1. Installation Instructions:
System Environment: CentOS-4.0
2. Dependent procedures
(1). Gzip module requires zlib library
(2). Rewrite module requires Pcre library
(3). SSL support requires OpenSSL library
3. There are two ways to install a dependency program: one is to download the package and the other is to install Yum one-time
(1) Zlib installation
Download Address: http://zlib.net/fossils/
$tar-xvzf zlib-1.2.5.tar.gz
$CD zlib-1.2.5.tar.gz
$./configure
$make
$make Install
(2) Pcre installation
Download Address: http://ftp.exim.llorien.org/pcre/
$tar-xvzf pcre-8.02.tar.gz
$CD pcre-8.02
$./configure--prefix=/usr/local/pcre--enable-utf8--enable-unicode-properties
$ make && make install
(3) OpenSSL installation
Download Address: http://mirrors.ibiblio.org/openssl/source/
$tar ZVXF openssl-1.0.0.tar.gz
$CD openssl-1.0.0
$./config--prefix=/usr/local/ssl-1.0.0 shared zlib-dynamic Enable-camellia
$make && make Install
(4) Nginx installation
Download Address: http://nginx.org/download/
$tar ZVXF Nginx 0.8.40.tar.gz
$CD Nginx 0.8.40
$./configure
$ make
$ make Install
More configuration:
./configure--prefix=/usr/local/nginx
--with-openssl=/usr/include (SSL enabled)
--with-pcre=/usr/include/pcre/(enable regular expressions)
--with-http_stub_status_module (installs programs that can view nginx status)
--with-http_memcached_module (enable Memcache cache)
--with-http_rewrite_module (enable URL rewriting enabled)
Two methods are as follows: This method is good, not easy to make mistakes, if the net speed is 10 in a while can complete, the network is not good can also be completed in 20.
Yum–y install zlib zlib-devel OpenSSL openssl-devel pcre pcre-devel
The installation of three dependent programs is now successful, and the following is the installation of Nginx 0.8.40.
Website Download Address: http://www.nginx.org/
$tar ZVXF Nginx 0.8.40.tar.gz
$CD Nginx 0.8.40
$./configure//By default installed under/usr/local/nginx
$ make
$ make Install
4. Configuration (Very important)
Copy Code code as follows:
#修改防火墙配置:
[Root@bogon nginx-0.8.4]# VI +/etc/sysconfig/iptables
#添加配置项
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
#重启防火墙
[Root@bogon nginx-0.8.4]# Service iptables restart
5. Start:
Copy Code code as follows:
#方法1
[Root@bogon nginx-0.8.4]#/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
#方法2
[Root@bogon nginx-0.8.4]# Cd/usr/local/nginx/sbin
[Root@bogon sbin]#./nginx
6. Stop:
Copy Code code as follows:
#查询nginx主进程号
Ps-ef | grep nginx
#停止进程
Kill-quit Main process Number
#快速停止
Kill-term Main process Number
#强制停止
Pkill-9 Nginx
7. Test:
Copy Code code as follows:
#测试端口
Netstat–na|grep 80
#浏览器中测试
Http://127.0.0.1:80
8. Attention to the problem:
workaround when installing Nginx:
Copy Code code as follows:
[Root@bogon sbin]#./nginx
[Emerg]: Bind () to 0.0.0.0:80 failed (98:address already in use)
[Emerg]: Bind () to 0.0.0.0:80 failed (98:address already in use)
[Emerg]: Bind () to 0.0.0.0:80 failed (98:address already in use)
[Emerg]: Bind () to 0.0.0.0:80 failed (98:address already in use)
[Emerg]: Bind () to 0.0.0.0:80 failed (98:address already in use)
[Emerg]: Still could not bind ()
#netstat-NPTL//View 80 ports have been used
#killall Nginx//CAN