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




Essential Articles on Remote PHP Debugging with PHPStorm and Xdebug



Enable remote xdebug in php.ini 

you will add a line in php.ini


Test your connection, if it doesn’t work with localhost, try you local network IP address as it depends to which network adapter PHPStorm is using for the debugging purposes.


Mac-Pro:~ mac$ telnet localhost 9000

Trying ::1…

telnet: connect to address ::1: Connection refused


Connected to localhost.

Escape character is ‘^]’.


telnet> exit

?Invalid command

telnet> quit

Connection closed.

Mac-Pro:~ mac$ telnet 9000


Connected to

Escape character is ‘^]’.

PHP Broken Pipe (mod_fcgid: ap_pass_brigade failed in handle_request_ipc function)


 If you get this error with VirtualMin.

This is a PHP-FCGI limit error you’re receiving. You’ll need to adjust either the “PHP_FCGI_MAX_REQUESTS” variable inside the “/home/user/fcgi-bin/php5.fcgi” file for the domain or “FcgidMaxRequestsPerProcess” variable inside the Apache config file.

You can read more about this topic at:




Fix php-mcrypt bug in Ubuntu 14.04


This one liner will fix your php-mcrypt, the last command tests to ensure mcrypt is properly installed.

sudo ln -sf /etc/php5/conf.d/mcrypt.ini && sudo php5enmod mcrypt && sudo service apache2 restart && php -m | grep mcrypt 




This does solve it:

Check if mcrypt is not enabled:

root@prod:/etc/php5/mods-available# php -m | grep mcrypt

Symlinks to the wrong mcrypt.ini as a workaround:

root@prod:/etc/php5/mods-available# ln -sf /etc/php5/conf.d/mcrypt.ini .

Enabled the mcrypt mod:

root@prod:/etc/php5/mods-available# php5enmod mcrypt

Check if it was enabled:

root@prod:/etc/php5/mods-available# php -m | grep mcrypt

Restart services:

root@prod:/etc/php5/mods-available# service apache2 restart

php -m | grep mcrypt


Adding SSH2 to MAMP and MAMP PRO on Yosemite the easy way


You will require autoconf.

Install via the above instructions will work. Also, using Homebrew will work.

Cannot find autoconf. Please check your autoconf installation and the

$PHP_AUTOCONF environment variable. Then, rerun this script.

Download the php version that matches the one you will be using with MAMP Pro.

Copy the extracted files to MAMP php folder in /Applications/MAMP/bin/php/php5.5.18/include/php

Do not copy the subfolder created by the extraction, only copy the contents of that folder. You may have to create the ‘include/php/‘ folders as they might not already exist.

Also, do change the PHP version number to match the one you’re using.

./configure --without-iconv

Adding SSH2 extension to your MAMP the sure way

  1. Download libssh2 from source forge, direct link here
  2. Then extract the package, configure, compile and install it.
    user:compile$ tar -xf libssh2-1.2.1.tar
    user:compile$ cd libssh2-1.2.1
    user:libssh2-1.2.1$ ./configure
    user:libssh2-1.2.1$ make
    user:libssh2-1.2.1$ sudo make install
  3. Download SSH2 PECL source code, get the latest stable version.
  4. Then untar and compile it.
    user:compile$ tar -xf ssh2-0.12.0.tar
    user:compile$ cd ssh2-0.12.0
    user:ssh2-0.12.0$ phpize
    If you don’t have have autoconf installed this is where you will get an error. Cannot find autoconf. Otherwise, proceed.
    user:ssh2-0.11.0$ ./configure
    If you get this error

    /Applications/MAMP/bin/php/php5.5.18/include/php/Zend/zend.h:51:11: fatal error: ‘zend_config.h’

          file not found

    This is probably because you did not compile the PHP you downloaded.
    user:ssh2-0.11.0$ make
  5. Look in
    ssh2-0.12.0/modules/ to find
    Copy this file to your MAMP location.
  6. Chmod 755 the location of your file.
  7. Edit templates in MAMP Pro, File->Edit Template->PHP-> Choose the PHP version you have compiled with.
  8. Add the line , in the [extensions] section
  9. Save changes
  10. Restart MAMP Pro
  11. Check phpinfo()
  12. Try it out

2015 03 01 11 47 08 PM 

If you are using Linux, such as Debian, Ubuntu you can install XAMPP for Linux. Compile ssh2 using the same instructions, update the php.ini file the same way.