How to Compile and Deploy Nginx from Source on Linux
This guide walks through downloading the Nginx source package, extracting it, compiling and installing it to a custom directory, configuring a systemd service unit, and finally starting and verifying the server on a Linux system.
Experiment: compile and install Nginx from source.
cd /opt
wget http://nginx.org/download/nginx-1.18.0.tar.gz # download the package to /opttar xf nginx-1.18.0.tar.gz # extract the archiveAfter extraction, create the installation directory and copy files:
mkdir -p /apps/nginx
# copy binaries and configuration files to /apps/nginx
# make symbolic links as neededCreate a systemd service unit for Nginx:
[Unit]
Description=The nginx HTTP and reverse proxy server
[Service]
PIDFile=/apps/nginx/logs/nginx.pid # specify PID file for management
ExecStart=/apps/nginx/sbin/nginx # start Nginx using absolute path
ExecStop=/usr/bin/kill -s TERM $MAINPID # stop the process
ExecReload=/apps/nginx/sbin/nginx -s reload # reload configuration
[Install]
WantedBy=multi-user.targetReload systemd, start Nginx, and check its status:
systemctl daemon-reload # inform systemd of the new unit file
systemctl start nginx # start Nginx
systemctl status nginx # verify that Nginx is runningFor further configuration, edit the Nginx configuration files under /apps/nginx/conf as needed.
Source: https://www.cnblogs.com/chenjw0608/p/17813477.html (© original author)
Signed-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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
