The default in the nginx sites-available file has modified the root path. But when accessing localhost, it always downloads the web page directly instead of opening the URL, which is very strange.
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html/laravel/public;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;
server_name 127.0.0.1;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
Looking at the configuration of the question, there is laravel, it seems to be related to PHP. If it is PHP, then the questioner, you should download php5-fpm first, because nginx itself does not execute PHP programs like Apache, but gives it to php5-fpm execution.
So, your steps should be as follows:
Download php5-fpm
Configure nginx to communicate with fpm. There are many configuration methods on the Internet. I will not repeat them. Here is a reminder: There are two ways for nginx to communicate with fpm, one is through ip, and the other is through socket.fpm and nginx. Configure the same communication method!!
Whether the final test was successful? Of course, it is possible that the accessed page will be downloaded when you get here. If you encounter this situation, you need to check again, but it is safer for the questioner to get the fpm first.
In order to better solve the problem of the subject, I saved a copy of the configuration I just made in the ubuntu14.04 environment
Not many changes:
index I put index.php in the first position
root path, please note that the last path does not have
/
Remove the comments related to php, my
/etc/php5/fpm/pool.d/www.conf
中找到listen = /var/run/php5-fpm.sock
,说明fpm是开启了socket,所以nginx的fastcgi_pass
parameter in fpm is also socket.For example, at the end of php, you need to use php’s cgi to parse it
@chenjiayao