1

I have NGINX running on CentOS7. And I would like to share the /etc/nginx directory between Linux and Windows.

The reason is that, I don't want to access the file every time I need to change/add hosts or play around with different configurations. For this I mounted the /etc/nginx dir to a folder on my Windows desktop as:

sudo mount -t vboxsf nginx /etc/nginx

Everything worked, and I can access both file and make an edit, but for some reason NGINX won't restart and this error is all I get.

[root@localhost]# systemctl status nginx.service
â nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2017-01-06 07:02:54 EST; 17s ago
     Docs: http://nginx.org/en/docs/
  Process: 3096 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

Jan 06 07:02:54 aphrodite systemd[1]: Starting nginx - high performance web server...
Jan 06 07:02:54 aphrodite nginx[3096]: nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (13: Permission denied)
Jan 06 07:02:54 aphrodite nginx[3096]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 06 07:02:54 aphrodite systemd[1]: nginx.service: control process exited, code=exited status=1
Jan 06 07:02:54 aphrodite systemd[1]: Failed to start nginx - high performance web server.
Jan 06 07:02:54 aphrodite systemd[1]: Unit nginx.service entered failed state.
Jan 06 07:02:54 aphrodite systemd[1]: nginx.service failed.
2

nginx can't read it's main configuration file, as seen in the service status output you have provided:

Jan 06 07:02:54 aphrodite nginx[3096]: nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (13: Permission denied

Fix the ownership/mod of the file (with chown, chmod) and use a different approach to access nginx folder from Windows, as most like that has mixed up the file permissions.

| improve this answer | |
  • also check the selinux contexts of the files. – Gerald Schneider Jan 6 '17 at 12:33
  • Ah! It worked with chmod 777 /etc/nginx -R but not with chown root or nginx. i know chmod 777 bad, but it's only for development – user7342807 Jan 6 '17 at 12:49
  • The issue is that vboxfs doesn't do permissions properly and nginx drops to www-data or www or httpd or something like that from root after it's started and then no longer has access to those files. – John Keates Jan 6 '17 at 22:26
  • please do not leave /etc/nginx with full write privileges...this will lead to a whole load of problems later. – Hydra IO Jan 13 '17 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.