install nginx from source

From WebHostingNeeds.com
Jump to: navigation, search


Install Requirements

CentOS/RHEL/Fedora

yum install glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel

Ubuntu/Debian

apt-get install libpcre3-dev


Create User

/usr/sbin/useradd -c "Nginx user" -s /bin/false -r -d /var/lib/nginx nginx


Install

Now download and install nginx

Download latest stable version from

http://nginx.org/en/download.html

cd /usr/local/src
wget http://nginx.org/download/nginx-1.9.12.tar.gz
tar -zxvf nginx-1.9.12.tar.gz
cd nginx-*
./configure \
    --user=nginx \
    --group=nginx \
    --prefix=/usr/share \
    --sbin-path=/usr/sbin/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --pid-path=/var/log/run/nginx.pid \
    --lock-path=/var/log/lock/subsys/nginx \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_gzip_static_module \
    --with-http_stub_status_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_secure_link_module 
make
make install


Test Nginx

To start nginx run

/usr/sbin/nginx

Configuration file is at

/etc/nginx/nginx.conf


echo "NGINX_CONF_FILE=/etc/nginx/nginx.conf" > /etc/sysconfig/nginx

Init Script

See nginx init script for centos



nginx