Skip to content

ConceptΒΆ

Install nginx via package managerΒΆ

DebianΒΆ

sudo apt install nginx

RedhatΒΆ

sudo yum install nginx

Build From SourceΒΆ

Download Nginx source code from this page then extract tar file, like this

./configure nginx with this parameters:
--sbin-path=/usr/bin/nginx nginx executable binary file path
--conf-path=/etc/nginx/nginx.conf nginx configuration file path
--error-log-path=/var/log/nginx/error.log nginx error log path
---http-log-path=/var/log/nginx/access.log nginx access log path
---with-pcre regex module for nginx
--pid-path=/var/run/nginx.pid nginx running process location
--with-http_ssl_module nginx 3rd party module
make
make install

Save this file as /lib/systemd/system/nginx.service to create systemctl unit

[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

get more help

Nginx Official SiteΒΆ

Check Nginx Config FileΒΆ

nginx -t (test all nginx config files)
nginx -c /etc/nginx/nginx.conf -t (test nginx.conf)

Documentation & ReferenceΒΆ

Nginx GEO IPΒΆ

Build GEO IP From SourceΒΆ

add `--with-http_geoip_module` to configure
fix error dependency with `apt install libgeoip-dev`
make
make install

download GeoIP and GeoLiteCity package from maxmind

Video StreamingΒΆ

Build from SourceΒΆ

add `--with-http_mp4_module` to configure
make
make install
worker_processes auto;

events {
  worker_connections 1024;
}

http {

  include mime.types;

  server {
    listen 80;

    location ~\.mp4$ {
      root /tmp/videos/;
      mp4;
      mp4_buffer_size 512K;
      mp4_max_buffer_size 10M;
    }

  }
}