<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>

                [TOC] ### 第一步 下載 nginx 包放置在指定目錄下一般放置 mnt 目錄 下載地址 :[nginx.org/en/download.html](http://nginx.org/en/download.html) ![](https://img.kancloud.cn/4d/6e/4d6eb4ce8ebefb36043c6f8f2bb721ce_594x246.png) 解壓 nginx 壓縮包 ``` tar zxvf nginx-1.19.7.tar.gz ``` 準備依賴包: ``` yum -y install zlib-devel pcre-devel openssl-devel ``` 準備 nginx 用戶: ``` useradd -M -s /sbin/nologin nginx ``` 源碼編譯與安裝: ``` ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_sub_module ``` 安裝 ``` make && make install ``` ## **nginx 配置** 設置配置文件: /usr/local/nginx/nginx.conf ``` user nginx; ``` ![](https://img.kancloud.cn/14/46/14468791180d386970738569cf913db5_383x266.png) 服務管理: 1. 檢測配置語法 ``` /usr/local/nginx/sbin/nginx -t ``` 2. 啟動服務 /usr/local/nginx/sbin/nginx 3. 重載服務 ``` /usr/local/nginx/sbin/nginx -s reload pkill -HUP nginx ``` 4. 關閉服務 ``` /usr/local/nginx/sbin/nginx -s stop pkill nginx ``` 5. 開機啟動 ``` vi /etc/rc.local /usr/local/nginx/sbin/nginx ``` ![](https://img.kancloud.cn/18/1c/181c90454c2df116dc582f9fd247168b_422x273.png) 進程管理: ``` pstree |grep nginx ps -ef |grep nginx ps aux |grep nginx ``` 端口管理: ``` netstat -tunpl |grep nginx ``` 客戶端測試:(輸入你的公網 IP) ``` http://192.168.2.1 ``` nginx 重載 ``` [root@wml sbin]# pkill -HUP nginx ``` ## **補充** > 很多情況下 我們需要執行 nginx -t , -s reload, restart , close ,start 等命令 > 這時候我們需要 執行完整命令 usr/local/nginx/sbin/nginx -t 太麻煩了 我們來配置一個全局的nginx變量 **首先 我們找到目錄 /etc/rc.d/init.d** **然后創建 nginx文件** ![](https://img.kancloud.cn/7b/d6/7bd62dd040b746800d7ac5a6a0d6d228_459x257.png) ~~~ #!/bin/sh # nginx - this script starts and stops the nginx daemin # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /usr/local/nginx/conf/nginx.conf # pidfile: /usr/local/nginx/logs/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac ~~~ **復制上面代碼到 新建的nginx文件中** 編輯文件 vim /etc/profile 在尾部添加如下 ``` PATH=$PATH:/usr/local/nginx/sbin #安裝nginx的sbin目錄 export PATHi ``` ![](https://img.kancloud.cn/ef/ad/efad7ca22b040f0e5a35dcad113262c1_527x167.png) 最后執行 ![](https://img.kancloud.cn/13/29/13292f5f8fea696a055b7aa8d84d1e52_604x80.png)
                  <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>

                              哎呀哎呀视频在线观看