Installing in Debian/Ubuntu Machine
Installing from Ubuntu repository
$ sudo apt-get update
$ sudo apt-get install nginx
To verify the nginx installation
$ sudo systemctl status nginx
Uninstalling Nginx
$ sudo apt-get purge nginx nginx-common
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
$ sudo vi /etc/apt/sources.list
*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
$ sudo apt-get update
$ sudo apt-get install nginx
- To know nginx status
$ sudo systemctl status nginx
- using PS we can get the nginx status
$ ps -ef | grep nginx
You will find master and worker process then its working fine
http://localhost/
- Nginx by default runs on port 80, HTTP server
- Start nginx
$ sudo systemctl start nginx
Key nginx folders,files,cmds
/etc/nginx/
- default nginx configuration files located here
/etc/nginx/nginx.conf
- default nginx configuration entry point used by nginx service.Contain the global settings like logs location,workers, files locations etc
/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
Thanks for reading
Top comments (0)