我在一个共享主机上有权inheritancenginx根安装并覆盖它的configuration文件(注意:我不想在我的主目录中编译自己的nginx)。
我写了一个开始/重新加载/停止脚本,完美的工作,但我不断收到下面的错误
启动脚本
#!/bin/bash # Set this to your nginx configuration file and PID CONFIG=~/nginx/nginx.conf PIDFILE=~/nginx/nginx.pid # Do not change anything below unless you know what you do DAEMON=/usr/local/nginx/sbin/nginx NAME="nginx" PATH=/sbin:/bin:/usr/sbin:/usr/bin OPTS="-c $CONFIG" ...
我的configuration:
worker_processes 4; error_log /home/myusername/nginx/error.log; pid /home/myusername/nginx/nginx.pid; events { worker_connections 8192; multi_accept on; use epoll; } http { error_log /home/myusername/nginx/error.log; access_log /home/myusername/nginx/access.log; server_names_hash_max_size 8192; server_names_hash_bucket_size 128; include /etc/nginx/mime.types; underscores_in_headers on; ...
错误:
Reloading nginx configuration: [alert]: could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied) nginx.
所以它似乎没有阅读我的错误和正确访问日志位置,我该如何解决这个,谢谢!
在读取你的configuration文件之前,NGINXsearch内置的错误日志位置。
你可以在这里find它: http ://wiki.nginx.org/CoreModule在error_log部分。
“另外请注意,从版本0.7.53开始,nginx会使用一个编译后的默认错误日志位置,直到它读取到configuration文件。如果运行nginx的用户没有写入权限,nginx将会引发像这样的警报:
[alert]:无法打开错误日志文件:open()“/var/log/nginx/error.log”failed(13:Permission denied)“
我已经能够得到这个工作使用-p选项,设置前缀到我可以写入的path。
$ nginx -p . -c my-nginx.conf