laravel的nginx配置

laravel的nginx的配置:php

 1 server {
 2         listen       80;
 3         server_name  localhost alias 127.0.0.1;
 4         location / {
 5             root   E:/down/UPUPW_NGINX_PHP5.6.7_1504_32bit/upupw/htdocs/laravel/public;
 6             index  index.html index.htm default.html default.htm index.php default.php app.php u.php;
 7             try_files      $uri $uri/ /index.php?$query_string;
 8             include        E:/down/UPUPW_NGINX_PHP5.6.7_1504_32bit/upupw/htdocs/up-*.conf;
 9         }
10         autoindex off;
11         include advanced_settings.conf;
12         location ~ ^.+\.php {
13             root           E:/down/UPUPW_NGINX_PHP5.6.7_1504_32bit/upupw/htdocs/laravel/public;
14             fastcgi_pass   bakend;
15             fastcgi_index  index.php;
16             fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
17             fastcgi_param  PATH_INFO $fastcgi_path_info;
18             fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;
19             include        fastcgi.conf;
20         }
21         location ~* ^.+.*\/(attachment|attachments|uploadfiles|avatar)\/.*\.(php|php5|phps|asp|aspx|jsp)$ {
22         deny all;
23         }
24         }
25 #server localhost end}

//注意兩處,html

(1):laravel的根目錄是在public目錄下面,因此須要修改」location \「 模塊的 根目錄地址 root項爲laravel的安裝路徑;nginx

(2):其餘的動態文件,即全部以.php結尾的文件,都交給上面設置的根目錄處理,修改" location ~ ^.+\.php "模塊的root項的根目錄爲laravel的安裝路徑.laravel

配置文件的servername 即監聽的域名此處配置爲:localhost,固然也能夠改爲其餘的域名做爲訪問lavarel目錄的域名,在瀏覽器處輸入localhost 或 127.0.0.1 便可以訪問laravel.截圖以下:瀏覽器

相關文章
相關標籤/搜索