DEV Community

Ramu Ummadishetty
Ramu Ummadishetty

Posted on

NGINX

Installing in Debian/Ubuntu Machine

Installing from Ubuntu repository

$ sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
$ sudo apt-get install nginx
Enter fullscreen mode Exit fullscreen mode

To verify the nginx installation

$ sudo systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Uninstalling Nginx

$ sudo apt-get purge nginx nginx-common
Enter fullscreen mode Exit fullscreen mode

from Ubuntu repo we get outdated nginx version so for latest we can install from nginx repo

Installing from Official Nginx repository

$ sudo wget https://nginx.org/keys/nginx_signing.key
$ sudo apt-key add nginx_signing.key
Enter fullscreen mode Exit fullscreen mode
$ sudo vi /etc/apt/sources.list
Enter fullscreen mode Exit fullscreen mode

*Here i am using vi editor to save the changes use Esc :wq
*Add the below two lines into this sources.list
deb https://nginx.org/packages/mainline/debian/ <CODENAME> nginx
deb-src https://nginx.org/packages/mainline/debian/ <CODENAME> nginx

Here replace CODENAME with your OS CODENAME
to know CODENAME use this cmd

$ sudo cat /etc/lsb-release
Enter fullscreen mode Exit fullscreen mode

Image description

 $ sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
$ sudo apt-get install nginx
Enter fullscreen mode Exit fullscreen mode

Image description

  • To know nginx status
$ sudo systemctl status nginx

Enter fullscreen mode Exit fullscreen mode

Image description

  • using PS we can get the nginx status
$ ps -ef | grep nginx
Enter fullscreen mode Exit fullscreen mode

You will find master and worker process then its working fine

Image description

http://localhost/

  • Nginx by default runs on port 80, HTTP server

Image description

  • Start nginx
$ sudo systemctl start nginx
Enter fullscreen mode Exit fullscreen mode

Key nginx folders,files,cmds

/etc/nginx/ - default nginx configuration files located here

Image description

/etc/nginx/nginx.conf - default nginx configuration entry point used by nginx service.Contain the global settings like logs location,workers, files locations etc

Image description

/etc/nginx/conf.d - default http server configuration file,which is added in http directive of nginx.conf referred using inculde(include /etc/nginx/conf.d/*.conf;)

/var/log/nginx - store the access and error log of nginx server.
access.log - logs each request
error.log - logs error events and for debugging

$ nginx -v
$ nginx -V
$ nginx -t
$ nginx -v
$ nginx -h

Enter fullscreen mode Exit fullscreen mode

Image description

Thanks for reading

Top comments (0)