Install nginx
sudo apt-get install nginxConfigure nginx
sudo nano /etc/nginx/sites-available/exampleMake the file as bellows:
server {
    listen   80;
    root /var/www/example.com/public_html;
    index index.php index.html index.htm;
    server_name example.com www.example.com; 
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~[^?]*/$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080;
    }
    location ~ \.php$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080;
    }
    location ~ /\.ht {
        deny all;
    }
}Activate the virtual host.
sudo ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/exampleand delete the default one.
sudo rm /etc/nginx/sites-enabled/defaultInstall Apache
sudo apt-get install apache2Configure Apache
sudo nano /etc/apache2/ports.confFind and replace the port 80 to 8080 like bellow:
NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080Create apache virtual host.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.conf
sudo nano /etc/apache2/sites-available/example.confChange the port 80 to 8080 including the IP address like bellow:
<VirtualHost 127.0.0.1:8080>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/var/www/html">
        AllowOverride ALL
    </Directory>
</VirtualHost>Activate the virtual host’s site.
sudo a2ensite exampleNow Install the php.
sudo apt-get install php
sudo apt-get install libapache2-mod-phpRestart both servers.
sudo service apache2 restart
sudo service nginx restartCongratulations you’re done.
Configure X-Debug:
sudo apt-get install php-xdebugadd these lines at the end of the file /etc/php/7.1/apache2/php.ini
# Added for xdebug
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.max_nesting_level=300Turn on error reporting
sudo nano /etc/php/7.1/apache2/php.iniInstall MySQL
sudo apt-get install mysql-server php-mysql
sudo mysql_install_db
sudo mysql_secure_installationInstall phpMyAdmin
sudo apt-get update
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html
sudo service apache2 restart
sudo service nginx restart