내 머리카락을 빼내고 나서, 나는 그 정보를 훨씬 현명하게 만들어야 할 것 같네 .... .다시!Rails 3.2.2 capistrano로 배포 한 후에 스타일 시트 및 js 자산에 404를 얻는 것
확인, 그래서 여기에 나는이 문제를 다음하고있어 다음과 같은 두 가지 railscasts :
deploying to a vps
asset pipeline in production
내 설정 :
우분투 서버 12.04
의 nginx
유니콘
루비 1.9.3p125
레일 3.2.2
광고 모든 것이 T (또는 차 또는 어쩌면 티에 따라 다름)라고 말할 수있는 한,이 문구는 전에는 적어 두었습니다. 앉아서 내 서버에서 실행되고 있지만 스타일 시트와 자바 스크립트 파일은로드되지 않습니다. Rails 3.1 404 Error when loading .css files that are present in public/assets 또는 Rails 404 error for Stylesheet or JavaScript files과 같은 문제인 것으로 보입니다. 처음에는 아무런 대답이 없지만 후자는 정적 인 자원을 찾지 않고 아마 그렇게해서는 안되는 웹 서버에 문제가있을 수 있다고 제안합니다.
누가이 문제의 원인인지 알고 있습니까?
몇 가지 사실 : 첫째
, 내가 미리 컴파일에 대한 성가신 오류를 받고 내 개별 CSS/JS 파일을 애플리케이션 대응으로 축소 된했던 것으로 나타났습니다 그래서 나는 그들의 선언을 변경되었습니다 루비 도우미가이를 반영합니다. 내가
config/environments/production.rb
에
config.serve_static_assets = true
로 변경할 때응용 프로그램은 당신이 볼 수 있듯이 더가 여기에 내 서버
Started GET "/main" for 92.237.28.149 at 2012-07-09 23:08:02 +0100 Processing by MainController#index as HTML Rendered shared/_login_form.html.erb (0.4ms) Rendered shared/_footer.html.erb (0.4ms) Rendered shared/_details_form.html.erb (7.7ms) Rendered main/index.html.erb within layouts/main_logged (17.1ms) Completed 200 OK in 21ms (Views: 20.5ms | ActiveRecord: 0.0ms) Compiled jquery.js (2ms) (pid 8253) Compiled jquery_ujs.js (0ms) (pid 8253) Compiled admin_user.js (227ms) (pid 8253) Compiled construction.js (227ms) (pid 8253) Compiled google-map.js (0ms) (pid 8253) Compiled jquery-1.2.6.min.js (1ms) (pid 8253) Compiled jquery-ui-personalized-1.5.2.packed.js (0ms) (pid 8253) Compiled login.js (227ms) (pid 8253) Compiled main.js (222ms) (pid 8253) Compiled menu.js (223ms) (pid 8253) Compiled order_steps.js (225ms) (pid 8253) Compiled register_user.js (223ms) (pid 8253) Compiled sprinkle.js (0ms) (pid 8253) Compiled sticky_basket/jquery.easing.1.3.js (0ms) (pid 8253) Compiled sticky_basket/stickysidebar.jquery.js (0ms) (pid 8253) Compiled sticky_basket/stickysidebar.jquery.min.js (0ms) (pid 8253) Compiled user.js (292ms) (pid 8253) Compiled application.js (2155ms) (pid 8253) Compiled admin_user.css (12ms) (pid 8253) Compiled construction.css (0ms) (pid 8253) Compiled construction.css (1ms) (pid 8253) Compiled lightbox.css (0ms) (pid 8253) Compiled login.css (1ms) (pid 8253) Compiled main.css (0ms) (pid 8253) Compiled login.css (1ms) (pid 8253) Compiled main.css (0ms) (pid 8253) Compiled main.css (2ms) (pid 8253) Compiled menu.css (1ms) (pid 8253) Compiled menu_style.css (0ms) (pid 8253) Compiled normalise.css (0ms) (pid 8253) Compiled order_steps.css (0ms) (pid 8253) Compiled order_steps.css (1ms) (pid 8253) Compiled register_user copy.css (0ms) (pid 8253) Compiled register_user.css (0ms) (pid 8253) Compiled register_user.css (1ms) (pid 8253) Compiled tab_style.css (0ms) (pid 8253) Compiled user.css (1ms) (pid 8253) Compiled application.css (236ms) (pid 8253) Compiled jquery.js (2ms) (pid 8253) Compiled jquery_ujs.js (0ms) (pid 8253) Compiled admin_user.js (273ms) (pid 8253) Compiled construction.js (225ms) (pid 8253) Compiled google-map.js (0ms) (pid 8253) Compiled jquery-1.2.6.min.js (1ms) (pid 8253) Compiled jquery-ui-personalized-1.5.2.packed.js (0ms) (pid 8253) Compiled login.js (269ms) (pid 8253) Compiled main.js (225ms) (pid 8253) Compiled menu.js (224ms) (pid 8253) Compiled order_steps.js (226ms) (pid 8253) Compiled register_user.js (224ms) (pid 8253) Compiled sprinkle.js (0ms) (pid 8253) Compiled sticky_basket/jquery.easing.1.3.js (0ms) (pid 8253) Compiled sticky_basket/stickysidebar.jquery.js (0ms) (pid 8253) Compiled sticky_basket/stickysidebar.jquery.min.js (0ms) (pid 8253) Compiled user.js (224ms) (pid 8253) Compiled application.js (2096ms) (pid 8253) Compiled admin_user.css (12ms) (pid 8253) Compiled construction.css (0ms) (pid 8253) Compiled construction.css (1ms) (pid 8253) Compiled lightbox.css (0ms) (pid 8253) Compiled login.css (1ms) (pid 8253) Compiled main.css (0ms) (pid 8253) Compiled login.css (1ms) (pid 8253) Compiled main.css (0ms) (pid 8253) Compiled main.css (1ms) (pid 8253) Compiled menu.css (2ms) (pid 8253) Compiled menu_style.css (0ms) (pid 8253) Compiled normalise.css (0ms) (pid 8253) Compiled order_steps.css (0ms) (pid 8253) Compiled order_steps.css (1ms) (pid 8253) Compiled register_user copy.css (0ms) (pid 8253) Compiled register_user.css (0ms) (pid 8253) Compiled register_user.css (1ms) (pid 8253) Compiled tab_style.css (0ms) (pid 8253) Compiled user.css (1ms) (pid 8253) Compiled application.css (179ms) (pid 8253) Started GET "/main" for 92.237.28.149 at 2012-07-09 23:15:00 +0100 Processing by MainController#index as HTML Rendered shared/_login_form.html.erb (1.2ms) Rendered shared/_footer.html.erb (1.1ms) Rendered shared/_details_form.html.erb (15.5ms) Rendered main/index.html.erb within layouts/main_logged (80.9ms) Completed 200 OK in 142ms (Views: 140.4ms | ActiveRecord: 0.0ms) Started GET "/main" for 92.237.28.149 at 2012-07-09 23:33:54 +0100 Processing by MainController#index as HTML Rendered shared/_login_form.html.erb (1.2ms) Rendered shared/_footer.html.erb (1.1ms) Rendered shared/_details_form.html.erb (15.6ms) Rendered main/index.html.erb within layouts/main_logged (80.7ms) Completed 200 OK in 142ms (Views: 140.0ms | ActiveRecord: 0.0ms)
에 생산 .LOG의 덤프가없는 로컬로 작동 사전 컴파일에 대한 더 많은 불만
여기에 생성 된 html은
입니다. 내가 그들을 클릭하면<title>HTML Snippet</title>
<link href="/assets/application-dd445a707b7e96c914afd14bf1f02bbc.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/assets/application-def3878140cda305cb0ca5ef745fd758.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js" type="text/javascript"></script>
이러한 링크는 nginx를 (404)을 생성하지만 난 http://<ipaddress>/public/assets/application-dd445a707b7e96c914afd14bf1f02bbc.css
에 URL을 변경하는 경우 나는 레일 The page you were looking for doesn't exist.
그리고 여기이의 중요한 (내가 생각하는) 내용입니다 생성 얻을/공공/
,536,913 :에 마지막으로application-7c90c01effcf9d8593e28e4c4b716ac2.css
application-7c90c01effcf9d8593e28e4c4b716ac2.css.gz
application.css
application.css.gz
application-dd445a707b7e96c914afd14bf1f02bbc.css
application-dd445a707b7e96c914afd14bf1f02bbc.css.gz
application-def3878140cda305cb0ca5ef745fd758.js
application-def3878140cda305cb0ca5ef745fd758.js.gz
application.js
application.js.gz
, 아니에요 지역 분명하고 너무 그 모든 덮여, 여기 카피 스트라 노,의 nginx와 유니콘의 구성을 위해 railscast에 사용 된 파일은 내 서버에 자산
캡 파일
에 load 'deploy/assets'
의 주석 처리를 해제했습니다.
root = "/home/daz/apps/little_oven_deploy/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.little_oven_deploy.sock"
worker_processes 2
timeout 30
unicorn_init.sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
set -e
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/daz/apps/little_oven_deploy/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
AS_USER=daz
set -u
OLD_PIN="$PID.oldbin"
sig() {
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig() {
test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
}
run() {
if [ "$(id -un)" = "$AS_USER" ]; then
eval $1
else
su -c "$1" - $AS_USER
fi
}
case "$1" in
start)
sig 0 && echo >&2 "Already running" && exit 0
run "$CMD"
;;
stop)
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
run "$CMD"
;;
upgrade)
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
then
n=$TIMEOUT
while test -s $OLD_PIN && test $n -ge 0
do
printf '.' && sleep 1 && n=$(($n - 1))
done
echo
if test $n -lt 0 && test -s $OLD_PIN
then
echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
exit 1
fi
exit 0
fi
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
run "$CMD"
;;
reopen-logs)
sig USR1
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
exit 1
;;
esac
unicorn_init.sh unicorn.rb
upstream unicorn {
server unix:/tmp/unicorn.little_oven_deploy.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# server_name example.com;
root /home/deployer/apps/blog/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
nginx.conf RB
require "bundler/capistrano"
server "92.237.28.149", :web, :app, :db, primary: true
set :application, "little_oven_deploy"
set :user, "daz"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "[email protected]:DanBaldwin/little_oven_deploy.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
after "deploy:finalize_update", "deploy:symlink_config"
desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
before "deploy", "deploy:check_revision"
end
또한 chmod를 + X이다.
정보 사용자의 잠재적 인 과부하는 미안하지만 내 문제의 스냅 샷을 제공하는 데 도움이된다면 진단을받는 데 도움이되며 도움이된다면 많은 도움이됩니다. 사전에
덕분에
감사합니다. Promethean_Sin – Trip
자신 만의 질문에 답변하는 것이 좋습니다. 이것이 참으로 정답이라면 그것을 받아 들여라. 나처럼 나에게 도착한 사람들에 대한 정확한 대답은 가장 중요한 목표입니다. –
설명해 주셔서 고맙습니다. @thedeoo – DazBaldwin