搜尋
首頁後端開發PHP7ubuntu16.04 PHP7安裝與Nginx PHP

nginx PHP常見錯誤

1、php7.0-fpm.sock權限不足:

[crit] 3182#3182: *20 connect() to unix:/run/php/php7.0-fpm.sock failed (13: Permission denied)

2、webroot路徑不對:

[error] 3147#3147: *10 FastCGI sent in stderr: "Unable to open primary script: /etc/nginx/html/index.php (No such file or directory)" while reading response header from upstream

PHP7安裝

刪除PHP7

apt-get autoremove --purge php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-gd php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline php7.0-sqlite3

安裝PHP7

apt-get install php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-gd php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline php7.0-sqlite3

#修改php .ini

vi /etc/php/7.0/fpm/php.ini

設定cgi.fix_pathinfo = 0

修改www.conf

vi /etc/php/7.0/fpm/pool.d/www.conf

把listen.mode = 0660 改成listen .mode = 0666

php7.0-fpm.sock預設(0660)權限

$ls -al /run/php/php7.0-fpm.sock
srw-rw----  1 www-data www-data   0 Mar 22 13:17 php7.0-fpm.sock

php7.0-fpm.sock(0666)權限

$ls -al /run/php/php7.0-fpm.sock
srw-rw-rw-  1 www-data www-data   0 Mar 22 13:17 php7.0-fpm.sock

重啟系統,這樣/run/php/php7.0-fpm.sock 檔案才會根據0666 權限重新產生

nginx PHP設定

location ~ \.php$ {
        root /your/web/root/document //必填,否则$document_root会是默认值/etc/nginx/html
        fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

對應的錯誤可以在Nginx的日誌/var/log/nginx/error.log中看到

以上是ubuntu16.04 PHP7安裝與Nginx PHP的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:segmentfault。如有侵權,請聯絡admin@php.cn刪除

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境