當前位置:首頁 » 存儲配置 » 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

熱點內容
360代理伺服器怎麼設置 發布:2025-07-04 12:49:49 瀏覽:514
iphone在哪清除緩存 發布:2025-07-04 12:49:38 瀏覽:339
代理訪問網址 發布:2025-07-04 12:47:50 瀏覽:400
分頁存儲的管理方式 發布:2025-07-04 12:47:45 瀏覽:495
linux與windows路徑 發布:2025-07-04 12:41:42 瀏覽:461
伺服器的數據量怎麼查 發布:2025-07-04 12:32:23 瀏覽:217
sql查詢單引號 發布:2025-07-04 12:31:43 瀏覽:142
快手怎麼上傳英雄時刻 發布:2025-07-04 12:27:22 瀏覽:217
linux查命令 發布:2025-07-04 12:27:20 瀏覽:608
sqs演算法 發布:2025-07-04 12:27:05 瀏覽:972