ubuntu – 以非root用户身份运行nginx

前端之家收集整理的这篇文章主要介绍了ubuntu – 以非root用户身份运行nginx前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我按照这个过程在我的Ubuntu 10.04 Lucid Server http://library.linode.com/web-servers/nginx/installation/ubuntu-10.04-lucid上安装Nginx

在创建启动Nginx的init脚本,然后调用/etc/init.d/Nginx start之后,我迷路了.当我这样做时,我收到以下错误

Starting Nginx_main: Starting /opt/Nginx/sbin/Nginx...
Nginx: [alert] could not open error log file: open() "/opt/Nginx/logs/error.log" Failed (13: Permission denied)
2012/03/16 18:17:27 [emerg] 859#0: open() "/opt/Nginx/logs/access.log" Failed (13: Permission denied)

我可以运行它的唯一方法是,如果我使用sudo并以root身份运行该进程,这是我不想要的.

我已经知道整个目录(chown -R NginxNginx / opt / Nginx),我也chmod -R 755目录.

按照CS3的建议添加用户指令也会给我这个错误,但是还有一行.

Starting Nginx_main: Starting /opt/Nginx/sbin/Nginx...
Nginx: [alert] could not open error log file: open() "/opt/Nginx/logs/error.log" Failed (13: Permission denied)
2012/03/16 18:48:34 [warn] 1606#0: the "user" directive makes sense only if the master process runs with super-user privileges,ignored in /opt/Nginx/conf/Nginx.conf:2
2012/03/16 18:48:34 [emerg] 1606#0: open() "/opt/Nginx/logs/access.log" Failed (13: Permission denied)

有任何想法吗?

首先,应该运行init脚本
sudo /etc/init.d/name

当您没有以root用户身份登录时(登录用户启用了sudo时)

其次,当你运行sudo /etc/init.d/Nginx start ==>它以root用户身份激活主Nginx进程,并按照你在Nginx.conf用户指令中指定的用户进行工作进程(例如www-data)

在发出sudo /etc/init.d/Nginx start时,你能否确认Nginx下的所有进程是否由root运行?

ps aux | grep [n]ginx

例如.

建议:Ubuntu 10.04 LTS拥有来自Nginx团队的优秀ubuntu软件包支持.那么,如果你不需要Nginx中的自定义模块,为什么还要从源代码安装呢?

咨询here

二进制包已经附带了非常需要的模块

Nginx version: Nginx/1.0.12
TLS SNI support enabled
configure arguments: --prefix=/etc/Nginx --conf-path=/etc/Nginx/Nginx.conf --error-log-path=/var/log/Nginx/error.log --http-client-body-temp-path=/var/lib/Nginx/body --http-fastcgi-temp-path=/var/lib/Nginx/fastcgi --http-log-path=/var/log/Nginx/access.log --http-proxy-temp-path=/var/lib/Nginx/proxy --http-scgi-temp-path=/var/lib/Nginx/scgi --http-uwsgi-temp-path=/var/lib/Nginx/uwsgi --lock-path=/var/lock/Nginx.lock --pid-path=/var/run/Nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/Nginx-1.0.12/debian/modules/Nginx-echo --add-module=/build/buildd/Nginx-1.0.12/debian/modules/Nginx-upstream-fair
原文链接:https://www.f2er.com/ubuntu/348798.html

猜你在找的Ubuntu相关文章