1、环境准备:先安装准备环境
[root@nginx ~]#yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
2、下载nginx 安装包: 官网地址:http://nginx.org/
现在就是Nginx和OpenSSL的安装与配置(这里注意,一般情况下一个IP只支持一个SSL证书,那么我们现在要在一个IP上实现多个SSL证书,就必须让Nginx支持TLS SNI,由于默认的OpenSSL是没有打开TLS SNI的),TCP请求转发基于stream在nginx1.9版本前,需要单独编译安装该组建,而目前我下载的是nginx-1.14.0
3、解压安装包:
[root@nginx ~]#tar xvf nginx-1.14.0.tar.gz
[root@nginx ~]#cd nginx-1.14.0
[root@nginx ~]#groupadd nginx
[root@nginx ~]#useradd -g nginx nginx
[root@nginx ~]#./configure --prefix=/usr/local/nginx/ --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
[root@nginx ~]#make && make install
[root@nginx ~]#cd /usr/local/nginx/sbin
[root@nginx ~]#./nginx -V
[root@nginx ~]#
Nginx 启动脚本
#!/bin/bash
#chkconfig: - 85 15
#description: Nginx is a World Wide Web server.
#processname: nginx
nginx=/usr/local/nginx/sbin/nginx
conf=/usr/local/nginx/conf/nginx.conf
case $1 in
start)
echo -n "Starting Nginx"
$nginx -c $conf
echo " done"
;;
stop)
echo -n "Stopping Nginx"
killall -9 nginx
echo " done"
;;
test)
$nginx -t -c $conf
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
echo " done"
;;
restart)
$0 stop
$0 start
;;
show)
ps -aux|grep nginx
;;
*)
echo -n "Usage: $0 {start|restart|reload|stop|test|show}"
;; esac
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
服务启动脚本(适合centos 7 版本)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|