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