本文基于centos6.6系统进行搭建: 准备前的工作: 1.修改selinux配置文件(/etc/sysconfig/selinux) (1)把SELINUX=enforcing注释掉 (2)并添加SELINUX=disabled 2.关闭防火墙 #service iptables stop 如今,Linux在Web应用越来越广,许多企业都采用Linux来搭建Web服务器,这样即节省了购买正版软件的费用,而且还能够提高服务器的安全性。 一、开始搭建 1、安装Apache #yum install httpd 2、启动 方法一:service httpd start 方法二:/etc/init.d/httpd start 浏览器输入:http://ip,应该看到Apache的测试页

3、设置开机启动 方法一:chkconfig --levels 235 httpd on 方法二:chkconfig httpd on //Apache的默认文档根目录是在CentOS上的/var/www/html 目录 ,配置文件是/etc/httpd/conf/httpd.conf。 二、配置文件详解(etc/httpd.conf) DirectoryIndex index.html index.html.var #设置网站默认文档 Include conf.d/*.conf #将指定文件包含进来 User apache #设置运行apache服务的用户 Group apache #设置运行apache服务的组 ServerAdmin root@localhost #设置管理员的邮箱,当apache服务有问题时会发邮件通知管理员 DocumentRoot "/var/www/html" #设置存放网页的根目录位置 ServerRoot "/etc/httpd" #指定服务器主配置文件和日志文件的位置 Timeout 60 #在指定时间内没有收到或发出任何数据则断开连接,单位为秒 KeepAlive On #是否启用长连接 MaxKeepAliveRequests 100 #当启用长连接时,一次连接最多能相应的请求数量 KeepAliveTimeout 15 #启用长连接时,指定一次连接中相邻两个请求的最大时间间隔,超过这个时间则会断开连接