php lumen nginx,nginx常规PHP框架的服务配置整理(TP5、CI、lumen、laravel等持续补充)...

phpinfo

server {

listen 80;

server_name phpinfo.com;

root /home/www/test;

index index.php index.html;

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

如果cgi_pass是连接php-fpm.sock,记得要设置php-fpm.conf里面的

listen.owner = nginx

listen.group = nginx

listen.mode = 0660

server {

listen 80;

server_name localhost;

root /data/php/phpinfo;

index index.php index.html;

location ~ \.php$ {

fastcgi_pass unix:/data/php/run/php-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

CI框架

server {

listen 80;

server_name dev.ci.com;

index index.php index.html index.htm;

root /lhdata/wwwroot/ci-api.benting.com.cn/www;

location / {

try_files $uri $uri/ /index.php?$query_string;

}

location ~ [^/]\.php(/|$) {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {

expires 30d;

access_log off;

}

location ~ .*\.(js|css)?$ {

expires 7d;

access_log off;

}

location ~ /\.ht {

deny all;

}

}

lumen框架

server {

listen 80;

server_name ???.com.cn;

access_log /???_nginx.log combined;

index index.php index.html index.htm;

root /???/[lumen_project]/public;

location / {

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=$1 last;

break;

}

}

# 添加一些跨域配置

add_header Access-Control-Allow-Origin *;

add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";

add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";

location ~ [^/]\.php(/|$) {

#fastcgi_pass remote_php_ip:9000;

fastcgi_pass unix:/dev/shm/php-cgi.sock;

fastcgi_index index.php;

include fastcgi.conf;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {

expires 30d;

access_log off;

}

location ~ .*\.(js|css)?$ {

expires 7d;

access_log off;

}

location ~ /\.ht {

deny all;

}

}

laravel框架

server {

listen 80;

server_name test.laravel.com;

root /home/www/gitosc/laravel_blog/public;

index index.html index.htm index.php;

charset utf-8;

location / {

try_files $uri $uri/ /index.php?$query_string;

}

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_intercept_errors off;

fastcgi_buffer_size 16k;

fastcgi_buffers 4 16k;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

}

location ~ /\.ht {

deny all;

}

}

整理常用PHP框架重写规则

ThinkPHP5重写规则

location / {

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=$1 last;

break;

}

}

Laravel或Lumen重写规则

location / {

try_files $uri $uri/ /index.php?$query_string;

}

CI框架重写规则

location / {

try_files $uri $uri/ /index.php?$query_string;

}

Yii2重写规则

location / {

if (!-f $request_filename){

rewrite ^/(.*)$ /index.php?/$1 last;

break;

}

}

希望大家会有所帮助,自己需要的时候也可以回头查查很方便,谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值