search
HomeBackend DevelopmentPHP7Ubuntu16.04 PHP7 installation and Nginx PHP

nginx PHP common errors

1. Insufficient permissions for php7.0-fpm.sock:

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

2. Wrong webroot path:

[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

PHP7Install

Delete 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

Install 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

Modify php .ini

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

Set cgi.fix_pathinfo = 0

Modify www.conf

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

Change listen.mode = 0660 to listen .mode = 0666

php7.0-fpm.sock default (0660) permissions

$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) permissions

$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

Restart the system, In this way, the /run/php/php7.0-fpm.sock file will be regenerated according to the 0666 permission

nginx PHP configuration

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;
    }

The corresponding error can be found in Nginx See

in the log /var/log/nginx/error.log

The above is the detailed content of Ubuntu16.04 PHP7 installation and Nginx PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment