루트가 아닌 사용자로 nginx 실행 시작하기 위해 init

내 우분투 10.04 루시드 서버에 nginx를 설치하기이 과정을 따라 http://library.linode.com/web-servers/nginx/installation/ubuntu-10.04-lucid

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‘전체 디렉토리를 D ( chown -R nginx:nginx /opt/nginx)와 나는 또한했습니다 chmod -R 755디렉토리를뿐만 아니라.

userCS3에서 제안한 지시문을 추가하면 이 오류가 발생하지만 추가 줄이 있습니다.

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 ==>를 실행하면 nginx.conf 사용자 지시문에 지정한 사용자 (예 : www-data)로 root 및 worker 프로세스로 마스터 nginx 프로세스를 시작합니다.

sudo /etc/init.d/nginx start를 실행할 때 nginx의 모든 프로세스가 루트로 실행 중인지 확인할 수 있습니까?

ps aux | grep [n]ginx

예.

제안 : Ubuntu 10.04 LTS는 nginx 팀으로부터 탁월한 우분투 패키지를 지원합니다. 그렇다면 nginx 내부에 커스텀 모듈이 필요하지 않은 이유는 무엇입니까?

여기에 문의 하십시오

바이너리 꾸러미에는 이미 필요한 모듈이 많이 들어 있습니다

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

답변

nginx.conf 안에 사용자 지시문을 추가하십시오

참조 : http://wiki.nginx.org/CoreModule#user


답변

이것에 관한 나의 5 kopek

nginx -V 2>&1 | sed 's/ --/\n--/g' | grep path

..는 사용자가 제공 한 구성 또는 “-g”옵션으로 재정의해야하는 다른 모든 경로를 제공합니다.


답변

제 경우에는 nginx.conf에 파일 참조가 없습니다.

error_log /var/log/nginx/error.log 경고;

오류 : error_log 경고;

따라서 우연히 권한 거부 오류 메시지를 유발 한 /var/log/nginx/error.log 참조를 삭제했습니다.