Install Nginx on CentOS 7
Install Nginx on CentOS 7
Table of Contents
Introduction
Nginx is a popular light-weight and high performance web server and commonly used as a proxy. It is quite flexible and a good alternative to Apache.
Requirements
- CentOS 7 or Red Hat Enterprise Linux 7
- Local Linux and ProfitBricks firewall ports need to be opened for external requests
Install Nginx
Many distributions include Nginx as part of the default distribution repository. However, this version can become outdated and it is recommended installing from a repository containing the latest version.
One common repository added to CentOS and Red Hat Enterprise Linux (RHEL) servers is the Extra Packages for Enterprise Linux (EPEL). The following command will add the EPEL repository to CentOS 7 or RHEL 7.
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
Optionally, the Nginx project also maintains a repository containing the latest Nginx build. To add the Nginx repository to CentOS 7 and RHEL 7.
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Note: The above mentioned repositories are also available for 32-bit (i386/i686) versions of Nginx. However, it is highly recommend 64-bit versions be used for production server deployments.
Nginx can now be installed using yum.
sudo yum -y install nginx
Start Nginx
Once Nginx has been installed, the service should be set to start on system boot.
sudo systemctl enable nginx
Now Nginx is ready to start.
sudo systemctl start nginx
You can verify the process has been started using curl to perform an HTTP request.
curl -i http://localhost/
CentOS 7 has a local firewall enabled by default. Proper TCP ports may need to be opened to allow external requests. This will usually be port 80 for normal HTTP traffic.
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
Ports will also need to be opened
Comments
Post a Comment