

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# apache2 屬性
<a name="attributes-recipes-apache"></a>

**重要**  
 AWS OpsWorks Stacks 此服務已於 2024 年 5 月 26 日終止，並已針對新客戶和現有客戶停用。我們強烈建議客戶盡快將其工作負載遷移至其他解決方案。如果您對遷移有任何疑問，請透過 [AWS re：Post](https://repost.aws/) 或透過 [AWS Premium Support](https://aws.amazon.com/support) 聯絡 AWS 支援 團隊。

**注意**  
這些屬性僅適用於 Linux 堆疊。

[apache2 屬性](https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/apache2/attributes/apache.rb)指定 [Apache HTTP 伺服器](http://httpd.apache.org/)組態。如需詳細資訊，請參閱 [Apache Core Features](http://httpd.apache.org/docs/current/mod/core.html)。如需如何覆寫內建屬性以指定自訂值的詳細資訊，請參閱[覆寫屬性](workingcookbook-attributes.md)。


****  

|  |  |  | 
| --- |--- |--- |
| [binary ](#attributes-recipes-apache-bin) | [contact ](#attributes-recipes-apache-contact) | [deflate\$1types](#attributes-recipes-apache-deflate) | 
| [dir ](#attributes-recipes-apache-dir) | [document\$1root ](#attributes-recipes-apache-doc-root) | [群組 ](#attributes-recipes-apache-group) | 
| [hide\$1info\$1headers ](#attributes-recipes-apache-hide) | [icondir ](#attributes-recipes-apache-icondir) | [init\$1script ](#attributes-recipes-apache-init-script) | 
| [keepalive ](#attributes-recipes-apache-keep) | [keepaliverequests ](#attributes-recipes-apache-keep-requests) | [keepalivetimeout ](#attributes-recipes-apache-keep-timeout) | 
| [lib\$1dir ](#attributes-recipes-apache-lib-dir) | [libexecdir ](#attributes-recipes-apache-libexecdir) | [listen\$1ports ](#attributes-recipes-apache-ports) | 
| [log\$1dir ](#attributes-recipes-apache-log-dir) | [logrotate 屬性](#attributes-recipes-apache-log) | [pid\$1file ](#attributes-recipes-apache-pidfile) | 
| [prefork 屬性](#attributes-recipes-apache-prefork) | [serversignature ](#attributes-recipes-apache-sig) | [servertokens ](#attributes-recipes-apache-tokens) | 
| [timeout ](#attributes-recipes-apache-timeout) | [traceenable ](#attributes-recipes-apache-trace) | [user ](#attributes-recipes-apache-user) | 
| [version](#attributes-recipes-apache-version) | [worker 屬性](#attributes-recipes-apache-worker) |  | 

**binary **  <a name="attributes-recipes-apache-bin"></a>
Apache 二進位檔的位置 (字串)。預設值為 `'/usr/sbin/httpd'`。  

```
node[:apache][:binary]
```

**contact **  <a name="attributes-recipes-apache-contact"></a>
電子郵件聯絡人 (字串)。預設值是虛擬地址 `'ops@example.com'`。  

```
node[:apache][:contact]
```

**deflate\$1types**  <a name="attributes-recipes-apache-deflate"></a>
引導 `mod_deflate` 啟用受瀏覽器支援之指定 MIME 類型的壓縮 (字串清單)。預設值如下：  

```
['application/javascript',
 'application/json',
 'application/x-javascript',
 'application/xhtml+xml',
 'application/xml',
 'application/xml+rss',
 'text/css',
 'text/html',
 'text/javascript',
 'text/plain',
 'text/xml']
```
壓縮可能會引發安全風險。若要完全停用壓縮，請設定此屬性如下：  

```
node[:apache][:deflate_types] = []
```

```
node[:apache][:deflate_types]
```

**dir **  <a name="attributes-recipes-apache-dir"></a>
伺服器的根目錄 (字串)。預設值如下：  
+ Amazon Linux 和 Red Hat Enterprise Linux (RHEL)：`'/etc/httpd'`
+ Ubuntu：`'/etc/apache2'`

```
node[:apache][:dir]
```

**document\$1root **  <a name="attributes-recipes-apache-doc-root"></a>
文件根 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'/var/www/html'`
+ Ubuntu：`'/var/www'`

```
node[:apache][:document_root]
```

**群組 **  <a name="attributes-recipes-apache-group"></a>
群組名稱 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'apache'`
+ Ubuntu：`'www-data'`

```
node[:apache][:group]
```

**hide\$1info\$1headers **  <a name="attributes-recipes-apache-hide"></a>
是否省略 HTTP 標頭中的版本和模組資訊 (`'true'`/`'false'`) (字串)。預設值為 `'true'`。  

```
node[:apache][:hide_info_headers]
```

**icondir **  <a name="attributes-recipes-apache-icondir"></a>
圖示目錄 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'/var/www/icons/'`
+ Ubuntu：`'/usr/share/apache2/icons'`

```
node[:apache][:icondir]
```

**init\$1script **  <a name="attributes-recipes-apache-init-script"></a>
初始化指令碼 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'/etc/init.d/httpd'`
+ Ubuntu：`'/etc/init.d/apache2'`

```
node[:apache][:init_script]
```

**keepalive **  <a name="attributes-recipes-apache-keep"></a>
是否啟用持續連線 (字串)。可能的值為 `'On'` 和 `'Off'` (字串)。預設值為 `'Off'`。  

```
node[:apache][:keepalive]
```

**keepaliverequests **  <a name="attributes-recipes-apache-keep-requests"></a>
Apache 會同時處理的持續連線請求數目上限 (數值)。預設值為 `100`。  

```
node[:apache][:keepaliverequests]
```

**keepalivetimeout **  <a name="attributes-recipes-apache-keep-timeout"></a>
Apache 等待請求的時間，之後會關閉連線 (數值)。預設值為 `3`。  

```
node[:apache][:keepalivetimeout]
```

**lib\$1dir **  <a name="attributes-recipes-apache-lib-dir"></a>
包含物件程式碼程式庫的目錄 (字串)。預設值如下：  
+ Amazon Linux (x86)：`'/usr/lib/httpd'`
+ Amazon Linux (x64) 和 RHEL：`'/usr/lib64/httpd'`
+ Ubuntu：`'/usr/lib/apache2'`

```
node[:apache][:lib_dir]
```

**libexecdir **  <a name="attributes-recipes-apache-libexecdir"></a>
包含可執行程式的目錄 (字串)。預設值如下：  
+ Amazon Linux (x86)：`'/usr/lib/httpd/modules'`
+ Amazon Linux (x64) 和 RHEL：`'/usr/lib64/httpd/modules'`
+ Ubuntu：`'/usr/lib/apache2/modules'`

```
node[:apache][:libexecdir]
```

**listen\$1ports **  <a name="attributes-recipes-apache-ports"></a>
伺服器接聽的連接埠清單 (字串清單)。預設值為 `[ '80','443' ]`。  

```
node[:apache][:listen_ports]
```

**log\$1dir **  <a name="attributes-recipes-apache-log-dir"></a>
日誌目錄 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'/var/log/httpd'`
+ Ubuntu：`'/var/log/apache2'`

```
node[:apache][:log_dir]
```

**logrotate 屬性**  <a name="attributes-recipes-apache-log"></a>
這些屬性指定如何輪換日誌檔案。    
**delaycompress **  <a name="attributes-recipes-apache-log-delay"></a>
是否將已關閉的日誌檔案壓縮延遲到下一個輪換週期開始 (`'true'`/`'false'`) (字串)。預設值為 `'true'`。  

```
node[:apache][:logrotate][:delaycompress]
```  
**群組 **  <a name="attributes-recipes-apache-log-group"></a>
日誌檔案的群組 (字串)。預設值為 `'adm'`。  

```
node[:apache][:logrotate][:group]
```  
**模式 **  <a name="attributes-recipes-apache-log-mode"></a>
日誌檔案的模式 (字串)。預設值為 `'640'`。  

```
node[:apache][:logrotate][:mode]
```  
**owner **  <a name="attributes-recipes-apache-log-owner"></a>
日誌檔案的擁有者 (字串)。預設值為 `'root'`。  

```
node[:apache][:logrotate][:owner]
```  
**rotate **  <a name="attributes-recipes-apache-log-rotate"></a>
輪換週期次數，之後會移除已關閉的日誌檔案 (字串)。預設值為 `'30'`。  

```
node[:apache][:logrotate][:rotate]
```  
**schedule **  <a name="attributes-recipes-apache-log-schedule"></a>
輪換排程 (字串)。可能的值如下：  
+ `'daily'`
+ `'weekly'`
+ `'monthly'`
預設值為 `'daily'`。  

```
node[:apache][:logrotate][:schedule]
```

**pid\$1file **  <a name="attributes-recipes-apache-pidfile"></a>
包含協助程式之處理序 ID 的檔案 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'/var/run/httpd/httpd.pid'`
+ Ubuntu：`'/var/run/apache2.pid'`

```
node[:apache][:pid_file]
```

**prefork 屬性**  <a name="attributes-recipes-apache-prefork"></a>
這些屬性指定預先分支處理組態。    
**maxclients **  <a name="attributes-recipes-apache-prefork-maxclients"></a>
要儲存的同步請求數目上限 (數值)。預設值為 `400`。  
僅針對執行 Amazon Linux 或 RHEL 的執行個體使用此屬性。如果您的執行個體執行 Ubuntu 14.04 LTS，請使用 [maxrequestworkers](#attributes-recipes-apache-prefork-maxrequestworkers)。

```
node[:apache][:prefork][:maxclients]
```  
**maxrequestsperchild **  <a name="attributes-recipes-apache-prefork-maxrequests"></a>
子伺服器處理序會處理的請求數目上限 (數值)。預設值為 `10000`。  

```
node[:apache][:prefork][:maxrequestsperchild]
```  
**maxrequestworkers**  <a name="attributes-recipes-apache-prefork-maxrequestworkers"></a>
要儲存的同步請求數目上限 (數值)。預設值為 `400`。  
此屬性只能用於執行 Ubuntu 14.04 LTS 的執行個體。如果您的執行個體正在執行 Amazon Linux 或 RHEL，請使用 [maxclients ](#attributes-recipes-apache-prefork-maxclients)。

```
node[:apache][:prefork][:maxrequestworkers]
```  
**maxspareservers **  <a name="attributes-recipes-apache-prefork-maxspare"></a>
閒置子伺服器處理序數目上限 (數值)。預設值為 `32`。  

```
node[:apache][:prefork][:maxspareservers]
```  
**minspareservers **  <a name="attributes-recipes-apache-prefork-minspare"></a>
閒置子伺服器處理序數目下限 (數值)。預設值為 `16`。  

```
node[:apache][:prefork][:minspareservers]
```  
**serverlimit **  <a name="attributes-recipes-apache-prefork-limit"></a>
可設定的處理序數目上限 (數值)。預設值為 `400`。  

```
node[:apache][:prefork][:serverlimit]
```  
**startservers **  <a name="attributes-recipes-apache-prefork-start"></a>
要在啟動時建立的子伺服器處理序數目 (數值)。預設值為 `16`。  

```
node[:apache][:prefork][:startservers]
```

**serversignature **  <a name="attributes-recipes-apache-sig"></a>
指定是否及如何設定伺服器產生文件尾端的頁尾 (字串)。可能的值為 `'On'`、`'Off'` 和 `'Email'`。預設值為 `'Off'`。  

```
node[:apache][:serversignature]
```

**servertokens **  <a name="attributes-recipes-apache-tokens"></a>
指定要包含在回應標頭中的伺服器版本資訊類型 (字串)：  
+ `'Full'`：完整資訊。例如，伺服器：Apache/2.4.2 (Unix) PHP/4.2.2 MyMod/1.2 
+ `'Prod'`：產品名稱。例如，伺服器：Apache
+ `'Major'`：主要版本。例如，伺服器：Apache/2
+ `'Minor'`：主要和次要版本。例如，伺服器：Apache/2.4
+ `'Min'`：最低版本。例如，伺服器：Apache/2.4.2
+ `'OS'`：作業系統版本。例如，伺服器：Apache/2.4.2 (Unix) 
預設值為 `'Prod'`。  

```
node[:apache][:servertokens]
```

**timeout **  <a name="attributes-recipes-apache-timeout"></a>
Apache 等待 I/O 的時間 (數值)。預設值為 `120`。  

```
node[:apache][:timeout]
```

**traceenable **  <a name="attributes-recipes-apache-trace"></a>
是否啟用 `TRACE` 請求 (字串)。可能的值為 `'On'` 和 `'Off'`。預設值為 `'Off'`。  

```
node[:apache][:traceenable]
```

**user **  <a name="attributes-recipes-apache-user"></a>
使用者名稱 (字串)。預設值如下：  
+ Amazon Linux 和 RHEL：`'apache'`
+ Ubuntu：`'www-data'`

```
node[:apache][:user]
```

**version**  <a name="attributes-recipes-apache-version"></a>
Apache 版本 (字串)。預設值如下：  
+ Amazon Linux: `2.2`
+ Ubuntu 14.04 LTS：`2.4`
+ RHEL: `2.4`

```
node[:apache][:version]
```

**worker 屬性**  <a name="attributes-recipes-apache-worker"></a>
這些屬性指定工作者處理序組態。    
**startservers **  <a name="attributes-recipes-apache-worker-start"></a>
要在啟動時建立的子伺服器處理序數目 (數值)。預設值為 `4`。  

```
node[:apache][:worker][:startservers]
```  
**maxclients **  <a name="attributes-recipes-apache-worker-maxclients"></a>
要儲存的同步請求數目上限 (數值)。預設值為 `1024`。  

```
node[:apache][:worker][:maxclients]
```  
**maxsparethreads **  <a name="attributes-recipes-apache-worker-maxspare"></a>
閒置執行緒數目上限 (數值)。預設值為 `192`。  

```
node[:apache][:worker][:maxsparethreads]
```  
**minsparethreads **  <a name="attributes-recipes-apache-worker-minspare"></a>
閒置執行緒數目下限 (數值)。預設值為 `64`。  

```
node[:apache][:worker][:minsparethreads]
```  
**threadsperchild **  <a name="attributes-recipes-apache-worker-threads"></a>
每個子處理序的執行緒數目 (數值)。預設值為 `64`。  

```
node[:apache][:worker][:threadsperchild]
```  
**maxrequestsperchild **  <a name="attributes-recipes-apache-worker-maxreq"></a>
子伺服器處理序會處理的請求數目上限 (數值)。預設值為 `10000`。  

```
node[:apache][:worker][:maxrequestsperchild]
```