尝试启动时,nginx权限被拒绝

时间:2016-09-22 04:13:51

标签: linux apache nginx centos

我用谷歌搜索了很多,但没有找到解决方案,我尝试在基本配置后启动nginx,我收到以下错误:

Set 21 23:57:53 vps.medjy.ml nginx[21444]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Set 21 23:57:53 vps.medjy.ml nginx[21444]: nginx: [emerg] open() "/srv/www/medjey/logs/access.log" failed (13: Permission denied)
Set 21 23:57:53 vps.medjy.ml nginx[21444]: nginx: configuration file /etc/nginx/nginx.conf test failed
Set 21 23:57:53 vps.medjy.ml systemd[1]: nginx.service: control process exited, code=exited status=1
Set 21 23:57:53 vps.medjy.ml systemd[1]: Failed to start nginx - high performance web server.

vhost / etc / nginx / sites-available / medjey的文件如下所示:

    server {
    listen 80 default;
    server_name medjey;
    access_log /srv/www/medjey/logs/access.log;
    error_log /srv/www/medjey/logs/error.log;
    root /srv/www/medjey/public_html;
    location ~* \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    127.0.0.1:9000;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }

和/etc/nginx/nginx.conf是这样的:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;
## Load virtual host conf files. ##
    include /etc/nginx/sites-enabled/*;
    include /etc/nginx/conf.d/*.conf;
}

我alredy可能更改了所有权限和所有者,但它仍未启动服务。

CentOS 7

2 个答案:

答案 0 :(得分:0)

解决了,只需要将/ etc / sysconfig / selinux更改为SELINUX=permissive并调整服务器名称更改为IP的vhost。

答案 1 :(得分:0)

使用 sestatuss 检查防火墙是否打开。

我也面临同样的问题。 只需禁用Selinux

即可