nginx 怎么修改php配置
1个回答
展开全部
####nginx配置虚拟机,此配置是支持tp框架pathinfo路径的
server{
#监听端口
listen 80;
#网站域名
server_name web.api55.com;
#默认索引页
index index.php;
#网站目录
root /usr/local/nginx/html/api55;
location ~ .+\.php($|/) {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php?IF_REWRITE=1;
include fastcgi.conf;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}
}
####负载均衡服务配置
upstream web{
server 192.168.67.135 weight=1 max_fails=3 fail_timeout=20s;
server 192.168.67.136 weight=1 max_fails=3 fail_timeout=20s;
}
####删除原来web.api53.com里的server段里的location段,增加这一段location
location /{
proxy_pass http://web;
}
###################nginx转发php文件给apache
# 动态文件.php请求转发给后端Apache
location ~ .php$ {
# 向后端服务器发起请求时添加指定的header头信息
proxy_set_header Host $http_host;
# 向后端服务器发送真实 IP
proxy_set_header X-Real-IP $remote_addr;
# 让后端如php能直接通过变量获取真实IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
# nginx找不到文件时,转发请求给后端Apache
location @proxy {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
server{
#监听端口
listen 80;
#网站域名
server_name web.api55.com;
#默认索引页
index index.php;
#网站目录
root /usr/local/nginx/html/api55;
location ~ .+\.php($|/) {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php?IF_REWRITE=1;
include fastcgi.conf;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}
}
####负载均衡服务配置
upstream web{
server 192.168.67.135 weight=1 max_fails=3 fail_timeout=20s;
server 192.168.67.136 weight=1 max_fails=3 fail_timeout=20s;
}
####删除原来web.api53.com里的server段里的location段,增加这一段location
location /{
proxy_pass http://web;
}
###################nginx转发php文件给apache
# 动态文件.php请求转发给后端Apache
location ~ .php$ {
# 向后端服务器发起请求时添加指定的header头信息
proxy_set_header Host $http_host;
# 向后端服务器发送真实 IP
proxy_set_header X-Real-IP $remote_addr;
# 让后端如php能直接通过变量获取真实IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
# nginx找不到文件时,转发请求给后端Apache
location @proxy {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询