當前位置:首頁 » 存儲配置 » nginx怎麼配置php

nginx怎麼配置php

發布時間: 2022-06-14 20:58:20

1. nginx 怎麼修改php配置

####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;
}

2. 如何正確配置 Nginx 和 PHP

php用php-fpm啟動,然後nginx
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}很簡單吧,如果你想學習關於php的話,可以在有空時在後盾人看看教材視頻,多看看,不就會了。

3. 如何在linux下配置nginx支持php

需要。
如果是nginx+php配置,也可以通過查找php執行路徑
ps
aux
|
grep
php
如,路徑為
/usr/local/nginx/sbin/php-fpm
然後執行以下命令
/usr/local/nginx/sbin/php-fpm
-i
|
grep
「Loaded
Configuration
File」
即可看到php載入的配置文件

4. 如何正確配置 Nginx + PHP

1. php用php-fpm啟動,然後nginx
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
這樣就可以了
2.安裝一個集成的軟體phpstudy

熱點內容
網頁加密代碼 發布:2025-09-18 21:56:12 瀏覽:163
安卓targz解壓 發布:2025-09-18 21:45:58 瀏覽:800
怎麼設置手機屏幕密碼怎麼設置 發布:2025-09-18 21:44:18 瀏覽:817
直線插補演算法 發布:2025-09-18 21:22:49 瀏覽:654
矩陣內的演算法 發布:2025-09-18 20:55:07 瀏覽:572
android網路優化 發布:2025-09-18 20:53:19 瀏覽:218
看交換機配置哪些是默認的 發布:2025-09-18 20:46:59 瀏覽:620
在釘釘上如何獲取自己的密碼 發布:2025-09-18 20:46:12 瀏覽:855
pythonifthenelse 發布:2025-09-18 20:33:19 瀏覽:914
熱血傳奇腳本怎麼做 發布:2025-09-18 20:29:06 瀏覽:614