Nginx解析PHP


剛安裝完PHP后,nginx是無法解析的,如果輸入地址會直接下載文件,需要進行如下的設置

步驟

修改/etc/nginx/sites-available/defaultcat /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代碼段,如下內容。如果你的發行版本文件與文章不同,可以留言,幫我完善這篇博文


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM