Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Created November 1, 2014 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseluisq/b44af8e84d1e5d63b990 to your computer and use it in GitHub Desktop.
Save joseluisq/b44af8e84d1e5d63b990 to your computer and use it in GitHub Desktop.
Installing Nginx in CentOS 7

Installing Nginx in CentOS 7

To install Nginx in CentOS 7, run the commands below to download and save its repository.

$ rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

The above commands will download and save Nginx’s repository file into the default directory at /etc/yum.repos.d/

When the repository file is downloaded, run the commands below to install Nginx.

$ yum -y install nginx

That’s it!

After installing Nginx, its default configuration file will be save in /etc/nginx/nginx.conf. This file is where you set global settings for websites on the systems.

Each website configuration will be saved in this directory: /etc/nginx/conf.d/. The default website configuration file for Nginx is at /etc/nginx/conf.d/default.conf

Now you know where these configuration files are, you can go and begin configuring your system.

Another thing to remember is that by default, http or port 80 is blocked on CentOS systems. In order to remotely access the server over http to test Nginx, you must first enable a firewall rule to allow port 80 traffic or http service.

In CentOS 7, the command to enable iptables is completely changed. To enable port 80 in CentOS 7, run the commands below.

$ firewall-cmd --permanent --zone=public --add-service=http

Finally, run the commands below to reload the firewall.

$ firewall-cmd --reload

Now go and test Nginx server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment