Answer the question
In order to leave comments, you need to log in
Why is the virtual host not working correctly?
Hello
ubuntu 16.04 + php 7 + nginx
pasha4ur.local - 404 when try_files $uri =404; or File not found with try_files $uri $uri/ =404;.
pasha4ur.local/index.html - access denied (Other - read only)
pasha4ur.local/index.php - ok
Put on the folder and files 777 - 0 effect.
/etc/nginx/sites-enabled/pasha4ur.local
#this first server module is just a rewrite directive – it is not required, and you
#can make the rewrite go the other way, to force NOT using www
server {
listen 80; #sets the HTTP port from which the website is served
server_name www.pasha4ur.local; #names the server using the www prefix
#if a server request is made without www, this next line will rewrite it
rewrite ^/(.*) http://pasha4ur.local$request_uri? permanent; #301 redirect
}
#this second server module tells Nginx where to find the files when requested
server {
listen 80; #sets the HTTP port from which the website is served
server_name pasha4ur.local; #names the server being configured
root /home/pasha4ur/public_html/pasha4ur.local; #top directory for the site
index index.php index.html index.htm index.nginx-debian.html;
client_max_body_size 1G;
fastcgi_buffers 64 4K;
location / { #sets the location of the files being served
try_files $uri $uri/ =404;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question