基础服务与访问控制
标签:
Nginx简述Nginx是一款高性能,轻量级web服务软件,其稳定性高、系统资源消耗低, 对HTTP并发连接的处理能力高(单台物理服务器可支持30000~50000个并发请求)。
Nginx常用命令 nginx -t 检查配置文件语法 nginx 启动nginx服务 killall -3 nginx 停止nginx服务 killall -s QUIT nginx 停止nginx服务 killall -s HUP nginx 重载nginx服务 killall -1 nginx 重载nginx服务 实验环境1.基础源码包(无密码):https://pan.baidu.com/s/14WvcmNMC6CFX1SnjHxE7JQ
2.CentOS 7版本Linux虚拟机
第一步:远程获取Windows上的源码包,并挂载到Linux上
[[email protected] ~]# smbclient -L //192.168.235.1 Enter SAMBA\root‘s password: Sharename Type Comment --------- ---- ------- LNMP Disk [[email protected] ~]# mkdir /abc [[email protected] ~]# mount.cifs //192.168.235.1/LNMP /abc Password for [email protected]//192.168.235.1/LNMP: [[email protected] ~]# ls /abc Discuz_X3.4_SC_UTF8.zip nginx-1.12.0.tar.gz php-7.1.10.tar.bz2 mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.20.tar.gz第二步:解压源码包
[[email protected] ~]# cd /abc [[email protected] abc]# tar zxvf nginx-1.12.0.tar.gz -C /opt [[email protected] abc]# ls /opt nginx-1.12.0 rh第三步:下载安装编译组件包
[[email protected] abc]# cd /opt [[email protected] opt]# yum install -y > gcc \ //C语言 > gcc-c++ \ //c++语言 > pcre-devel \ //pcre语言工具 > zlib-devel //压缩函数库第四步:创建程序用户并配置Nginx服务相关组件
[[email protected] opt]# useradd -M -s /sbin/nologin nginx //创建程序用户nginx,并限定其不可登录终端 [[email protected] opt]# cd nginx-1.12.0/ [[email protected] nginx-1.12.0]# ./configure \ //配置nginx > --prefix=http://www.mamicode.com//usr/local/nginx \ //指定安装路径 > --user=nginx //指定用户名 > --group=nginx //指定用户所属组 > --with-http_stub_status_module //安装状态统计模块第五步:编译与安装Nginx
[[email protected] nginx-1.12.0]# make && make install第六步:优化Nginx服务启动脚本,并建立命令软连接
[[email protected] nginx-1.12.0]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ //创建nginx服务命令软链接到系统命令 [[email protected] nginx-1.12.0]# systemctl stop firewalld.service //关闭防火墙 [[email protected] nginx-1.12.0]# setenforce 0 //关闭增强型安全功能 [[email protected] nginx-1.12.0]# nginx //输入nginx 开启服务 [[email protected] nginx-1.12.0]# netstat -ntap | grep 80 //查看服务的80 端口,显示已开启 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7520/nginx: master第七步:使用浏览器访问192.168.235.158,即可访问到Nginx服务的首页
第八步:制作service管理脚本 [[email protected] nginx-1.12.0]# cd /etc/init.d/ //切入启动配置文件目录 #!/bin/bash # chkconfig: - 99 20 ##注释信息 # description: Nginx Service Control Script PROG="/usr/local/nginx/sbin/nginx" ##设置变量为nginx命令文件 PIDF="/usr/local/nginx/logs/nginx.pid" ##设置变量PID文件 进程号为5346 case "$1" in start) $PROG ##开启服务 ;; stop) kill -s QUIT $(cat $PIDF) ##关闭服务 ;; restart) ##重启服务 $0 stop $0 start ;; reload) ##重载服务 kill -s HUP $(cat $PIDF) ;; *) ##错误输入提示 echo "Usage: $0 {start|stop|restart|reload}" exit 1 esac exit 0 [[email protected] init.d]# chmod +x nginx //授予nginx执行权限 [[email protected] init.d]# chkconfig --add nginx //将nginx添加到service管理器 [[email protected] init.d]# service nginx stop //使用service控制nginx服务停止 [[email protected] init.d]# service nginx start //使用service控制nginx服务启动 Nginx的访问状态统计
启用HTTP STUB _STATUS状态统计模块
●配置编译参数时添加--with-http_ stub status module
(前文我们已经顺带安装了统计模块)
●nginx -V查看已安装的Nginx是否包含HTTP STUB_ _STATUS模块
温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/web/10080.html
- 上一篇:PHP灌水机器人实现原理
- 下一篇:web前端入门到实战:css实现文字竖排的方式