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.

1 Answer 1

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.

4
  • also check the selinux contexts of the files. Jan 6, 2017 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, 2017 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. Jan 6, 2017 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, 2017 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .