Nginx

NGINX is a free, open-source, high-performance HTTP server, reverse proxy, and IMAP/POP3 proxy server.

Installation of Nginx server

In order to have the latest updates, we update the the package lists before installing any package:

$ sudo apt-get update

We then install Nginx with

$ sudo apt-get install nginx

To check if Nginx is properly installed and running, we can check for its process in command line

$ ps -aux | grep nginx

The output will be like

root     22078  0.0  0.1 180536  1476 ?        Ss   Nov23   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 22086  0.0  0.4 181468  4100 ?        S    Nov23   0:00 nginx: worker process
ubuntu   31904  0.0  0.0  12944   908 pts/0    S+   00:51   0:00 grep --color=auto nginx

Configure a virtual host for the server (with domain name task.woezzon.com )

To serve our website with task.woezzon.com, we create virtual host conf file in /etc/nginx/sites-enabled/task.woezzon.com.conf

$ cd /etc/nginx/sites-enabled/
$ sudo nano task.woezzon.com.conf 

with the content

server {
		listen 80;
		listen [::]:80;
		
		server_name www.task.woezzon.com task.woezzon.com;
		
		root /var/www/html;
		index index.html index.htm index.nginx-debian.html;

		location / {
			try_files $uri $uri/ =404;
		}
}

After that, we restart Nginx with

$ sudo /etc/init.d/nginx restart

In a browser, http://task.woezzon.com will point to the default Nginx web page.

Last updated

Was this helpful?