當前位置:首頁 » 編程語言 » 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

熱點內容
免費的socks5伺服器搭建 發布:2023-05-29 07:44:31 瀏覽:268
安卓11和安卓10哪個更好 發布:2023-05-29 07:44:25 瀏覽:343
西安兒童醫院密碼是多少 發布:2023-05-29 07:41:51 瀏覽:965
電視訪問小米路由器 發布:2023-05-29 07:38:38 瀏覽:843
酷狗緩存的mv在哪裡 發布:2023-05-29 07:38:34 瀏覽:51
怎麼定位手機找人安卓手機 發布:2023-05-29 07:37:41 瀏覽:755
為什麼安卓機不像蘋果那麼流暢 發布:2023-05-29 07:30:53 瀏覽:429
oauth20java 發布:2023-05-29 07:30:06 瀏覽:134
易編學學編程 發布:2023-05-29 07:29:06 瀏覽:559
定數java 發布:2023-05-29 07:29:04 瀏覽:891