Its not N G I N X. nginx is pronounced as “Engine X”.
nginx is an open source web server that is similar to Apache, but very light weight. nginx is both web server and reverse proxy server.
The following are some of the features of nginx:
- It serves static and index files
- Reverse proxy with caching
- Supports SSL
- Simple load balancing with fault tolerance
- Both name-based and ip-based virtual server can be configured
- HTTP basic authentication
- Supports rewrite module
- Supports gzip, XSLT, SSI and image resizing filters
- All the main mail proxy server features are supported
- and lot more..
1. Download nginx
Download nginx from here, or use wget as shown below. The current stable version is nginx 1.9.5cd /usr/src/
wget http://nginx.org/download/nginx-1.9.5.tar.gz
tar xvfz nginx-1.9.5.tar.gz
cd nginx-1.9.5
2. Install nginx
CentOS#yum install make gcc pcre-devel zlib-devel openssl-devel git bison wget
Ubuntu
#sudo apt-get install gcc libpcre++-dev libssl-dev make gitThere are lot of options that you can pass to ./configure. To identify list of all the configuration options do the following.
./configure --help
Download the required expansion nginx source
mkdir -p /home/git/code cd /home/git/code git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module git clone https://github.com/agentzh/sregex git clone https://github.com/agentzh/replace-filter-nginx-module
Install sregex
cd /home/git/code/sregex make make install
Compile nginx
#cd /usr/src/
#tar xzvf nginx-1.9.5.tar.gz
#cd nginx-1.9.5
#
./configure \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_sub_module \ --with-http_gzip_static_module \ --with-ipv6 \ --add-module=/home/git/code/ngx_http_substitutions_filter_module \ --add-module=/home/git/code/replace-filter-nginx-module
make make install
now we need to ln file to directory:
+centos 32bit
ln -s /usr/local/lib/libsregex.so.0 /lib
+centos 64bit
ln -s /usr/local/lib/libsregex.so.0 /lib64
Start Nginx Server
#/usr/local/nginx/sbin/nginx
Check version of nginx:
#/usr/local/nginx/sbin/nginx -v
check nginx port status
#netstat -tapn | grep nginx
if you want to stop nginx use this:
# /usr/local/nginx/sbin/nginx -s stop
Testing nginx with PHP info file
#vim /usr/local/nginx/html/phpinfo.php
past this php code
<?php phpinfo(); ?>-open web browser:
http://server-ip/phpinfo.php
To debug issues, view the error.log and access.log files located under /usr/local/nginx/logs
ls /usr/local/nginx/logs/ access.log error.log
Add nginx auto start when reboot
#vim /etc/rc.local
add this:
/usr/local/nginx/sbin/nginx
save and exit
=============================
reference:
-http://www.thegeekstuff.com/2011/07/install-nginx-from-source/
-http://www.cnblogs.com/firadio/p/4111823.html