For some reason I cannot change the root. I have the same rights as the default root on /usr/share/nginx/html
, and I also have 755
recursive on all files and folders in my other folder. I even tried changing the user and group to root and nginx back and forth to see if it made any difference but it doesn't. I keep getting 403 Forbidden
so basicly I made this folder
$ mkdir -p /srv/www/test.com/public_html
$ vi /srv/www/test.com/public_html/index.html
$ vi /srv/www/test.com/public_html/test.php
$ chmod -R 755 /srv/www/test.com/public_html
tried to change the user and group to nginx
$ chown -R nginx:nginx /srv/www
configured the main conf file
$ vi /etc/nginx/nginx.conf
this is how my config looks like, the includes are commented out
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /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;
keepalive_timeout 65;
index index.php index.html index.htm;
server {
listen 80;
server_name _;
root /srv/www/test.com/public_html;
# root /usr/share/nginx/html;
location / {
autoindex on;
}
error_page 404 /404.html;
location = /40x.html { }
error_page 500 502 503 504 /50x.html;
location = /50x.html { }
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
everything works in the default root folder that is commented out, but when I change the root I get 403 forbidden. I feel like I have tried everything I can, changing users and file permissions and so on. the php-fpm has nginx as user and group. and the user is set to nginx in the main.conf file. I only use this one file for configuration for nginx, and have the includes commented out.
I have no idea what to do. Been stuck for hours now. Any help would be greatly appreciated
ls -lh /srv/www/test.com/public_html/index.html
? Do you have SELinux running enforcing mode ?