部署Nginx服务

IP主机名节点
192.168.19.10nginxNginx节点
   # 修改主机名
   hostnamectl set-hostname nginx
   bash
   # 配置网络
   vi /etc/sysconfig/network-scripts/ifcfg-ens33
   BOOTPROTO=static
   ONBOOT=yes
   IPADDR=192.168.19.10
   NETWORK=255.255.255.0
   GATEWAY=192.168.19.2
   DNS1=8.8.8.8
   DNS2=114.114.114.114
   # 配置yum 源
   # 备份旧的yum源
   mv /etc/yum.repos.d/*  /media
   # 挂载镜像
   mount sr0 /mnt/
   mkdir /opt/centos
   cp -rvf /mnt/* /opt/centos/
   umount /mnt/
   # 关闭防火墙及selinux服务
   systemctl stop firewalld 
   systemctl disable firewalld --now
   sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
   # 安装配置基础服务
   # 编译安装基础环境
   [root@nginx~]# yum install -y gcc gcc-c++ openssl-devel zlib-devel zlib pcre-devel
   # 创建指定用户,这个 nginx 用户要和 PHP 服务器上创建的 nginx 两者 id 一致,这里先创建用户
   [root@nginx~]# groupadd -g 1001 nginx
   [root@nginx~]# useradd -u 900 nginx -g nginx -s /sbin/nologin
   [root@nginx~]# tail -l /etc/passwd
   # 安装配置Nginx服务
    将下载的 nginx-.12.2.tar.gz 压缩包上传至nginx 节点的usr/local/src/
    [root@nginx~]# cd /usr/local/src/
    [root@nginx~]# tar -zxvf nginx-1.12.2.tar.gz
    [root@nginx~]# cd nginx-1.12.2/
    [root@nginx~]# 
./configure --prefix=/usr/local/nginx --with-http_dav_module \
--with-http_stub_status_module --with-http_addition_module \
--with-http_sub_module --with-http_flv_module --with-http_mp4_module \
--with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx
    # 编译安装      
     [root@nginx~]# make 
     [root@nginx~]# make install
    # 编译安装完毕后,创建软连接并启动测试,命令如下: (netstat 命令无法使用时,请自行使用YUM 源安装 net-tools 工具)
     [root@nginx nginx-l.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
     [root@nginx nginx-l.12.2]# nginx -t
     [root@nginx nginx-l.12.2]# nginx
     [root@nginx nginx-1.12.2]# netstat -ntpl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值