Die Standardeinstellung in der Nginx-Sites-verfügbaren Datei hat den Root-Pfad geändert. Beim Zugriff auf localhost wird die Webseite jedoch immer direkt heruntergeladen, anstatt die URL zu öffnen, was sehr seltsam ist.
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;
}
看题主配置里面有laravel,看来是跟php有关,如果是php,那么题主你应该先去下载php5-fpm才对,因为nginx本身不像apache一样会执行php程序,而是交给php5-fpm执行.
所以,题主你的步骤应该如下 :
下载php5-fpm
配置nginx,使nginx跟fpm通信,网上有很多配置方法,我不重复,这里指提醒一点 : nginx跟fpm通信方式有两种,一个是通过ip,一个是通过socket.fpm跟nginx里面要配置成同一种通信方式!!
最后测试是否成功.当然有可能到了这里还会出现访问页面下载下来的情况,如果遇到这个情况就需要再排查了,但是题主先搞定fpm比较稳妥.
为了更好的解决题主的问题,我扑出一份我刚刚在ubuntu14.04环境下的配置
改动的地方不多 :
index我把index.php放在第一位置
root路径,这里注意最后路径不要有
/
去掉跟php有关的注释,我在fpm的
/etc/php5/fpm/pool.d/www.conf
中找到listen = /var/run/php5-fpm.sock
,说明fpm是开启了socket,所以nginx的fastcgi_pass
参数也是socket.譬如php结尾,你要用php的cgi去解析
@chenjiayao