Linux服務器---apache配置文件


Apache配置文件

      Apache的配置文件默認路徑是“/etc/httpd/conf/httpd.conf”,編輯該文件就可以修改Apache的配置     

1、設置網頁主目錄,參數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"目錄下,所有的網頁必須放在這里

2、設置連接端口,通過參數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

3、設置連接超時,參數timeout,當連接超過一定的空閑時間,就會自動斷開。(大約68行)

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

#

Timeout 60

4、設置字符集,參數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

5、設置服務器名稱,參數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 www.example.com:80

6、設置keepalive,提高網絡效率,默認是關閉的。(大約76行)

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

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

#

KeepAlive Off

7、設置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                          


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM