0%

Installing nginx from source on Ubuntu 14.04

These installation steps are just for my reference. Visit INSTALLING NGINX OPEN SOURCE if you need a more detailed installation guide.

sudo apt-get update
sudo apt-get install build-essential

Next, go to nginx source releases and find the download link.
In my case it is http://nginx.org/download/nginx-1.10.1.tar.gz?_ga=1.4610931.1556411009.1493370198. Download it with wget:

wget http://nginx.org/download/nginx-1.10.1.tar.gz?_ga=1.4610931.1556411009.1493370198

Extract the downloaded file:

tar -zxvf nginx-1.10.1.tar.gz?_ga=1.4610931.1556411009.1493370198

Switch to nginx’s directory.

cd nginx-1.10.1/

Install libraries for nginx:

sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

The PCRE (libpcre3, libpcre3-dev, and libpcrecpp0 ) library provides support for regular expression.

The zlib library is used for headers compression.

The OpenSSL library is used for supporting HTTPS protocol.

Configure the modules you want to install with Installation and Compile-Time Options

./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-debug --with-pcre --with-http_ssl_module 
make
sudo make install

For installing nginx as a service, I use initScript from https://raw.githubusercontent.com/JasonGiedymin/nginx-init-ubuntu/master/nginx

wget https://raw.githubusercontent.com/JasonGiedymin/nginx-init-ubuntu/master/nginx
mv nginx /etc/init.d/nginx
chmod +x nginx
update-rc.d -f nginx defaults

If I exeucte service nginx status now, I would get /etc/init.d/nginx: You don't have permissions to execute nginx..

This is because I made some custom configurations when installing nginx.

According to the Advanced Configuration, I should edit DAEMON and NGINX_CONF_FILE in /etc/default/nginx

echo "NGINX_CONF_FILE=/etc/nginx/nginx.conf" > /etc/default/nginx
echo "DAEMON=/usr/bin/nginx" >> /etc/default/nginx