(1)稳定性高 (2)系统资源消耗低 (3)对HTTP并发连接的处理能力高 单台物理服务器可支持30000~50000个并发请求
将Nginx安装包解压到/opt/目录下
[root@localhost mnt]# tar zxvf nginx-1.12.2.tar.gz -C /opt/安装支持软件
[root@localhost opt]# yum install gcc gcc-c++ pcre-devel zlib-devel make -y创建运行用户、组
[root@localhost opt]# useradd -M -s /sbin/nologin nginx编译安装Nginx
[root@localhost opt]# cd nginx-1.12.2/ [root@localhost nginx-1.12.2]# ls auto CHANGES.ru configure html man src CHANGES conf contrib LICENSE README [root@localhost nginx-1.12.2]# ./configure \ > --prefix=/usr/local/nginx \ > --user=nginx \ > --group=nginx \ > --with-http_stub_status_module [root@localhost nginx-1.12.2]# make && make installnginx命令执行路劲优化
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ [root@localhost nginx-1.12.2]# nginx -t //检查配置文件 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@localhost nginx-1.12.2]# nginx //启动nginx [root@localhost nginx-1.12.2]# netstat -ntap | grep 80 //查看端口 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20716/nginx: master关闭防火墙和安全功能
[root@localhost nginx-1.12.2]# systemctl stop firewalld.service [root@localhost nginx-1.12.2]# setenforce 0安装测试包,查看服务是否正常运行
[root@localhost nginx-1.12.2]# yum install elinks -y [root@localhost nginx-1.12.2]# elinks httpd://localhost通过浏览器查看,输入自己的IP地址 制作管理脚本
[root@localhost logs]# cd /etc/init.d/ [root@localhost init.d]# ls functions netconsole network README [root@localhost init.d]# vim nginx #!/bin/bash # chkconfig: - 99 20 # description: Nginx Service Control Script PROG="/usr/local/nginx/sbin/nginx" PIOF="/usr/local/nginx/sbin/nginx" case "$1" in start) $PROG ;; stop) kill -s QUIT $(cat $PIOF) ;; restart) $0 stop $0 start ;; reload) kill -s HUP $(cat $PIOF) ;; *) echo "Usage: $0 {start|stop|restart|reload}" exit 1 esac exit 0 [root@localhost init.d]# chmod +x nginx //给nginx给与执行权限 [root@localhost init.d]# chkconfig --add nginx //将nginx添加到service 然后我们的服务就可以通过service来控制服务的启动#### 安装DNS服务,并配置DNS服务
[root@localhost conf]# yum install bind -y配置主配置文件 配置区域配置文件
配置区域数据配置文件
[root@localhost conf]# cd /var/named [root@localhost named]# cp -p named.localhost kgc.com.zone [root@localhost named]# vim kgc.com.zone开启DNS服务 [root@localhost named]# systemctl start named
