Install Nginx
Yum
Option1. use yum repo:
sudo yum install nginx -y
Option2. use URL:
sudo yum install https://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.19.2-1.el7.ngx.x86_64.rpm -y
released date: 11/08/2020
Option3. Binary Install
Download
https://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.19.2-1.el7.ngx.x86_64.rpm
Save in Linux using Open FTP
Install using yum
sudo yum install /home/ec2-user/ginx-1.19.2-1.el7.ngx.x86_64.rpm -y
AWS
sudo amazon-linux-extras install nginx1.12
Docker
Pull & Run container
docker run --name nginx -p 80:80 -d nginx
Image Pull
docker pull nginx:latest
required install docker
Reference:
Start Nginx
Start Nginx on Linux
Nginx does not start on its own. To get Nginx running, type:
sudo systemctl start nginx
Start Nginx docker container
docker run --restart="always" -d --name nginx \ -p 80:80 -p 443:443 \ -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf \ -v /var/log/nginx:/var/log/nginx \ -v /etc/nginx/conf.d/:/etc/nginx/conf.d/ \ nginx:latest
-v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf
: synchronise with actual nginx.conf path-v /var/log/nginx:/var/log/nginx/
: synchronise with actual nginx log path-v /etc/nginx/conf.d/:/etc/nginx/conf.d/
: synchronise with actual conf.d folder path to set sub domain
Restart
sudo systemctl restart nginx
Background Start Nginx when your system boots
Before continuing, you will probably want to enable Nginx to start when your system boots. To do so, enter the following command:
sudo systemctl enable nginx