Enable Nginx’s Repository And Install Nginx In CentOS 7

This brief tutorial is going to show you how to enable Nginx’s repository and installera Nginx i CentOS version 7. If you’re reading this, then you probably no a thing or two about Nginx.

För dem som inte vet, Nginx is a webbserver that’s fast and lightweight when compared to Apache, the most popular web servers there is.

Without saying much about why choose Nginx or how it’s better than Apache, I am going to only show you how to installera it in CentOS 7. If you want to know why many webmasters are choosing Nginx over Apache, then i suggest to Sök and read online articles written by those who have tested both servers.

The reason Nginx isn’t as simple as Apache to install in CentOS unknown to me as well. For Apache, all one has to do is run the command, <koden>yum -y install httpdcode> to install Apache.

Not Nginx. Till install Nginx, you must first enable the correct repository before you can install it. This brief tutorial is going to show you how to do it.

  • 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 Katalog/etc/yum.repos.d/

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

yum -y install nginx

Det är det!

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 webbplats configuration will be saved in this Katalog: /etc/nginx/conf.d/. The default webbplats 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 systemet.

Another thing to remember is that by default, http eller hamn 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.

I 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

Slutligen, run the commands below to reload the firewall.

firewall-cmd --reload

Now go and test Nginx server.

Install Nginx in Centos 7

You test should show the above Sidan. If you don’t see it, then there’s something wrong, check your steps above.

If you installed CentOS 7 minsta, there are some basic configuration tools that are left out or not installed by default, Till exempel, ipconfig command won’t be installed.

To check your IP-adress, use the commands below.

ip addr

To enable the ipconfig command, install the net-tools package.

yum install net-tools


Lämna svar