Install NGINX on CentOS

29/12/2020
In the case of any web server, the performance is something that you need to keep in mind. In fact, performance is the main factor that decides the success of running a server. The faster the server, the better performance you get out of your current hardware config.

There are a number of available server apps out there. The most popular ones include Apache and NGINX. Both of them are free and open-source. Of course, in terms of popularity, Apache is a quite popular choice even in the world. In fact, more than 65% of all the servers in the current cyber world is powered by Apache!

However, that doesn’t diminish the benefits of NGINX (engine-ex – that’s how it’s pronounced). There are tons of additional benefits that NGINX provide that Apache fails to serve.

The first and foremost reason is the performance. NGINX, being a lightweight alternative to Apache, offers better overall performance than Apache. NGINX is also well-suited with the Linux and other UNIX-like environment. However, NGINX falls short in terms of flexibility. You need to compile additional modules into the NGINX binary in most cases as not all the modules of NGINX support dynamic module loading.

As both of them are free, you can easily start your own server right now! In today’s tutorial, we’ll be checking out NGINX running on my test CentOS system.

Installing NGINX

NGINX is available on the EPEL repository. Let’s start the installation!

At first, make sure that your system has EPEL repository enabled –

sudo yum install epel-release

sudo yum update

Now, time to perform the installation!!!

sudo yum install nginx

Starting NGINX

The installation is complete, time to fire it up! It’s not going to start itself all by itself!

sudo systemctl start nginx

If your system is configured to use a firewall, enable HTTP and HTTPS traffic from/to the server –

sudo firewall-cmd –permanent –zone=public –add-service=http
sudo firewall-cmd –permanent –zone=public –add-service=https
sudo firewall-cmd –reload

Time to test the server working –

http://<server_domain_IP>

Don’t have the IP address of the server? Then you can find out by running the following command –

ip addr

In my case, I need the “enp0s3” connection. Now, find out the IP address by running the following command –

ip addr show enp0s3 | grep inet | awk ‘{ print $2; }’ | sed ‘s//.*$//’

You may also want to enable NGINX every time your system boots up –

sudo systemctl enable nginx

Additional configurations

The default configuration isn’t always the best one as it depends on the particular usage case. Fortunately, NGINX comes up with a handy set of configuration files.

  • NGINX global configuration file
    /etc/nginx/nginx.conf
  • Default server root
    /usr/share/nginx/html
  • Server block configuration
    /etc/nginx/conf.d/*.conf

Enjoy!

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Install, And Configure a Nginx Server For the First Time

Nginx is one of the popular web servers, and is used as a proxy server, reverse proxy server, load balancer. It’s a popular...
29/12/2020

How to Install Free SSL Certificate for Nginx on Debian 10

TLS and SSL protocols cipher the connection between a site (or other service, but in this tutorial Nginx is the focus)...
29/12/2020

Nginx Reverse Proxy

What is a reverse proxy? A proxy server is the one that talks to the Internet on your behalf. For example, if your college’s...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024