nginx 错误日志在自定义位置导致权限被拒绝(启动时)

nginx 错误日志在自定义位置导致权限被拒绝(启动时)

我正在使用带有 CentOS 7.x 的 AWS EC2(c3.xlarge)实例,这些是我的挂载点:

[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

根分区/为 8gb(用于操作系统),我安装了一个 40gb 的驱动器/mnt用于网站文件。这是标准设置。

我以 root 身份登录(使用sudo su -),并将的所有权更改/mntcentos:centos(您登录的默认帐户)。

在此目录中,创建另一个目录来存储所有错误日志:(/mnt/errors目录权限为 755)。

Nginx 安装后nginx.conf有以下几行:

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

当我使用此命令启动 nginx 服务器时:systemctl 启动 nginx.service我收到以下错误:

[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.

为什么我不能使用自定义位置来存储 nginx 错误?

相关内容