0

I was googled alot but not find a solution for this, i am trying start nginx after a basic config, and i am getting the following error:

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.

The file of vhost /etc/nginx/sites-available/medjey are same this below:

    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;
    }

and the /etc/nginx/nginx.conf are same this:

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;
}

I alredy changed all permissions and owners possible, but its still not up the service.

CentOS 7

Nakilon
  • 34,866
  • 14
  • 107
  • 142
John Kurv
  • 1
  • 1
  • 1
  • Does this answer your question? [Nginx: Permission denied for nginx on Ubuntu](https://stackoverflow.com/questions/18714902/nginx-permission-denied-for-nginx-on-ubuntu) – Michael Freidgeim Dec 15 '20 at 11:33

2 Answers2

0

Solved, just need change on /etc/sysconfig/selinux to SELINUX=permissive and adjust the vhost on servername change for the IP.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
John Kurv
  • 1
  • 1
  • 1
0

Use sestatuss to check whether the firewall is open or not.

I also faced same issue . Just disable the Selinux

HarshitG
  • 2,677
  • 3
  • 16
  • 13