Nginx网站服务,服务基础,访问控制(实战!)

  

关于Nginx

  

一款高性能,轻量级web服务软件

  
  

稳定性高
系统资源消耗低
对HTTP并发连接的处理能力高

  
      <李>单台物理服务器可支持30000 ~ 50000个并发请求李   
     

环境

  
 <代码>一台Linux服务器(192.168.13.128)
  一台win10测试机 
  

一,在Windows上将灯所需压缩软件包共享出来(此处如有问题请看之前的博客相关文章)

  

 Nginx网站服务,服务基础,访问控制(实战!)

  

二,在Linux上使用远程共享获取文件并挂载到mnt目录下

  
 <代码> [root@localhost ~] # smbclient - l//192.168.100.3/# #远程共享访问
  进入SAMBA \ root的密码:
  
  Sharename类型的评论
  - - - - - - - - - - - - - - - - - - - - - - - -
  LAMP-C7磁盘
  root@localhost ~ #山。cifs//192.168.100.3/LAMP-C7/mnt # #挂载到/mnt目录下 
  

三、编译安装Nginx

  
1,解压源码包到/opt下,并查看
  
 <代码> [root@localhost ~] # cd/mnt # #切换到挂载点目录
  [root@localhost mnt] # ls
  apr-1.6.2.tar。广州Discuz_X2.5_SC_UTF8。zip LAMP-php5.6.txt
  apr-util-1.6.0.tar。广州错误。png mysql-5.6.26.tar.gz
  awstats-7.6.tar。广州httpd-2.4.29.tar。bz2 nginx-1.12.0.tar.gz获取
  cronolog el7.x86_64——1.6.2 - 14.。rpm kali.jpg php-5.6.11.tar.bz2
  [root@localhost mnt] #焦油zxvf nginx-1.12.0.tar。广州- c/opt # #解压Nginx源码包到/opt下
  [root@localhost mnt] # cd/opt/# #切换到解压的目录下
  root@localhost选择# ls
  nginx-1.12.0 rh  
  
2,安装编译需要的环境组件包
  
 <代码>安装\ [root@localhost选择]# yum - y
  gcc \//c语言
  gcc-c + + \//c++语言
  pcre-devel \//pcre语言工具
  zlib-devel//数据压缩用的函式库代码 
  
3,创建程序用户nginx并编译nginx h5> <代码> [root@localhost选择]# useradd - m - s/sbin/nologin nginx # #创建程序用户,安全不可登陆状态   [root@localhost选择]# id nginx   uid=1001 (nginx) gid=1001 (nginx)组=1001 (nginx)   [root@localhost选择]# cd nginx-1.12.0/# #切换到nginx目录下   [root@localhost nginx-1.12.0] # ./configure \ # #配置nginx   比;——prefix=/usr/地方/nginx \ # #安装路径   比;——用户=nginx \ # #用户名   比;——组=nginx \ # #用户组   比;——with-http_stub_status_module # #状态统计模块   
4,编译和安装
  
 <代码> [root@localhost nginx-1.12.0] #让# #编译
  …
  [root@localhost nginx-1.12.0] # make install # #安装
  … 
  
5,优化nginx启动脚本,以便于系统识别h5> <代码> [root@localhost nginx] # ln - s/usr/local/nginx/sbin/nginx/usr/local/sbin/# #创建软连接让系统识别nginx启动脚本   [root@localhost nginx] # nginx - t # #检查配置文件的语法问题/usr/local/nginx/conf/nginx. nginx:配置文件配置语法好/usr/local/nginx/conf/nginx. nginx:配置文件配置测试是成功的   [root@localhost nginx] # nginx # #开启ngnix   [root@localhost nginx] # netstat -ntap | grep 80 # #查看端口,nginx已经开启   tcp 0 0 0.0.0.0:80 0.0.0.0: * 39620/nginx听:主人   [root@localhost nginx] # systemctl firewalld停止。服务# #关闭防火墙   [root@localhost nginx] # setenforce 0   
6,安装elinks网页测试工具,并进行测试h5> <代码> [root@localhost nginx] # yum安装elinks - y # #安装elinks软件   [root@localhost nginx] # elinks http://localhost # #测试nginx网页   

 Nginx网站服务,服务基础,访问控制(实战!)

  
7日服务开启重载以及关闭h5> <代码> [root@localhost nginx] killall - s退出nginx # # #停止或者使用killall 3 nginx   [root@localhost nginx] # killall - s玫瑰nginx # #重启或者使用killall 1 nginx   [root@localhost nginx] # nginx # #开启   
8日制作管理脚本,便于使用服务管理使用
  
 <代码> [root@localhost nginx] # cd/etc/init.d/# #切换到启动配置文件目录
  [root@localhost init。d] # ls
  函数netconsole网络自述
  [root@localhost init。d] # vim nginx # #编辑启动脚本文件
  
  # !/bin/bash
  20 # # # chkconfig: - 99注释信息
  描述:Nginx服务控制脚本
  学监="/usr/地方/nginx/sbin/nginx”# #设置变量为nginx命令文件
  PIDF="/usr/地方/nginx/logs/nginx。pid”# #设置变量pid文件进程号为5346
  “1美元”
  开始)
  美元掠夺# #开启服务
  ;;
  停止)
  杀- s退出美元(猫PIDF美元)# #关闭服务
  ;;
  重启)# #重启服务
  0美元停止
  $ 0开始
  ;;
  重载)# #重载服务
  杀- s玫瑰(猫PIDF美元美元)
  ;;
  *)# #错误输入提示
  回声”用法:$ 0{启动|停止| |重启重载}”
  出口1
  esac
  退出0
  [root@localhost init。d] # chmod + x/etc/init.d/nginx # #给启动脚本执行权限
  [root@localhost init。d] # chkconfig——添加nginx # #添加到服务管理器中
  [root@localhost init。d] nginx停止# # #服务就可以使用服务控制nginx
  [root@localhost init。d] #服务nginx开始

Nginx网站服务,服务基础,访问控制(实战!)