1

I am using an AWS EC2 (c3.xlarge) instance with CentOS 7.x and these are my mount points:

[centos@ip-10-0-4-119 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      8.0G  1.5G  6.6G  18% /
devtmpfs        3.6G     0  3.6G   0% /dev
tmpfs           3.5G     0  3.5G   0% /dev/shm
tmpfs           3.5G   17M  3.5G   1% /run
tmpfs           3.5G     0  3.5G   0% /sys/fs/cgroup
/dev/xvdb        40G   49M   38G   1% /mnt
tmpfs           707M     0  707M   0% /run/user/1000

The root partition / is 8gb (for the OS) and I have a 40gb drive mounted on /mnt for the website files. This is a standard setup.

I logged in as root (using sudo su -) and changed the ownership of /mnt to centos:centos (default account you login into).

in this dir, made another directory to store all the error logs here: /mnt/errors (dir perm is 755).

Nginx was installed the nginx.conf has the following lines:

user             centos;
worker_processes 4;
error_log        /mnt/errors/nginx-errors.log crit;
pid              /var/run/nginx.pid;

When I start the nginx server with this command: systemctl start nginx.service I get the following errors:

[centos@ip-10-0-4-119 ~]$ sudo systemctl status nginx
â— nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2016-11-11 02:20:14 UTC; 7min ago
     Docs: http://nginx.org/en/docs/
  Process: 10394 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

Nov 11 02:20:14 ip-10-0-4-119.localdomain systemd[1]: Starting nginx - high performance web server...
Nov 11 02:20:14 ip-10-0-4-119.localdomain nginx[10394]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Nov 11 02:20:14 ip-10-0-4-119.localdomain nginx[10394]: nginx: [emerg] open() "/mnt/errors/nginx-errors.log" failed (13: Permission denied)
Nov 11 02:20:14 ip-10-0-4-119.localdomain nginx[10394]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 11 02:20:14 ip-10-0-4-119.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Nov 11 02:20:14 ip-10-0-4-119.localdomain systemd[1]: Failed to start nginx - high performance web server.
Nov 11 02:20:14 ip-10-0-4-119.localdomain systemd[1]: Unit nginx.service entered failed state.
Nov 11 02:20:14 ip-10-0-4-119.localdomain systemd[1]: nginx.service failed.

Why am I not able to use a custom location to store the nginx errors?

  • Do an ls -l /mnt/errors/nginx-errors.log does the user centos have write permission to that file? – Drifter104 Nov 11 '16 at 12:07
  • @Drifter104 The file has write permission. i.imgur.com/j9wIMja.png and this is the output of the ls command: -rw-rw-r--. 1 centos centos 0 Nov 11 02:20 /mnt/errors/nginx-errors.log – Latheesan Nov 11 '16 at 14:52
  • Just check and make sure nginx is running as centos with ps -eo "%U %G %a" | grep nginx – Drifter104 Nov 11 '16 at 15:18

Your Answer

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

Browse other questions tagged or ask your own question.