【问题标题】:nginx permission denied when try start尝试启动时拒绝nginx权限
【发布时间】:2017-01-30 12:08:37
【问题描述】:

我被谷歌搜索了很多,但没有找到解决方案,我尝试在基本配置后启动 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;
}

我已经更改了所有可能的权限和所有者,但它仍然无法提供服务。

CentOS 7

【问题讨论】:

标签: linux apache nginx centos


【解决方案1】:

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

我也遇到了同样的问题。 只需禁用 Selinux

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 抱歉,新的服务器名称是什么?我在 FreeBSD 上遇到了同样的问题。
    猜你喜欢
    • 1970-01-01
    • 2012-01-01
    • 1970-01-01
    • 2021-03-13
    • 1970-01-01
    • 1970-01-01
    • 2013-06-05
    相关资源
    最近更新 更多