安装nginx

1>安装make
     yum -y install gcc automake autoconf libtool make

2>安装g++

    yum install gcc gcc-c++

3>选定源码目录

    cd /usr/local/src

4>安装依赖

    nginx安装依赖pcre库、zlib库、ssl库

    安装nginx前先安装这些依赖

    a>安装pcre库

            cd /usr/local/src

            wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz 

           tar -zxvf pcre-8.44.tar.gz

           cd pcre-8.44

           ./configure

           make

           make install

    b>安装zlib库

            cd /usr/local/src

            wget http://zlib.net/zlib-1.2.11.tar.gz

            tar -zxvf zlib-1.2.11.tar.gz

            cd zlib-1.2.11

            ./configure

            make

            make install

    c>安装ssl

            cd /usr/local/src

            wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz

            tar -zxvf openssl-1.1.1g.tar.gz

5>安装nginx

        cd /usr/local/src

        wget http://nginx.org/download/nginx-1.18.0.tar.gz

        tar -zxvf nginx-1.18.0.tar.gz

        cd nginx-1.18.0

        ./configure --sbin-path=/usr/local/nginx/nginx \

        --conf-path=/usr/local/nginx/nginx.conf \

        --pid-path=/usr/local/nginx/nginx.pid \

        --with-http_gzip_static_module \

        --with-http_stub_status_module \

        --with-file-aio \

        --with-http_realip_module \

        --with-http_ssl_module \

        --with-pcre=/usr/local/src/pcre-8.44 \

        --with-zlib=/usr/local/src/zlib-1.2.11 \

        --with-openssl=/usr/local/src/openssl-1.1.1g

        make

        make install

    #注意

    #--with-pcre=/usr/local/src/pcre-8.44 指的是pcre-8.44 的源码路径。

    #--with-zlib=/usr/local/src/zlib-1.2.11指的是zlib-1.2.11 的源码路径。

6>启动

    #确保系统的 80 端口没被其他程序占用,运行/usr/local/nginx/nginx 命令来启动 Nginx

    cd  /usr/local/nginx

    ./nginx

    #安装完成

7>nginx命令

    nginx -t  测试nginx配置文件是否正确

    nginx -s reload  重新加载nginx配置规则

    nginx -s stop    停止nginx服务

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值