参考:
https://blog.youkuaiyun.com/default7/article/details/97789141
https://blog.youkuaiyun.com/edwin19911212/article/details/82811818
升级过程
阿里云一直在报错提示有一个nginx漏洞。Nginx HTTP/2和mp4模块远程拒绝服务漏洞
创建文件 /etc/yum.repo.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
如果是RHEL则如下内容
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enabled=1
再执行 yum update nginx 即可,升级之后,再重新启动nginx。
此时升级后的服务为默认安装路径:
即:启动脚本在/usr/sbin/nginx
配置文件在/etc/nginx/nginx.conf
启动:可以nohup /usr/sbin/nginx /etc/nginx/nginx.conf &>/dev/null &
或者创建nginx脚本启动脚本如下:
#! /bin/sh
# chkconfig: - 85 15
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/$NAME
CONFIGFILE=/etc/nginx/$NAME.conf
PIDFILE=/etc/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
将这脚本文件nginx放入/etc/init.d/目录下,即可使用service nginx start或sh nginx进行启动。
报错一
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/vhost/site1.conf:14
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/vhost/pma.conf:26
移除 ssl on 在 listen 443 http2 ssl 加入即可。nginx 1.17 比 nginx1.12配置更清晰。
状态
[root@f2 vhost]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-05-21 11:14:47 CST; 2 months 9 days ago
Docs: http://nginx.org/en/docs/
Main PID: 9408 (nginx)
CGroup: /system.slice/nginx.service
├─ 9408 nginx: master process /usr/sbin/nginx
├─ 9410 nginx: worker process is shutting down
├─30376 nginx: worker process
└─30377 nginx: worker process
May 21 11:14:47 fl2 systemd[1]: Starting The nginx HTTP and reverse proxy server...
May 21 11:14:47 fl2 nginx[15219]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
May 21 11:14:47 fl2 nginx[15219]: nginx: configuration file /etc/nginx/nginx.conf test is successful
May 21 11:14:47 fl2 systemd[1]: Started The nginx HTTP and reverse proxy server.
报错二
重启报如下:
nginx: [emerg] module "/usr/lib64/nginx/modules/ngx_http_geoip_module.so" version 1012002 instead of 1014000 in /usr/share/nginx/modules/mod-http-geoip.conf:1
这个原因是因为以前nginx modules 和现在官方的modules 不匹配需要我们先将旧的modules 卸载安装新版官方的modules
命令如下:
yum remove nginx-mod*
yum install nginx-module-*
然后再次重启ok
本文详细记录了阿里云环境下Nginx的升级步骤,包括创建yum源配置文件、执行更新命令,并解决了升级后遇到的配置警告与模块版本冲突问题。
1051

被折叠的 条评论
为什么被折叠?



