centos 7.2 下 nginx 1.14.1 安装部署

时间:2021-12-31 21:51:48
Nginx1.14.1安装部署
1.环境: 所有源码在跳板机kx的/web/soft下
2.安装依赖:
[root@bogon src]# yum install -y libxml2 openssl openssl-devel pcre-devel libxml2-devel libxslt libxslt-devel gd gd-devel perl-ExtUtils-Embed perl-devel geoip geoip-dev
3.创建用户 [root@bogon src]# useradd -s /sbin/nologin -M w 4.解压源码包 [root@bogon src]#tar zxf nginx-1.14.1.tar.gz [root@bogon src]#unzip nginx-module-vts-0.1.18.zip [root@bogon src]#unzip nginx-upstream-fair-master.zip 5.编译安装: [root@bogon src]# cd nginx-1.14.1 [root@bogon nginx-1.14.1]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-http_sub_module --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_xslt_module --with-http_image_filter_module --with-http_perl_module --with-http_gunzip_module --with-http_geoip_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_addition_module --with-debug --add-module=../nginx-upstream-fair-master --add-module=../nginx-module-vts-0.1.18 报错后执行: [root@bogon nginx-1.14.1]# yum -y install GeoIP GeoIP-devel GeoIP-data 重复执行配置命令 [root@bogon nginx-1.14.1]# make 报错后执行: [root@bogon nginx-1.14.1] vim /usr/local/src/nginx-1.14.1/src/http/ngx_http_upstream.h 在 ngx_http_upstream_srv_conf_s 函数里 找到 in_port_t port; 在后面添加 : in_port_t default_port; [root@bogon nginx-1.14.1]# make [root@bogon nginx-1.14.1]# make install [root@youzhuan-online soft]# cat /etc/init.d/nginx

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /usr/local/nginx/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /usr/local/nginx/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL

[root@bogon nginx-1.14.1]# chmod +x /etc/init.d/nginx
[root@bogon nginx-1.14.1]# /etc/init.d/nginx start
[root@bogon nginx-1.14.1]#  systemctl enable nginx