Install nginx in Centos 7

This guide will help you how to install nginx web server with Centos 7 Linux distro. Please keep in mind that Centos 7 will reach EOL (End of Life) in June 30th, 2024. If you wish to continue using Centos 7 please use it for simple application only.

yum update
yum install epel-release -y

By default nginx from epel-release will install version 1.20 which is already EOL as well. However, for some people that only use nginx for reverse proxy or for file server, this should be no issue.

Now we edit as our needs.

vi /etc/nginx/nginx.conf

Then change port 80 to another ports that available. For example :

Then change to another port that we had, for example 40101. So it will become :

Now save it. Check if the configuration of nginx already correct.

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If everything OK, then restart it.

systemctl restart nginx

Open within your web browser http://x.x.x.x:4101/ and you should see your default nginx web browser within your web browser. Please keep in mind, the default document root is /usr/share/nginx/html so you need to go to that directory and change your default index page.

Leave a Reply 0

Your email address will not be published. Required fields are marked *