I was super excited about PHP 7.0 and started using it as soon it was getting some shape. But I also faced some problem while I was configuring PHP 7.0 with Nginx. I was trying to configure virtual hosts in Nginx. I need to change the following blog things

Prerequisites

I am assuming that you are running PHP 7.x on an Ubuntu 14.04 machine, Also have PHP-FPM in conjunction with Nginx. I also assume that you have a non-root user configured with sudo privileges for administrative tasks.

Let's Configure

I was trying to configure virtual hosts in Nginx. I need to change the following things:

File: /etc/nginx/sites-enabled/nmrony.local

server {  
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /media/nmrony/devzone/www;
    index index.php index.html index.htm;

    server_name nmrony.local;

    location / {
        try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}

Please note the PHP FPM socket path

Configuring PHP-FPM

File: /etc/php/7.0/fpm/php.ini

Add or find and replace the following line. Please remove semicolon(;) before it.

cgi.fix_pathinfo=0;  


If you want to run PHP-FPM with different user (As I wanted to change) you need to change the following line in the file below (Nowhere i found this)

File: /etc/php/7.0/fpm/pool.d/www.conf

Find and replace the following lines

;line number 23 and 24 for me
user = <your-user>  
group = <your-group>  
....
....
;line number 47 and 48 for me
listen.owner = nmrony ;should be your user  
listen.group = nmrony ;should be your group  

Restart php-fpm service.

Everything should work fine. If you find any problem in this post please let me know. I am all ears.

© 2016. All Rights Reserved.

Proudly published with Ghost