Install and configure PHP + NGINX for Ubuntu 18.04

How to install and configuration NGINX with PHP.

It’s really simple.

Install NGINX and php-fpm

apt install nginx php-fpm

Then add this configuration to the NGINX site with which you want to enable PHP.

 location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

 

This configuration will usually be added in /etc/nginx/sites-enabled/default

or the global configuration in /etc/nginx/nginx.conf

 

References:
https://devanswers.co/installing-php-nginx-ubuntu-18-04/
https://linuxize.com/post/how-to-install-php-on-ubuntu-18-04/

 

php5 nginx xdebug


$ sudo apt-get install php5-dev php-pear
$ sudo pecl install xdebug

Open file /etc/php5/fpm/php.ini 

$ sudo nano /etc/php5/fpm/php.ini

 add the following line to the “Dynamic Extensions” section:

[xdebug]
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_port=9000
xdebug.remote_enable=On
xdebug.remote_connect_back=On
xdebug.remote_log=/var/log/xdebug.log

Restart PHP:

$ sudo service php5-fpm restart 

 

http://blog.shahariaazam.com/enable-xdebug-in-nginx/#.VKY8wGZdksk

http://www.bravo-kernel.com/2014/09/how-to-set-up-xdebug-for-php5-fpm-on-ubuntu/