剛安裝完PHP后,nginx是無法解析的,如果輸入地址會直接下載文件,需要進行如下的設置
步驟
修改/etc/nginx/sites-available/default
和cat /etc/nginx/sites-enabled/default
文件,搜索php-fpm
,可以看到以下的內容,修改為你所安裝的版本,並取消注釋。
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
這里,如果遇到這個錯誤Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
一般就是修改錯了,可以按照提示使用systemctl status nginx.service
查看具體的錯誤信息。
不同發行版本安裝位置和目錄結構可能不同,但配置文件中會包含已經注釋掉的php代碼段,如下內容。如果你的發行版本文件與文章不同,可以留言,幫我完善這篇博文