我正在使用Unicorn在Nginx上开发Rails应用程序。 当我用Capistrano启动Nginx时,但是无法写入access.log。
我已经更改了日志目录和文件的权限和用户,但它对我没有用。 有人能帮助我吗?
我的nginx.conf就像这样
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
upstream unicorn {
server unix:/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80 default_server;
server_name _;
location ~ ^/assets/ {
root /home/vagrant/xxx/public;
}
location / {
proxy_pass http://unicorn;
}
}
}
我已经更改了用户' nginx'流浪者'。 (' vagrant'是服务器的ssh用户)
目录:
drwx------ 2 vagrant vagrant 4096 Nov 20 18:53 nginx
日志文件:
-rw-r--r-- 1 nginx nginx 0 Nov 20 18:53 access.log
-rw-r--r-- 1 vagrant vagrant 0 Nov 20 18:53 error.log
unicorn.rb(位于rails应用程序中)
listen "/tmp/unicorn.sock"
worker_processes 2 # this should be >= nr_cpus
working_directory "/home/vagrant/xxx/current"
pid "/home/vagrant/xxx/shared/tmp/pids/unicorn.pid"
stderr_path "/home/vagrant/xxx/shared/log/unicorn.log"
stdout_path "/home/vagrant/xxx/shared/log/unicorn.log"
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "/home/vagrant/xxx/current/Gemfile"
end
答案 0 :(得分:1)
之后,我注意到nginx.conf中出现了一些错误。