How to install Nginx on CentOS7

Kevin W Tech Notes
1 min readFeb 12, 2021

--

Add the epel repo

[root@ip-172-31-52-63 centos]# sudo yum install epel-release -y

Install nginx

[root@ip-172-31-52-63 centos]# sudo yum install nginx -y

Enable service

[root@ip-172-31-52-63 centos]# sudo systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@ip-172-31-52-63 centos]# sudo systemctl start nginx
[root@ip-172-31-52-63 centos]# sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-02-02 21:46:49 UTC; 3s ago
Process: 21100 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 21097 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 21096 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 21102 (nginx)
CGroup: /system.slice/nginx.service
├─21102 nginx: master process /usr/sbin/nginx
└─21103 nginx: worker process
Feb 02 21:46:49 ip-172-31-52-63.ec2.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Feb 02 21:46:49 ip-172-31-52-63.ec2.internal nginx[21097]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Feb 02 21:46:49 ip-172-31-52-63.ec2.internal nginx[21097]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Feb 02 21:46:49 ip-172-31-52-63.ec2.internal systemd[1]: Failed to parse PID from file /run/nginx.pid: Invalid argument
Feb 02 21:46:49 ip-172-31-52-63.ec2.internal systemd[1]: Started The nginx HTTP and reverse proxy server.

Default index.html page

[root@ip-172-31-52-63 centos]# vim /usr/share/nginx/html/index.html

--

--

No responses yet