Update the repository
yum update -y
Install the EPEL repository
yum install epel-release -y
Install dependencies from yum
yum install -y zlib zlib-devel pcre prce-devel openssl openssl-devel
Get the Nginx packages to install
cd /usr/src wget https://nginx.org/download/nginx-1.14.0.tar.gz tar xvf nginx-1.14.0.tar.gz cd nginx-1.14.0
Create user nginx
useradd -d /etc/nginx/ -s /sbin/nologin nginx
Configure
./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --with-http_realip_module
Compile and Install
make make install
Verify NginX is installed
nginx -v
Add systemd service file
vi /etc/systemd/system/nginx.service [Unit] Description=The NGINX HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/var/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t ExecStart=/usr/sbin/nginx ExecReload=/usr/sbin/nginx -s reload ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
Enable and start service
systemctl enable nginx systemctl start nginx
Check nginx is processing your request
On commandline
curl localhost
Browser
Make sure port 80 is enabled.
firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload
Findout the ip
ip addr
Load the site using the URL and it should display ‘Welcome to nginx!’ message.
http://127.0.0.1/