Alibaba Cloud Linux 3.2104 64位安装nginx-1.16.1
2022/2/10 7:17:20
本文主要是介绍Alibaba Cloud Linux 3.2104 64位安装nginx-1.16.1,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 下载nginx
从nginx官网 http://nginx.org/ 下载新的稳定版本nginx 并上传到linux服务器
2 安装nginx 所需要的扩展
yum -y install pcre openssl openssl-devel
3 安装nginx
useradd -s /sbin/nologin www tar zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-pcre=/home/www/pcre-8.31 (源文件的解压路径不是安装路径) --with-http_gzip_static_module make make install
配置nginx开机启动文件
vi /etc/init.d/nginx 写入如下内容 根据实际情况修改
#!/bin/sh # # nginx - this script start and stop the nginx daemon # # chkconfig: 2345 55 25 # description: Startup script for nginx # processname: nginx # config: /usr/local/nginx/conf/nginx.conf # pidfile: /var/run/nginx.pid # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/nginx/sbin/nginx CONFIGFILE=/usr/local/nginx/conf/nginx.conf PIDFILE=/var/run/nginx.pid SCRIPTNAME=/etc/init.d/nginx LOCKFILE=/var/lock/nginx.lock set -e [[ -x "$DAEMON" ]] || exit 0 start() { echo "Startting Nginx......" [[ -x $DAEMON ]] || exit 5 [[ -f $CONFIGFILE ]] || exit 6 $DAEMON -c $CONFIGFILE || echo -n "Nginx already running!" [[ $? -eq 0 ]] && touch $LOCKFILE } stop() { echo "Stopping Nginx......" MPID=`ps aux | grep nginx | awk '/master/{print $2}'` if [[ "${MPID}X" != "X" ]]; then kill -QUIT $MPID [[ $? -eq 0 ]] && rm -f $LOCKFILE else echo "Nginx server is not running!" fi } reload() { echo "Reloading Nginx......" MPID=`ps aux | grep nginx | awk '/master/{print $2}'` if [[ "${MPID}X" != "X" ]]; then kill -HUP $MPID else echo "Nginx can't reload!" fi } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop sleep 1 start ;; *) echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" exit 3 ;; esac exit 0
4 设置开机启动
chmod 755 /etc/init.d/nginx chkconfig --add nginx chkconfig nginx on /etc/init.d/nginx start
5 测试
用浏览器访问实际的域名 看看是否正常
重启服务器 看nginx 是否随机启动
6 配置相关
######## 查看nginx状态配置 location =/nginx_status { stub_status on; access_log off; #allow 127.0.0.1; #deny all; }
active connections – 活跃的连接数量
server accepts handled requests — 总共处理了11989个连接 , 成功创建11989次握手, 总共处理了11991个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
这篇关于Alibaba Cloud Linux 3.2104 64位安装nginx-1.16.1的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-13用Nginx防范DDoS攻击的那些事儿
- 2024-12-13用Terraform在AWS上搭建简单NGINX服务器指南
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享