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                          

Linux服务器---apache配置文件的更多相关文章

  1. Linux服务器---apache支持cgi

    Apache支持cgi  1.打开Apache配置文件httpd.conf,搜索“cgi”,找到下面的一段,去掉“addhandler”前面的“#“,这样就开启了Apache的cgi功能 [root@ ...

  2. centos linux服务器apache+mysql环境访问慢优化方法

    查找软件安装目录:find / -name 软件名称 一.优化apache配置增加MaxClients的值 默认情况下,2.0及以上apache版本MaxClients的值为256,对于中大型应用访问 ...

  3. Linux服务器---apache支持SSL

    Apache支持ssl 1.检测是否安装ssl模块,如果没有就安装 [root@localhost cgi-bin]# rpm -qa | grep mod_ssl           //查看是否安 ...

  4. linux服务器apache 一个IP,一个端口,建立多个网站的方法。

    找到apache-tomcat-6.0.14\conf\server.xml ,再services 后面添加此段代码: Xml代码 <!-- 此处  新增的项目配置-->  <Ser ...

  5. [linux]服务器apache配置vhost

    官网示例: http://httpd.apache.org/docs/current/vhosts/examples.html

  6. Atitit. 软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动、停止、重启

    Atitit.   软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动.停止.重启 可以通过"netstat -anp" ...

  7. linux 下 apache相关;启动、停止、重启命令;配置文件位置等等

    linux 下 apache启动.停止.重启命 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/usr/l ...

  8. Linux服务器部署系列之一—Apache篇(下)

    接上篇 linux服务器部署系列之一—Apache篇(上)    四.管理日志文件 Apache日志分为访问日志和错误日志两种: 1)访问日志 用于记录客户端的访问信息,文件名默认为access_lo ...

  9. Apache配置文件服务器

    配置Apache文件服务器: apache配置文件服务器httpd.conf中这两个模块必须不被注释LoadModule autoindex_module modules/mod_autoindex. ...

随机推荐

  1. 7.22 python面试题

    2018-7-22 16:32:24 把面试题敲完了,,好强悍! Python 10期考试题 1.常用字符串格式化有那些?并说明他们的区别 # format 直接调用函数 # %s 语法塘 # %r ...

  2. git 提示:fatal: remote origin already exists. 错误解决

    今天git连接远程库的时候出现fatal: remote origin already exists. 这个错误 大概是之前连接过别的库吧 然后我们的解决办法就是删除之前的连接 1.删除git远程仓库 ...

  3. PLSQL过程创建和调用

    存储过程 创建过程范例 create or replace procedure pro_kingsql_p1( p_one in varchar2,--可以传入参数 p_two out varchar ...

  4. Python开发【Tornado】:搭建文件下载服务、音频文件播放

    Tornado 如何做文件下载 要求:浏览器输入url地址,直接弹窗提示下载 Tornado服务端,搭建文件下载服务 #!/usr/bin/env python # -*- coding:utf-8 ...

  5. Hibernate错误

    1.Field 'id' doesn't have a default value 原来是我的数据设计的时候,把主键的类型定义为int的,原本想是用自增的方式来的,可是由于自己的粗心,写sql语句的时 ...

  6. sql server字符串中怎么添加换行?

    换行/回车,可以使用CHAR函数处理,比如: 1 insert into tbtest (text) values ('abc' + char(13)+char(10) + 'def') 主要还是要看 ...

  7. 前端 html input标签 disable 属性

    该属性只要出现在标签中,表示禁用该控件 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  8. xss跨站脚本攻击及xss漏洞防范

    xss跨站脚本攻击(Cross Site Scripting,因与css样式表相似故缩写为XSS).恶意攻击者往Web页面里插入恶意Script代码,当用户浏览该页之时,嵌入其中Web里面的Scrip ...

  9. druid部署

    Quickstart单机测试 http://druid.io/docs/0.10.1/tutorials/quickstart.html (1)Getting started 下载安装Druid: c ...

  10. 使用block的好处

    1 使用block 可以轻松地绑定各处代码块,使用delete 结构是分散的,不利于变量之间传值,不像block可以随意地获取变量值. 2.使用block可以方便执行异步代码,作为异步处理回调. In ...