sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/nginx
sudo apt-get install nginx
sudo apt-get install mysql-server
sudo apt install php7.1 php7.1-bcmath php7.1-bz2 php7.1-cli php7.1-common php7.1-curl php7.1-fpm php7.1-gd php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-pspell php7.1-soap php7.1-tidy php7.1-xml php7.1-xmlrpc php7.1-xsl php7.1-zip
sudo service php7.1-fpm restart
sudo service nginx restart
sudo apt-get update
sudo apt-get install phpmyadmin
When asked to choose between apache and lighttpd choose none and simply press TAB key to go forward.
The next prompt will ask if you would like dbconfig-common to configure a database for phpmyadmin to use. Select "Yes" to continue.
The next prompt shall ask you the password, provide the MySQL root password.
i) Keep a backup of the existing www.conf file
sudo mv /etc/php/7.1/fpm/pool.d/www.conf{,.bak}
sudo nano /etc/php/7.1/fpm/pool.d/site1.localhost.com.conf
[site1.localhost.com]
user = www-data
group = www-data
listen = /run/site1.localhost.com-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.process_idle_timeout = 30s
pm.max_requests = 512
pm.max_children = 30
Create proper directory structure and log files
sudo mkdir /var/www/site1.localhost.com/
sudo mkdir /var/www/site1.localhost.com/files
sudo mkdir /var/www/site1.localhost.com/log
sudo touch /var/www/site1.localhost.com/log/access.log
sudo touch /var/www/site1.localhost.com/log/error.log
sudo touch /var/www/site1.localhost.com/files/index.php
sudo nano /etc/nginx/sites-available/site1.localhost.com
Put the following in the file
server {
listen 80;
server_name site1.localhost.com;
root /var/www/site1.localhost.com/files;
index index.php index.html index.htm;
access_log /var/www/site1.localhost.com/log/access.log;
error_log /var/www/site1.localhost.com/log/error.log notice;
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_read_timeout 300;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass unix:/run/site1.localhost.com-fpm.sock;
}
}
sudo ln -s /etc/nginx/sites-available/site1.localhost.com /etc/nginx/sites-enabled/
sudo ln -s /usr/share/phpmyadmin/ /var/www/site1.localhost.com/files
sudo nano /etc/hosts
Add the new virtual host below localhost with same address
127.0.0.1 localhost
127.0.0.1 site1.localhost.com
sudo service php7.1-fpm restart
sudo service nginx restart