phpstudy2017版本的nginx 支持laravel 5.X配置


之前做開發和學習一直用phpstudy的mysql服務,確實很方便,開箱即用。QQ群交流:697028234

現在分享一下最新版本的phpstudy2017 laravel環境配置。

最新版的phpstudy2017已支持php7,也就是說支持目前最新版的laravel了。

1、安裝好phpstudy2017,下載laravel解壓,我這是放到c:\laravel。

2、設置phpstudy的站點域名管理,自己定義一個域名。如www.herostore.cn  然后指定到c:\laravel。

3、修改host文件。我是win7哈。加入:127.0.0.1 www.herostore.cn 

4、默認情況下,如果是用的apache,就已經可以運行laravel項目了。如果訪問報Forbidden錯誤,再檢查一下vhosts.conf文件。

看虛擬主機目錄和參數是否設置正確,如下:

<VirtualHost *:80>
    DocumentRoot "H:\code\blog"
    ServerName www.blog.com
  <Directory "H:\code\blog">
      Options Indexes FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
  </Directory>
</VirtualHost>

 

重點來了。如果切換到nginx環境,就不行。報禁止訪問的錯誤。

何解?手動修改nginx.conf文件。增加一個server即可。媽媽再也不用擔心我的學習了。呵呵。

 

 1 server {
 2         listen  80;
 3         server_name www.herostore.cn;
 4         set $root_path 'c:/laravel/';
 5         root $root_path;
 6 
 7         index index.php index.html index.htm;
 8 
 9         location / {
10             try_files $uri $uri/ /index.php?$query_string;
11         }
12 
13         location ~ \.php(.*)$  {
14             fastcgi_pass   127.0.0.1:9000;
15             fastcgi_index  index.php;
16             fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
17             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
18             fastcgi_param  PATH_INFO  $fastcgi_path_info;
19             fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
20             include        fastcgi_params;
21         }
22 
23         location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
24 
25         }
26 
27         location ~ /\.ht {
28             deny all;
29         }
30     }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM