nginx使用说明(一) 安装
以Centos7为例
安装gcc
安装c编译器
[root@localhost ~]# yum install gcc
安装pcre
安装perl语言库
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# yum -y install pcre-devel
[root@localhost src]#wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz
[root@localhost src]# tar -xvzf pcre2-10.20.tar.gz
[root@localhost src]# cd pcre2-10.20/
[root@localhost pcre2-10.20]# ./configure
[root@localhost pcre2-10.20]# make
[root@localhost pcre2-10.20]# make install
安装zlib
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://zlib.net/zlib-1.2.8.tar.gz
[root@localhost src]# tar -xvzf zlib-1.2.8.tar.gz
[root@localhost src]# cd zlib-1.2.8/
[root@localhost zlib-1.2.8]# ./configure
[root@localhost zlib-1.2.8]# make
[root@localhost zlib-1.2.8]# make install
安装OpenSSL
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
[root@localhost src]# tar -xvzf openssl-1.0.2h.tar.gz
[root@localhost src]# cd openssl-1.0.2h/
[root@localhost openssl-1.0.2h]# ./config
[root@localhost openssl-1.0.2h]# make
[root@localhost openssl-1.0.2h]# make install
安装nginx
下载
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://nginx.org/download/nginx-1.10.0.tar.gz
解压
[root@localhost src]# tar -xvzf nginx-1.10.0.tar.gz
[root@localhost src]# cd nginx-1.10.0/
安装配置,安装路径为/usr/local/nginx
[root@localhost nginx-1.10.0]# ./configure --prefix=/usr/local/nginx --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.2h --with-pcre --with-http_ssl_module
[root@localhost nginx-1.10.0]# make
[root@localhost nginx-1.10.0]# make install
启动
修改iptables,添加80端口
确认80端口是否被其它程序占用
[root@localhost nginx]# netstat -apn|grep 80
执行命令启动
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
在浏览器中输入IP地址,如果出现Nginx的欢迎界面,则表示启动成功。