If you do PHP development, moving to a PHP IDE is extremely beneficial especially when debugging. PHPStorm is a great IDE for PHP development and has tons of support for various frameworks and from the community. In this post, I will walk through the steps to setup and configure a PHP development environment on Ubuntu using Percona MySQL, Nginx, PHP 7, XDebug, and PHPStorm.

To get started we need to add the repos for our software.

Add the repo for NGINX stable from

sudo apt-key add nginx_signing.key
sudo add-apt-repository "deb $(lsb_release -sc) nginx"
rm nginx_signing.key

Add repo for Percona Server for MySQL 5.7 from I recommend Percona over stock MySQL and over MariaDB due to better performance and stability, (more on this in an upcoming blog post).

wget$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
rm percona-release_0.1-4.$(lsb_release -sc)_all.deb

Install the packages. You may also want to include any other PHP extensions you might need.

sudo apt update 
sudo apt install git nginx hhvm percona-server-server-5.7 php7.0-fpm php7.0-cli php7.0-xdebug php7.0-curl

We will also install Composer to easily add packages to our PHP apps.

curl -sS | php

Move composer to bin.

sudo mv composer.phar /usr/local/bin/composer

Now is the time to install PHPStorm from the JetBrains website.

With the essentials installed, it’s time to configure it.

sudo mkdir -p /var/www/dev/public/
nano /etc/nginx/conf.d/default.conf
server {

root /var/www/dev/public;
index index.php;

server_name localhost;

location ~ \.(php)$ {
    fastcgi_keep_conn on;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;

client_max_body_size 2M;

location / {
try_files $uri $uri/ /index.php$is_args$args;
sudo service nginx restart

Time to enable XDebug for our PHP server. (NOTE: Do not do this on a production server.) To enable this for the CLI, make the same file inside

sudo nano /etc/php/7.0/fpm/conf.d/20-xdebug.ini

We are now ready to setup PHPStorm. Open up the IDE, and add your /var/www/dev/ directory as your project folder. Out of the box, PHPStorm’s debugger attached for me, but if you are having issues, try the PHPStorm docs or leave a comment. =)

You now should have a full PHP development environment, time to get cracking on that app!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.