一,下载的安装包:
1,httpd-2.4.9.tar.gz
2,apr-1.5.1.tar.bz2
3,apr-util-1.5.3.tar.bz2
APR(Apache portable Run-time libraries,Apache可移植运行库)主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库
二,准备安装环境
tar -jxvf apr-util-1.5.1.tar.bz2
tar -jxvf apr-1.4.6.tar.bz2
tar -jxvf httpd-2.4.4.tar.bz2
tar -zxvf pcre-8.32.tar.gz
1.安装C++
yum install gcc-c++ //安装C++编译环境
2.安装 APR
cd apr-1.4.6/
./configure --prefix=/usr/local/apr-1.4.6 //配置
make //编译
make test //测试
make install //安装
3.安装APR-UTIL
cd ../apr-util-1.5.1/
./configure --prefix=/usr/local/apr-util-1.5.1
./configure --prefix=/usr/local/apr-util-1.5.1 --with-apr=/usr/local/apr-1.4.6/
make
make test
make install
4.安装 PCRE
cd ../pcre-8.32/
./configure
make
make check
make install
5.安装apache
cd ../httpd-2.4.4/
./configure --prefix=/usr/local/apache --enable-mods-shared=all --with-apr=/usr/local/apr-1.4.6/ --with-apr-util=/usr/local/apr-util-1.5.1/ //--prefix指定安装路径,--enable-mods-shared启用所有支持的动态加载模块,--with-apr指定APR路径,--with-apr-util指定APR-util路径
make
make install
/usr/local/apache/bin/apachectl start //启动apache
重启
# /usr/local/apache2/bin/apachectl restart
如果报错说:Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
需要修改/usr/local/apache2/conf/httpd.conf在
#serverName www.example.com:80
这个位置修改为:
serverName localhost:80
防火墙配置
注意如果你希望在本地机器例如xp访问虚拟机的网页,如果是centos6需要修改防火墙启动80端口
/etc/sysconfig
[root@centos6 ~]# vim /etc/sysconfig/iptables
添加下面一行,打开防火墙80端口:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重启防火墙#/etc/init.d/iptables restart
查看CentOS防火墙信息:/etc/init.d/iptables status
关闭CentOS防火墙服务:/etc/init.d/iptables stop
三、注册apache为系统服务
cp /usr/local/apache/apachectl /etc/init.d/httpd //把apache启动脚本复制到系统脚本目录下
vi /etc/init.d/httpd在第一行下插入# chkconfig: 2345 85 35 //修改脚本用于在运行界别2345下自启动,并指定启动脚本序号为85,关闭脚本序号为35
chkconfig --add httpd //注册为自启动服务
四、修改防火墙设置
vi /etc/sysconfig/iptables //编辑iptables配置文件
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT //在适当位置插入
service iptables restart //重启防火墙服务
/#tar zxvf httpd-2.4.9.tar.gz
#cd ./httpd-2.2.22
#./configure --prefix=/usr/local/apache2/ --enable-proxy --enable-ssl --enable-cgi --enable-rewrite --enable-so --enable-module=so
#make
#make install
说明:如果make不成功,那么是configure不成,例如你缺少ssl组件,可以去掉
--enable-ssl
如果提示:make: *** 没有指明目标并且找不到 makefile。 停止。
则运行:yum -y install gcc
yum -y install gcc-c++
/
------------------------
开机加入自动启动服务
编辑rc.local文件
#vi /etc/rc.d/rc.local
加入如下启动命令
/usr/sbin/apachectl start
/etc/rc.d/init.d/mysqld start
/etc/rc.d/init.d/smb start
/usr/local/subversion/bin/svnserve -d
注意:我的这个路径是yum安装这些服务得到的路径,填写时要根据自己的安装路径,找不到可以借助whereis命令,主要是找到apachectl 、mysqld 、smb 这三个启动文件。
------------------------------------------
----------------------------------------
ab测试
#ab -n 1000 -c 10 http://localhost/
------------------------------------------
卸载apache
如果是源码安装
#rm -rf 你的apache安装路径
同样作用于其他
========================
httpd启用虚拟主机
#Include conf/extra/httpd-vhosts.conf
httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/www/"
<Directory />
#拒绝所有请求
# Deny from all
#是否显示列表
# Options Indexes FollowSymLinks
#是否启用rewrite
# AllowOverride all
========================
YUM方式安装的,这样卸载:#yum remove httpd
否则要用
#rpm -qa|grep httpd
一个个删除
# rpm -e ......