/usr/local/src下
1.安装nginx需要一个c++环境:yum install -y gcc gcc-c++
2.安装nginx需要一个pcre依赖:wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
(1)tar -zxvf pcre-8.40.tar.gz
(2) cd pcre-8.40
(3) ./configure && make && make install 完成pcre安装
3安装nginx需要zlib依赖:wget http://zlib.net/zlib-1.2.11.tar.gz
(1)tar -zxvf zlib-1.2.11.tar.gz
(2) cd zlib-1.2.11
(3)./configure && make && make install 完成zlib安装
4.若为ssl网需执行这一步wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
(1) tar -zxvf openssl-fips-2.0.10.tar.gz
(2)cd openssl-fips-2.0.10
(3)./config && make && make install 进入文件执行安装程序
5.安装nginx:wget http://nginx.org/download/nginx-1.10.2.tar.gz
(1) tar -zxvf nginx-1.10.2.tar.gz
(2) cd nginx-1.10.2
(3)./configure && make && make install完成安装
3.启动nginx
(1)、查看nginx安装的地址(whereis)
(2)、进入目录启动
cd /usr/local/nginx/
/usr/local/nginx/sbin/nginx
一般这个时候会报错,不要慌张!!!
错误信息:error while loading shared libraries:libpcre.so.1.......
解决方案:
[root@localhost nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so.1 /usr/local/lib/libpcre.so
[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@localhost nginx]# sbin/nginx
[root@localhost nginx]# ps -aux | grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 12007 0.0 0.0 20296 628 ? Ss 13:28 0:00 nginx: master process sbin/nginx
nobody 12008 0.0 0.1 20716 1220 ? S 13:28 0:00 nginx: worker process
root 12010 0.0 0.0 103244 836 pts/0 S+ 13:29 0:00 grep nginx