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:codelog"
    ServerName www.blog.com
  <Directory "H:codelog">
      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     }
原文地址:https://www.cnblogs.com/draculaqk/p/7838047.html