<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                #### 1. 安裝依賴包 nginx依賴ssl,rewrite,gzip 3個包,如果沒有c++編譯環境需要用下面命令安裝。 `yum install gcc-c++` #### 2. 建立目錄 先在home目錄下建一個nginx文件夾。然后進入文件。(nginx、openssl、zlib、pcre直接下載到這個文件夾,解壓也是解壓到這個文件夾,都安裝好后直接刪除即可。) ~~~ cd home mkdir nginx cd nginx ~~~ #### 3. openssl庫安裝 ssl功能需要安裝openssl庫 ,官網:https://www.openssl.org。建立文件夾/alidata/library/做為這3個庫的安裝目錄。統一放一個文件夾,日后如果想卸載,直接刪除就可以。在library下面再建立openssl、zlib、pcre三個文件夾。做為那3個庫的安裝目錄。 參考:https://blacksaildivision.com/how-to-install-openssl-on-centos 查看openssl版本 ``` openssl version which openssl ``` ``` wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz yum install libtool perl-core pcre-devel zlib-devel -y #安裝響應的組件 tar -zxvf openssl-1.1.1k.tar.gz cd openssl-1.1.1k ./config --prefix=/alidata/library/openssl --openssldir=/alidata/library/openssl shared zlib && make && make install ``` 添加新版本 ``` mv /usr/bin/openssl /usr/bin/opensslOld (舊版本可以刪除) ln -s /alidata/library/openssl/bin/openssl /usr/bin/openssl ln -s /alidata/library/openssl/lib/libssl.so.1.1 /usr/lib64/ ln -s /alidata/library/openssl/lib/libcrypto.so.1.1 /usr/lib64/ ``` ``` vi /etc/profile.d/openssl.sh (添加啟動腳本路徑) # /etc/profile.d/openssl.sh pathmunge /alidata/library/openssl/bin ``` 執行命令使openssl新版本lib路徑生效 ``` ldconfig ``` 重開shell #### 4. 安裝zlib庫 gzip模塊需要安裝zlib庫,官網:https://www.zlib.net。(axel -n 后面的10是一次性建立10個連接下載) ~~~ axel -n 10 https://www.zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure --prefix=/alidata/library/zlib && make && make install ~~~ #### 5. 安裝pcre庫 rewrite模塊需要pcre庫,官網:https://www.pcre.org。 ~~~ axel -n 10 https://deac-ams.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz tar -zxvf pcre-8.45.tar.gz cd pcre-8.45 ./configure --prefix=/alidata/library/pcre && make && make install ~~~ #### 6. nginx的編譯安裝 下載nginx,nginx的官網是https://nginx.org/。我們直接下載最新版本的nginx-1.14.2。在/alidata下建立server,然后在server下面分別建立nginx、mysql、php。后面會分別把對應的軟件安裝到這幾個文件夾里。(--prefix:nginx的安裝目錄 ,--with-pcre:pcre的源碼目錄,--with-zlib和--with-openssl同理) ~~~ axel -n 10 https://nginx.org/download/nginx-1.20.1.tar.gz tar -zxvf nginx-1.20.1.tar.gz cd nginx-1.20.1 ./configure \ --prefix=/alidata/server/nginx \ --with-http_realip_module \ --with-http_sub_module \ --with-http_flv_module \ --with-http_dav_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_addition_module \ --with-pcre=/home/nginx/pcre-8.45 \ --with-openssl=/home/nginx/openssl-1.1.1k \ --with-openssl-opt='enable-tls1_3 enable-weak-ssl-ciphers' \ --with-http_ssl_module \ --with-http_v2_module \ --with-stream_ssl_module \ --with-zlib=/home/nginx/zlib-1.2.11 && make && make install ~~~ ![](https://box.kancloud.cn/f12e32e64d49d4f1d179bdc823bec954_1918x1013.png =770x400) ![](https://box.kancloud.cn/e7c94bc0d57782c88cfc126595277657_1917x1009.png =770x400) ![](https://box.kancloud.cn/fb769711a6d0b36e6d4a4088458c0dff_778x725.png) ![](https://box.kancloud.cn/9b2e99afc01e42595a1635ebe932697e_780x161.png) ![](https://box.kancloud.cn/afe787b404b2de4f9441a19b62b09621_779x136.png) #### 7. 檢查nginx是否安裝成功 檢查nginx是否安裝成功,如果出現下圖信息,表示安裝成功。 ~~~ cd /alidata/server/nginx/sbin ./nginx -t ~~~ ![](https://box.kancloud.cn/865ea7eb8cc66c6a957c3adeeec56ab6_780x104.png) ![](https://box.kancloud.cn/e07c544ac1f0b30823eeca19b2febc08_780x309.png) #### 8. 常用命令 nginx的幾個常用命令: 查看Nginx的版本號:./nginx -v 啟動Nginx:./nginx 快速停止或關閉Nginx:./nginx -s stop 正常停止或關閉Nginx:./nginx -s quit 配置文件修改重裝載命令:./nginx -s reload #### 9. 將nginx加入系統命令 vi /etc/init.d/nginx 加入下面代碼 ~~~ #!/bin/bash #nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/alidata/server/nginx/sbin/nginx nginx_config=/alidata/server/nginx/conf/nginx.conf nginx_pid=/alidata/server/nginx/run/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ [${NETWORKING} = "no"] ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /alidata/server/nginx/run/nginx.pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL ~~~ 保存上面的代碼。然后添加到系統服務中。 ~~~ chmod 755 /etc/init.d/nginx chkconfig --add nginx ~~~ #### 10. 在系統服務目錄中創建nginx.service文件 `vi /usr/lib/systemd/system/nginx.service` 加入下面的代碼 ~~~ [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/alidata/server/nginx/sbin/nginx ExecReload=/alidata/server/nginx/sbin/nginx -s reload ExecStop=/alidata/server/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target ~~~ 保存。再執行重加載 `systemctl daemon-reload` 設置開機啟動 `systemctl enable nginx.service` ![](https://box.kancloud.cn/139d1bd6272fe6d138cf0c0f6d9c9e89_780x274.png) #### 10. nginx服務命令 配置好之后nginx就可以用系統服務的方式操作了。 service nginx start 啟動nginx service nginx stop 關閉nginx service nginx restart 重啟nginx service nginx reload 重新加載nginx ![](https://box.kancloud.cn/e22dda5676007bb140f50fb61060bf6d_779x150.png) ![](https://box.kancloud.cn/c257016fd720ebc8d2056812d64c2bae_1917x446.png =770x180) #### 11. 添加用戶和組 `groupadd -r www && adduser -r -g www -s /bin/false -d /alidata/www -M www` 查看用戶 `cat /etc/passwd` 查看組 `cat /etc/group`
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看