Step-by-Step Guide to Compile, Install, and Configure Nginx on CentOS 7
This tutorial walks through preparing a CentOS 7.5 host, installing required dependencies, creating an nginx user, downloading the source, compiling and installing Nginx 1.11.1, configuring the firewall, and using common Nginx commands to start, test, reload, and enable the service at boot.
Introduction
After covering basic Nginx concepts, this guide walks through compiling, installing, and configuring Nginx 1.11.1 on a CentOS 7.5 machine.
Preparation
A Linux host (CentOS 7.5).
Download the Nginx source package from the official site.
Install Dependencies
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre pcre-develVerify installation with rpm -qa.
Create Nginx User
useradd -M -s /sbin/nologin nginxDownload and Extract Source
wget http://nginx.org/download/nginx-1.11.1.tar.gz tar -xf nginx-1.11.1.tar.gz -C /usr/srcCompile and Install
# step 1: extract (already done) cd /usr/src/nginx-1.11.1/ ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx make -j 4 && make install ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/Start Nginx
Run /usr/local/nginx/sbin/nginx and open a browser at http://<em>your‑IP</em> to confirm the default page.
Firewall Configuration
If the page is not reachable, either disable the firewall or open port 80:
systemctl stop firewalld && systemctl disable firewalld firewall-cmd --add-service=http --permanent firewall-cmd --add-port=80/tcp --permanent firewall-cmd --reloadNginx Common Commands
cd /usr/local/nginx/sbin ./nginx -v # show version ./nginx -t # test configuration ./nginx # start ps -aux | grep nginx # verify process ./nginx -s reload # graceful reload ./nginx -s stop # stop echo "/usr/local/nginx/sbin/nginx &" >> /etc/rc.local # enable at bootSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
