So here you go. We are going to use Ubuntu and Nginx
Install the Software
sudo apt-get update
sudo apt-get install mysql-server php5-mysql nginx php5-fpm
File Structure
mkdir /var/www/html/domain1
mkdir /var/www/html/domain2
Nginx Configuration
Domain1
sudo nano /etc/nginx/sites-available/domain1
Copy and paste this
server {
listen 80;
root /var/www/html/domain1;
index index.php index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ /index.html;
}
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
save it
Domain2
sudo nano /etc/nginx/sites-available/domain2
server {
listen 80;
root /var/www/html/domain2;
index index.php index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ /index.html;
}
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
save it
The last Step
sudo ln -s /etc/nginx/sites-available/domain1 /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/domain2 /etc/nginx/sites-enabled/
Why Nginx ?
- It is much faster
- Easy to manage
PS: If it works click that hearth to show me some love
Instead of spending time on learning about servers you could try ServerPilot which installs with a single command and lets you manage websites from a web interface.
Thanks jesin! Checked it out, saw a couple videos. Seems incredibly intuitive, fast and organised. Will definitely give it a shot. :)