NginX Configuration HowTo

How To Set Up nginx Virtual Hosts 

1) Install the following pagkage
sudo apt-get install nginx

2) Create New Directory and grant permissions

sudo mkdir -p /var/www/
sudo chown -R www-data:www-data /var/www/
sudo chmod 755 /var/www
3) create an index page
sudo nano /var/www/
    <h1>Test Page</h1>
4) Create virtual host
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/
 sudo nano /etc/nginx/sites-available/
5 ) We need to make a couple of changes in these few lines:
 server {
        listen   80;
        root /var/www/;
        index index.html index.htm;

  • sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/xyz.comsudo 
6) Restart the service
sudo service nginx restart

7) create host lookup

vim /etc/hosts 
#Virtual Hosts 

No comments:

Post a Comment