centos7离线搭建nginx相关部署说明

6 篇文章 0 订阅
1 篇文章 0 订阅

将zlib-1.2.11.tar.gz 解压安装

    [root@wizesb-test-mng01 java]# cd /data/zlib
    [root@wizesb-test-mng01 zlib]# tar -zxvf zlib-1.2.11.tar.gz 
    [root@wizesb-test-mng01 zlib]# ./configure 

解压安装gcc_dependences.zip

    [root@wizesb-test-mng01 gcc]# cd /data/gcc/
    [root@wizesb-test-mng01 gcc]# rpm -Uvh *.rpm --nodeps --force

解压安装nginx-1.15.7.tar.gz

    [root@wizesb-test-mng01 gcc]# cd nginx/

    [root@wizesb-test-mng01 nginx]# tar zxvf nginx-1.15.7.tar.gz
    [root@wizesb-test-mng01 nginx]# cd nginx-1.15.7
    [root@wizesb-test-mng01 nginx]# ./configure
    [root@wizesb-test-mng01 nginx]# make
    [root@wizesb-test-mng01 nginx]# make install

    // 测试是否安装成功
    cd /usr/local/nginx
    ./sbin/nginx -t 
    // 显示结果
    [root@192 nginx]# ./sbin/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

    // 启动nginx
    cd /usr/local/nginx/sbin
    ./nginx   

    //通过端口查看nginx是否开启
    netstat -ntlp | grep 80


    1、关闭firewall:
    systemctl stop firewalld.service #停止firewall
    systemctl disable firewalld.service #禁止firewall开机启动
    firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)


    配置nginx开机自启动
    vim /etc/rc.d/rc.local
    /usr/local/nginx/sbin/nginx

    将nginx加入systemctl

    vi  /usr/lib/systemd/system/nginx.service
    [Unit]
    Description=The nginx HTTP and reverse proxy server
    After=network.target remote-fs.target nss-lookup.target


    [Service]
    Type=forking
    ###通过 find / -name 'nginx.pid'找到pid的位置
    PIDFile=/usr/local/nginx/logs/nginx.pid    

    # Nginx will fail to start if /run/nginx.pid already exists but has the wrong
    # SELinux context. This might happen when running `nginx -t` from the cmdline.
    # https://bugzilla.redhat.com/show_bug.cgi?id=1268621

    ExecStartPre=/usr/bin/rm -f /usr/local/nginx/logs/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/bin/kill -s HUP $MAINPID
    KillSignal=SIGQUIT
    TimeoutStopSec=5
    KillMode=process
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target


    :wq
    保存退出
    开启开机启动
    systemctl enable nginx.service
    systemctl  restart nginx
    pkill -9 nginx
    systemctl start nginx.service

    查看端口占用
    ss -lntp | egrep ':80\s'



    部署vue项目
    cd /usr/local/nginx/conf/
    vi nginx.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值