#先将准备好的nginx-1.1.10.tar.gz、pcre-devel-7.8-7.el6.x86_64.rpm、zlib-devel-1.2.3-29.el6.x86_64.rpm 上传至/usr/local/src/目录下
[root@localhost security]# cd /usr/local/src/
[root@localhost src]# ls
nginx-1.1.10.tar.gz pcre-devel-7.8-7.el6.x86_64.rpm
zlib-devel-1.2.3-29.el6.x86_64.rpm
后面加上 --force --nodeps
[root@localhost src]# rpm -ivh pcre-devel-7.8-7.el6.x86_64.rpm[root@localhost src]# rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm
升级openssl
tar -zxvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/data/service/openssl no-zlib
make
make install
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /data/service/openssl/include/openssl/ /usr/include/openssl
ln -s /data/service/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /data/service/openssl/bin/openssl /usr/bin/openssl
echo "/data/service/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
openssl version -a
#安装nginx
[root@localhost src]# tar -zxvf nginx-1.1.10.tar.gz
[root@localhost src]# cd nginx-1.1.10
[root@localhost nginx-1.1.10]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.1.10]# make
[root@localhost nginx-1.1.10]# make install
--启动命令
[root@localhost nginx-1.1.10]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@localhost nginx-1.1.10]# ps -ef|grep nginx
root 23826 1 0 16:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 23827 23826 0 16:44 ? 00:00:00 nginx: worker process
root 23838 4163 0 16:44 pts/0 00:00:00 grep nginx###替换conf目录下的nginx.conf配置文件,
[root@localhost nginx-1.1.10]# cd /usr/local/nginx/conf/
[root@localhost conf]# mv nginx.conf nginx.conf.bak
##将准备好nginx.conf上传至/usr/local/nginx/conf/
[root@localhost conf]# ls
fastcgi.conf mime.types scgi_params.default
fastcgi.conf.default mime.types.default uwsgi_params
fastcgi_params nginx.conf uwsgi_params.default
fastcgi_params.default nginx.conf.bak win-utf
koi-utf nginx.conf.default
koi-win scgi_params
##重启生效
[root@localhost conf]# cd ../sbin
[root@localhost sbin]# ./nginx -s reload##以上操作nginx安装完成。
--停止
[root@localhost nginx-1.1.10]# ps -ef|grep nginx
root 23826 1 0 16:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 23827 23826 0 16:44 ? 00:00:00 nginx: worker process
root 23838 4163 0 16:44 pts/0 00:00:00 grep nginx
[root@localhost nginx-1.1.10]# kill -QUIT 23826
--强制停止
[root@localhost nginx-1.1.10]# pkill -9 nginx
--重启
#1、进入nginx可执行目录sbin下,输入命令
[root@localhost /]# cd /usr/local/nginx/sbin
[root@localhost sbin]#./nginx -s reload
#2、在任意目录重启
[root@localhost sbin]#/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
https模块注意配置
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
server {
listen 443 ssl ;
server_name 127.0.0.1;
ssl_certificate test.pem;
ssl_certificate_key test.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
}
//---------非root用户安装-------//
--安装 pcre 开始(root用户安装)
tar -xvf pcre-8.12.tar.gz
cd pcre-8.12/
./configure
make && make install
--安装 pcre 结束--安装 nginx 开始(普通用户安装)
cd /dev/hnfsjf/insallPackages/ngingx/
tar -xvf nginx-1.15.8.tar.gz
cd nginx-1.15.8
./configure --prefix=/dev/hnfsjf/service/nginx --with-http_ssl_modulemake && make install
安装成功后 启动nginx 报错,错误如下:
./nginx: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
根据网上搜索结果,使用root 用户 执行:ln -s /usr/local/lib/libpcre.so.0 /lib64 即可。再切换到普通用户,启动nginx
--安装 nginx 结束
hhFs8800808!
./configure --with-http_ssl_module --with-openssl=/usr/share/doc/openssl-1.0.1e --with-pcre=/usr/share/doc/pcre-7.8 --with-zlib=/usr/share/doc/zlib-1.2.3
./configure --prefix=/data/service/nginx --with-http_ssl_module --with-openssl=/data/installPackage/openssl-1.1.1g
# 设置常量
./configure \
--prefix=/自定义位置/ \
--sbin-path=/自定义位置/nginx \
--conf-path=/自定义位置/nginx.conf \
--pid-path=/自定义位置/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/pcre-8.38 \ # 刚刚安装的 pcre 的位置
--with-zlib=/usr/local/zlib-1.2.11 \ # 刚刚安装的 zlib 的位置
--with-openssl=/usr/local/openssl-1.0.1t #刚刚安装的 openssl 的位置
//---------nginx升级---------//
nginx -V
查看configure配置
下载新版本nginx后解压
./configure (复制前面查看的配置,不然少模块)
make后不要make install
找到objs文件下nginx文件替换旧版本sbin下nginx文件(原来的备份好点)
最后在新解压的nginx版本处运行
make upgrade