Linux伺服器---apache配置檔案

夏末18844發表於2018-11-23

Apache  配置檔案

Apache  的配置檔案預設路徑是“  /etc/httpd/conf/httpd.conf  ”,編輯該檔案就可以修改Apache的配置     

、設定網頁主目錄,引數DocumentRoot就是網頁存放的主目錄。開啟配置檔案httpd.conf,查詢DocumentRoot(大約292行)

[root@localhost ~]#   gedit   /etc/httpd/conf/httpd.conf 

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

DocumentRoot "/var/www/html"   //  當前預設是在  "/var/www/html"  目錄下,所有的網頁必須放在這裡 

、設定連線埠,透過引數listen來設定連線的埠,預設80.(大約136行)

[root@localhost ~]#   gedit   /etc/httpd/conf/httpd.conf 

# Listen: Allows you to bind Apache to specific IP addresses and/or

# ports, in addition to the default. See also the <VirtualHost>

# directive.

#

# Change this to Listen on specific IP addresses as shown below to 

# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)

#

#Listen 12.34.56.78:80

Listen 80

、設定連線超時,引數timeout,當連線超過一定的空閒時間,就會自動斷開。(大約68行)

# Timeout: The number of seconds before receives and sends time out.

#

Timeout 60

、設定字符集,引數  AddDefaultCharset  ,建議最好設定utf-8,這是通用的。(大約753行)

# Specify a default charset for all content served; this enables

# interpretation of all content as UTF-8 by default.  To use the 

# default browser choice (ISO-8859-1), or to allow the META tags

# in HTML content to override this choice, comment out this

# directive:

#

AddDefaultCharset UTF-8

、設定伺服器名稱,引數ServerName。這是伺服器的域名,必須有dns解析才可以訪問。如果你沒有合法的域名,那麼只能透過ip地址來訪問

# ServerName gives the name and port that the server uses to identify itself.

# This can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#

# If this is not set to valid DNS name for your host, server-generated

# redirections will not work.  See also the UseCanonicalName directive.

#

# If your host doesn't have a registered DNS name, enter its IP address here.

# You will have to access it by its address anyway, and this will make 

# redirections work in a sensible way.

#

#ServerName

、設定keepalive,提高網路效率,預設是關閉的。(大約76行)

# KeepAlive: Whether or not to allow persistent connections (more than

# one request per connection). Set to "Off" to deactivate.

#

KeepAlive Off

、設定keepaliverequest,設定為0 的時候沒有限制,不過最好還是用預設值,或者自己根據情況來改變。(大約83行)

# MaxKeepAliveRequests: The maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend ou leave this number high, for maximum performance.

#

MaxKeepAliveRequests 100                          

  轉自 http://blog.itpub.net/29270124/viewspace-2220980/如有侵權,聯絡刪除。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31557905/viewspace-2221467/,如需轉載,請註明出處,否則將追究法律責任。

相關文章