Nginx is a well-known software that acts as both a web server and a proxy. Right now, the market has very few of them who have both these capabilities. So yes, it works as a web server in which you serve web content like HTML, CSS, javascript, etc and along with that the power of proxy adds more advantages to it. Advantages like Load Balancing, Reverse Proxy, Forward Proxy, Caching, and much more. Through this blog post, the Oodles AI team presents a comprehensive guide to install NGINX from source that brings benefits of variety and choice.
As providers of artificial intelligence services, we at Oodles employ NGINX to build and deploy dynamic machine learning applications including prediction, classification, and more.
In the IT industry, not every business uses the traditional way of software installation in the server (Linux) viz package installation using a command like apt-get or yum.
So what they do? As we know software like Nginx is open-source so anyone can get its source code. So we use that source code, compile them and then install the software in the system and this is called “source installation”. But after compilation of this type of installation, we did not get the directory structure as we get with the traditional installation (by apt-get or yum). This might be slightly confusing for those who used to install via “yum” or “apt-get”.
Here are simple steps in source installation that can be used to provide you the same familiar Nginx directory structure as we get in a traditional installation.
$ sudo apt update
$ sudo apt install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev php-fpm
$ wget https://nginx.org/download/nginx-1.16.1.tar.gz
$ tar xvf nginx-1.16.1.tar.gz
$ cd nginx-1.16.1/
$ ./configure --prefix=/etc/nginx
$ sudo make
$ sudo make install
$ sudo nano /lib/systemd/system/nginx.service
[Unit]
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network.target
[Service]
Type=forking
PIDFile=/etc/nginx/logs/nginx.pid
ExecStartPre=/etc/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/etc/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/etc/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
$ sudo systemctl start nginx
Now after all these setups, if you try to look the Nginx directory in /etc/nginx then it will not look as familiar as you expected. The main reason is that you don’t have those three directories that used most i.e “conf.d”, “sites-available” and “sites-enabled”.
$ sudo mkdir /etc/nginx/sites-available /etc/nginx/sites-enabled /etc/nginx/conf.d
$ sudo nano /etc/nginx/conf/nginx.conf
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
$ sudo systemctl enabl
Once installed, NGINX is a great proxy tool for building multiple web apps encompassing machine learning, predictive analytics, and computer vision services.