Skip to main content

Nginx

Install

  • Prerequisited
apt-get install libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
  • Download

Download Nginx from the official Download Page.

  • Build
./configure \
--sbin-path=/usr/bin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-pcre \
--pid-path=/var/run/nginx.pid \
--with-http_ssl_module
make -j

Startup on boot

Save the following to /lib/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.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

See also here

Start it with

systemctl start nginx

Check if it is running with

ps aux | grep nginx

or

systemctl status nginx

To enable startup on boot

systemctl enable nginx