需要下载的包
apr-1.5.0.tar.gz
apr-util-1.5.3.tar.gz
pcre-8.33.tar.gz
httpd-2.4.9.tar.gz
我是统一放到/usr/下解压
安装apr-1.5.0
安装apr-util-1.5.3
注意在执行 ./configure --prefix=/usr/local/apr-util --with- apr=/usr/local/apr/bin/apr-1-config出现cannot install `libaprutil-1.la' to a directory not ending in /usr/local/apr/lib
执行 make clean
安装pcre-8.33
注意在执行./configure --prefix=/usr/local/pcre 出现You need a C++ compiler for C++ support时
执行 yum install -y gcc gcc-c++
安装httpd-2.4.9
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
make
make install
修改: /usr/local/apache2/conf
用记事本打开httpd.conf
将里面的#ServerName www.example.comt:80注释去掉即可,把www.example.com改为localhost
再执行service httpd start
然后可以通过浏览器访问http://localhost:80,如果页面显示“Itworks!”,即表示apache已安装并启动成功。
添加到启动项
解决httpd: 未被识别的服务
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd
在开头的#!/bin/sh 下面加上
#chkconfig: 2345 85 15
chkconfig --add httpd 添加httpd服务
yum install lynx -y
执行service httpd status 出现
service httpd status
Not Found
The requested URL /server-status was not found on this server.
暂未解决
重启Apache
service httpd restart
至此apache服务器软件安装完毕
=====================以下是网上资料=====================
进入/usr/local/apache2/conf目录,运行如下命令修改配置文件
vim httpd.conf
a) 1去掉下面语句前的#
LoadModulephp5_module modules/libphp5.so
如果没有词句,可添加到已有的LoadModule语句下
b) 修改邮箱
修改为自己的邮箱ServerAdmin xxx@gmail.com
修改服务器名为本机ip地址如下:ServerName192.168.1.191:80
c) 修改首页索引
修改首页索引文件如下(首页为index.php或index.html):
DirectoryIndexindex.php index.html
d) AddType修改
添加如下AddType到已有的AddType下面(没有下面语句将不能解析php文本)
AddTypeapplication/x-httpd-php .php .phtml .php3 .inc
运行命令
vi /usr/local/apache/conf/extra/httpd-info.conf将
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from .example.com </Location>
改成
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 </Location>
参考http://hi.baidu.com/life_to_you/item/420889fd3ec7810884d278c8