1.获取软件: http://httpd.apache.org/ httpd-2.2.21.tar.gzhtml
2.安装步骤:apache
解压源文件:app
1 tar zvxf httpd-2.2.21.tar.gz
2 cd httpd-2.2.21
3 ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
4 make
5 make install
运行./configure 命令进行编译源代码,编辑器
--prefix=/usr/local/apach2 是设置编译安装到的系统目录,ide
--enable-s 参数是使httpd服务可以动态加载模块功能,post
--enable-rewrite 是使httpd服务具备网页地址重写功能。url
3.启动apache:code
/usr/local/apache2/bin/apachectl startserver
4.将apache加入到系统服务,用service命令来控制apache的启动和中止htm
grep -v "#" /usr/local/apache2/bin/apachectl > /etc/init.d/apache
vi /etc/init.d/apache
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
chmod +x /etc/init.d/apache
chkconfig --add apache
chkconfig --list apache
apache 0:off 1:off 2:on 3:on 4:on 5:on 6:off
代表apache服务已经生效,在二、三、四、5运行级别随系统启动而自动启动,之后能够使用service命令控制Apache的启动和中止。