编程技术分享平台

网站首页 > 技术教程 正文

php Nginx配置(nginx配置php环境)

xnh888 2024-10-02 03:13:23 技术教程 17 ℃ 0 评论

大部分情况下,我们开发的php项目运行在linux下,下面介绍一下,php Nginx配置,前提已经安装好了php-fpm

打开nginx.conf文件配置如下:

server

{

listen 8082;

index index.html index.htm index.php;

server_name xx.com www.xx.com www.xx.cn xx.cn www.xx.com.cn;

root /web/forum;

location / {

index index.php index.html index.htm;

if (!-e $request_filename) {

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

break;

}

}

location ~ .*\.(php|php5)?$

{

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

fastcgi_param PATH_INFO $request_uri;

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

fastcgi_param PATH_INFO $fastcgi_path_info;

}

location ~ .*\.(cer|pem|sql|p12)$ {

deny all;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

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

{

expires 1h;

}

if (!-e $request_filename) {

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

break;

}

}

配置完成重启服务即可。

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表