當前位置:首頁 » 編程語言 » nginxphp被下載

nginxphp被下載

發布時間: 2023-04-01 23:42:36

1. nginx配置支持php

nginx本身不支持php解析,需要配合php-fpm來配置。

location~.php${
root/var/www;#指定php的根目錄
fastcgi_pass127.0.0.1:9000;#php-fpm的默認埠是9000
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}

centos下安裝php-fpm (php及其它組件已經安裝過的情況)

yuminstallphp-fpm

啟動php-fpm 並設置開機啟動 (centos 7)

systemctlstartphp-fpm
systemctlenablephp-fpm

2. centos7 apache訪問php文件變成下載index.php

nginx應該是先裝的,已經關聯php服務,httpd沒有關聯php,所以,就算你裝了php也沒用

3. nginx不解析php,訪問php文件彈出直接下載該文件 系統是centos7

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}

4. nginx搭建的伺服器,提示下載index.php源碼

你這個問題排查需要幾點確認:

  1. 把你的index.php復制一個其它名字的文件,看是否能正常訪問。

  2. 配置我建議你改成(原版的配置還少了一個括弧)

server {
listen 80;
server_name localhost;
root "D:/wwwroot";


location / {
index index.html index.htm index.php;
}


location ~ .php {
root "D:/wwwroot";
fastcgi_pass 127.0.0.1:33669;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}


你先按我說的試試。

5. php頁面變成下載頁面,nginx+linux

瀏覽器不支持php格式,請升級或換用其它瀏覽器。

要不然你可以參考這個

網頁鏈接

6. nginx 瀏覽php的時候會變成下載

php的時候會變成下載:這是因為nginx沒有設置好碰到php文件時,要傳遞到後方的php解釋器。

看看你的nginx.conf配置,裡面有沒有這樣的設置:
location ~ .*\.php$ {
fastcgi_pass 127.0.0.1:9000;
}
上面的意思,就是說,碰到.php結尾的文件,傳遞給後方127.0.0.1的9000埠上。

當然啦,你的php-fpm解析器也需要正常運行,並監聽好9000埠,才能最終生效並有效處理php腳本

windows下開啟監聽的辦法,php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini

熱點內容
c語言中a10什麼意思 發布:2024-04-27 10:45:43 瀏覽:58
物聯網中ftp是什麼意思 發布:2024-04-27 10:41:17 瀏覽:986
銀行密碼保護在哪裡 發布:2024-04-27 10:25:23 瀏覽:189
tomcat源碼導入eclipse 發布:2024-04-27 10:25:15 瀏覽:194
android的api 發布:2024-04-27 10:23:39 瀏覽:683
官式訪問 發布:2024-04-27 10:04:00 瀏覽:522
國產高配置有哪些 發布:2024-04-27 09:18:26 瀏覽:948
建行手機app忘記密碼如何修改 發布:2024-04-27 08:58:59 瀏覽:393
蟻群演算法的數學模型 發布:2024-04-27 08:58:39 瀏覽:994
androidactivity生命 發布:2024-04-27 07:33:48 瀏覽:84