<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安裝和端口轉發 ## 1.下載相應的依賴,準備安裝包 ```shell yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre-devel ``` 上傳安裝包到 /usr/local/src路徑下 [nginx-1.16.1.tar.gz] 下載地址http://nginx.org/download/nginx-1.16.1.tar.gz ## 2.解壓安裝包,配置安裝模塊 ```shell //解壓 tar -zxvf nginx-1.16.1.tar.gz //進入解壓后的文件 cd nginx-1.16.1 // 指定安裝目錄 ./configure --prefix=/data/work/nginx --with-stream --with-http_ssl_module ``` ![](http://dc.zjhcsoft.com:25680/mindoc/uploads/deliver/images/m_7af85e6663efc81d804c82d9cf69a458_r.png) ```shell //編譯(通過gcc進行編譯) make //編譯安裝 make install ``` ![](https://img.kancloud.cn/5b/c8/5bc87126a2b5b2d61f91f238738aa146_660x229.png) ```shell //進入安裝目錄,查看詳細信息 cd nginx ``` ![](https://img.kancloud.cn/2a/64/2a64de566611eb8189d21654e0ec6d24_364x96.png) conf:配置文件文件夾,其中nginx.conf是核心配置文件 html:里邊包含了歡迎首頁(index.html)和錯誤頁(50x.html) logs:記錄日志目錄 sbin:里邊有nginx文件,啟動文件 至此,nginx 安裝完成! ### 補裝模塊 > 有些小伙伴安裝nginx的時候`configure`配置沒有安裝SSL模塊。當然,這些都是經常需要安裝的部分,在本教程中前面的部分中已經安裝了。如果缺失再按照這里的方法進行安裝。 ``` ./configure --with-http_ssl_module --with-stream --prefix=/data/work/nginx ## 不要執行make install make ``` 覆蓋原先nginx目錄中的nginx文件。 ``` cp objs/nginx /data/work/nginx/sbin/nginx ``` ## 3.Nginx一些簡單命令 ### 1.啟動 ```shell #切換到sbin目錄下,執行 ./nginx 簡單啟動,默認配置文件 最常用的方式 /data/work/nginx/sbin/nginx -c /userxxxxxxx/local/nginx/conf/nginx.conf #其中 -c 是指定配置文件,指定任意目錄的配置文件 //查看 ps -ef | grep nginx ``` 啟動后默認的開啟服務端口是80,在瀏覽器直接輸入IP可以出現如下圖頁面。如果80端口未開放的話,自行修改。 ![](http://dc.zjhcsoft.com:25680/mindoc/uploads/deliver/images/m_f6c5a2566ac2b406d81d60776e37bced_r.png) ### 2.關閉 ```shell //找出nginx進程 ps -ef | grep nginx //執行命令,pid是主進程的pid kill -QUIT 主pid //注意在安裝目錄sbin下 ./nginx -s reload ``` ### 3.查看版本 ```shell -v:小寫,顯示nginx版本 /usr/local/nginx/sbin/nginx -v -V:大寫,顯示nginx版本、編譯器版本和配置參數 /usr/local/nginx/sbin/nginx -V ``` ## 4.配置修改與做數據庫端口映射 找到/usr/local/nginx/conf路徑下的nginx.conf文件修改 ![](http://dc.zjhcsoft.com:25680/mindoc/uploads/deliver/images/m_6bae76af4872e716de78487eb4b26b60_r.png) 改成你想要的端口,并重啟nginx,這樣之后在頁面輸入ip+端口就可以直接訪問如上的nginx服務器成功啟動頁面 有個這樣的場景,我想讓在訪問服務器3307端口的時候正好是訪問數據庫的3306端口,我們可以通過nginx做端口的轉發。修改配置如下,看圖應該就能看懂吧。 ![](http://dc.zjhcsoft.com:25680/mindoc/uploads/deliver/images/m_ef4ef771cf454f180dd82de0495e2b7d_r.png) ```shell events { worker_connections 1024; } stream { upstream mysql { server 139.196.33.93:3306; } upstream oracle { server 139.196.33.93:1521; } server { listen 3307; proxy_pass mysql; } server { listen 1525; proxy_pass oracle; } } ``` 現在數據庫就可以通過其他端口連接了連接了
                  <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>

                              哎呀哎呀视频在线观看