#tar zxvf httpd-2.2.11.tar.gz
解压apache包,在当前目录下生成httpd-2.2.11
#cd httpd-2.2.11.tar.gz
进入httpd-2.2.11目录
#./configure –prefix=/usr/local/apache2 –enable-so -enable-mods-shared=most –enable-rewrite –enable-cache
其中的-enable要用空格连起来写
–prefix指定安装目录
–enable-so选项:让Apache可以支持DSO模式,注意,这里采用的是Apache2.0的语法。使用1.3版本的将其改为–enable-module=so。
–enable-mods-shared=most选项:告诉编译器将所有标准模块都编译为DSO模块。使用1.3版本的将其改为–enable-shared=max。此方式是动态加载所有模块,如果去掉-shared话,是静态加载所有模块。”most”表示大部分常用的模块,”all”表示所有模块(–enable-mods-shared=all)
–enable-rewrite(实现对动态网页地址的重写)选项:支持地址重写功能,使用1.3版本的将其改为–enable-module=rewrite。
#make;make install 编译并且安装
#cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
#service httpd start/stop
立即启动apache服务,重启后无效
开机自启动apache服务器
a:
echo “/usr/local/apache2/bin/apachectl start” >> /etc/rc.local
b:
vi /etc/rc.d/init.d/httpd (就是上面复制的文件)
添加入下code
# Comments to support chkconfig on Centos
# chkconfig: 2345 50 90
# description: Activates/Deactivates Apache Web Server
#description一定要有,否则httpd脚本就会出错
这样就可以通过chkconfig配置自启动了