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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 創建 Nginx 虛擬主機 **Nginx** 是一個快速的、輕量級的 Web 服務器軟件, 在許多情況下它已取代了 Apache,尤其是運行 Web 應用程序的情況。 然而,其配置語言與 Apache 相比并沒有做什么重大改進,仍然不夠簡單清晰。 此外,大多數的配置文檔只有俄語版,這也就解釋了為什么你看到這么多份關于 "Understanding Russian for Nginx Administrators" 的拷貝。 #### 準備工作 你需要 [當文件更新時運行命令](#ch06sec06) 一節中曾使用的 Nginx 模塊。 如果你像本章 [管理 Apache 服務](#ch07sec01) 一節中那樣創建了 Apache 模塊, 你還需要使用如下命令關閉 Apache 服務: ``` # service apache2 stop ``` #### 操作步驟 1. 添加如下代碼到 /etc/puppet/modules/nginx/manifests/init.pp: ``` define site( $sitedomain = "" ) { include nginx if $sitedomain == "" { $vhost_domain = $name } else { $vhost_domain = $sitedomain } file { "/etc/nginx/sites-available/${vhost_domain}.conf": content =&gt; template("nginx/vhost.erb"), require =&gt; Package["nginx"], } file { "/etc/nginx/sites-enabled/${vhost_domain}.conf": ensure =&gt; link, target =&gt; "/etc/nginx/sites-available/${vhost_domain}. conf", require =&gt; File["/etc/nginx/sites-available/${vhost_ domain}.conf"], notify =&gt; Exec["reload nginx"], } } ``` 2. 使用如下內容創建 /etc/puppet/modules/nginx/templates/vhost.erb 文件: ``` server { listen 80; server_name &lt;%= vhost_domain %&gt;; access_log /var/log/nginx/&lt;%= vhost_domain %&gt;-access_log; root /var/www/&lt;%= vhost_domain %&gt;; } ``` 3. 創建目錄 /var/www/bbqrecipes.com,使用適當的信息創建此目錄下的 index.html 文件: ``` Welcome to the BBQ Recipes site! ``` 4. 添加如下代碼到一個節點: ``` nginx::site { "bbqrecipes.com": } ``` 5. 運行 Puppet: ``` # puppet agent -test info: Retrieving plugin info: Caching catalog for cookbook. bitfieldconsulting.com info: Applying configuration version '1309198476' notice: /Stage[main]/Nginx/Package[nginx]/ensure: ensure changed 'purged' to 'present' notice: /Stage[main]//Node[cookbook]/Nginx::Site[bbqrecipes.com]/ File[/etc/nginx/sites-available/bbqrecipes.com.conf]/ensure: defined content as '{md5}fa92d2e7543b378e26827a063be34a31' notice: /Stage[main]//Node[cookbook]/Nginx::Site[bbqrecipes.com]/ File[/etc/nginx/sites-enabled/bbqrecipes.com.conf]/ensure: created info: /Stage[main]//Node[cookbook]/Nginx::Site[bbqrecipes.com]/ File[/etc/nginx/sites-enabled/bbqrecipes.com]: Scheduling refresh of Exec[reload nginx] notice: /Stage[main]/Nginx/Service[nginx]/ensure: ensure changed 'stopped' to 'running' notice: /Stage[main]/Nginx/Exec[reload nginx]: Triggered 'refresh' from 1 event notice: Finished catalog run in 21.45 seconds ``` #### 工作原理 以 bbqrecipes.com 為資源名對名為 nginx::site 的 define 創建一個實例, Puppet 會使用變量 vhost_domain 的值 bbqrecipes.com 調用 vhost.erb 模板生成相應的配置文件 bbqrecipes.com.conf。 此文件包含了 Nginx 為了響應對 domain 的請求所需要知道的一切, 并且指明了與 domain 對應的根文檔目錄所映射的文件系統位置。 #### 更多用法 與 Apache 不同,Nginx 直到現在還不支持動態模塊。這就意味著, 如果想為其添加默認不包含的特殊功能,你必須自己重新編譯 Nginx。 正確的做法是,使用你想要的選項編譯 Nginx,然后創建一個軟件包,將其放在自己的倉庫中 (參見 [配置 APT 軟件倉庫](#ch05sec07) 一節的描述)提供給需要它的節點使用。 然而,一些使用 Puppet 的系統管理員希望省略這個步驟,直接提供源碼包并在目標服務器上編譯。 為了實現這點,可以使用 exec 資源通過類似于 [從源碼包自動構建軟件](#ch05sec09) 一節中描述的模式實現。 對于敏捷開發環境而言,被管理的有關產品幾乎每隔幾天就會有所變化,在這種情況下, 使用這種做法比不斷重構軟件包要迅速且節省由于重構軟件包帶來的成本。 #### 參見本書 * 本章的 [管理 Rails 應用程序](#ch07sec06) 一節
                  <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>

                              哎呀哎呀视频在线观看