服务器之家:专注于服务器技术及软件下载分享
分类导航

云服务器|WEB服务器|FTP服务器|邮件服务器|虚拟主机|服务器安全|DNS服务器|服务器知识|Nginx|IIS|Tomcat|

服务器之家 - 服务器技术 - Nginx - Nginx中运行PHP框架Laravel的配置文件分享

Nginx中运行PHP框架Laravel的配置文件分享

2019-10-28 13:56Nginx教程网 Nginx

这篇文章主要介绍了Nginx中运行PHP框架Laravel的配置文件分享,本文直接给出配置示例,需要的朋友可以参考下

配置文件改成这样

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

在CentOS7.1+Nginx1.8.0+Laravel5.0测试通过

延伸 · 阅读

精彩推荐