403 Forbidden nginx/1.12.1 (Ubuntu) Distributor ID: Ubuntu Description: Ubuntu 17.10 Release: 17.10 Codename: artful I have many virtual sites running on my server identical to this one, but for some reason I have run into the 403 wall. Permissions for my virtual website dir sudo chown -R www-data:www-data /var/www/html/C1/ sudo chmod -R 755 /var/www/html/C1/ results drwxrwxrwx 3 www-data www-data 4096 May 23 12:37 C1 Code (markup): The virtual directory is as follows.. and is linked to. sudo ln -s /etc/nginx/sites-available/c1 /etc/nginx/sites-enabled/ server { listen 80; listen [::]:80; root /var/www/html/C1; index index.html index.php index.htm; server_name c1inventory.xxxxxxx.com; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } Code (markup): Dump from the nginx error log. 2018/05/23 14:15:49 [error] 1530#1530: *1 directory index of "/var/www/html/C1/" is forbidden, client: 67.127.276.257, server: c1inventory.xxxxxx.com, request: "GET / HTTP/1.1", host: "c1inventory.xxxxxx.com" Code (markup): Any help is greatly appreciated. Thanks.
The 403 Forbidden error shows that the file has bad permissions. Directories and folders must be 755. Executable scripts within the cgi-bin folder must be 755. Images, media, and text files like HTML should be 755 or 644. You can try out the following command: sudo chown -R www-data:www-data /usr/share/nginx/html/* sudo chmod -R 0755 /usr/share/nginx/html/*
Are you using PHP-FPM with Nginx? If so then go to PHP-FPM www.conf Code (markup): file and edit the below two lines and save and exit the file and restart Nginx, PHP-FPM service both. # vim /etc/php-fpm.d/www.conf. Code (markup): . user = nginx . group = nginx create an info.php file in /usr/share/nginx/html file using below code. save the file and exit. <?php phpinfo(); ?> now browse the file using your server IP http://xx.xx.xx.xx/info.php Code (markup): . it should work.