CentOS5源代码编译安装apache2.2.21

来源:互联网 发布:pc打电话软件 编辑:程序博客网 时间:2024/05/22 13:29
+Linux+Apache+Mysql+PHP典型配置 (整理篇) http://www.chinaunix.net/jh/4/215402.html
+Linux + Apache + MySQL + PHP环境搭建 http://commandos.blog.51cto.com/154976/124452
+CentOS 5.x源码编译安装LAMP(Apache MySQL PHP) http://www.centos.bz/2011/09/centos-compile-lamp-apache-mysql-php/
+怎样查看apache编译时使用的参数? http://bbs.chinaunix.net/thread-1216141-1-1.html
+查看apache,php,mysql编译参数 http://www.baalchina.net/2009/08/php-mysql-apache-configure/

所安装版本: 2.2.21 。它是 2.2.X 最后一个版本。
*注:apache1.* 和 apache2.* 两个版本的编译命令是有所区别的。

先关闭 SELinux(并非必须,但不做容易出错。)

安装依赖包:
yum -y install zlib-devel openssl-devel
否则编译时会报错:
configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

+apache编译问题centos http://hi.baidu.com/duking/blog/item/485d216dc1beccf342169465.html

若centos预装了apache,先卸载:
rpm -e mod_ssl
rpm -e mod_python
rpm -e mod_perl
rpm -e php
rpm -e webalizer
rpm -e gnome-user-share
rpm -e httpd-manual
rpm -e system-config-httpd
rpm -e httpd

若系统编译安装过apache,也需要先卸载:
假设已安装 apache2 并名为 httpd 加入系统服务及开机启动。安装目录为 /usr/local/apache2
#取消自启动
chkconfig httpd off
#删除自启动
chkconfig --del httpd
#停止 httpd
service httpd stop
#删除 httpd 服务文件
rm /etc/init.d/httpd
#删除安装目录
rm -r /usr/local/apache2
#若 apache2 不是安装在一个目录,而是分散的话,用 whereis 找出所有目录,遂一删除:
whereis apache2

+linux中chkconfig命令详解 http://blog.chinaunix.net/space.php?uid=12814440&do=blog&id=2914632
+Linux 的系统服务及其配置 http://www.centos.bz/2011/10/linux-system-service-configure/

http://httpd.apache.org/download.cgi
下载
httpd-2.2.21.tar.gz
http://labs.renren.com/apache-mirror//httpd/httpd-2.2.21.tar.gz
解压到 /srv/
cd /srv/
tar xf httpd-2.2.21.tar.gz
#进入源代码目录
cd /srv/httpd-2.2.21
#配置
./configure --prefix=/usr/local/apache2 --enable-module=so --enable-module=rewrite --enable-mods-shared=all
#编译与安装
make
make install

配置成功后最后显示的是:
config.status: executing default commands

编译参数说明:
--prefix=/usr/local/apache2 #安装目录
--enable-module=so #编译 so 模块
--enable-module=rewrite #编译 rewrite 模块
--enable-mods-shared=all #编译其它所有模块为DSO(*.so文件)
--enable-deflate 启用 mod_deflate ,压缩传输
--with-apr=/usr/bin 需要 apr-devel

另一台服务器上的编译参数:
./configure --prefix=/usr/local/apache2 --with-mpm-prefork --with-ssl --enable-ssl --enable-deflate --enable-mods-shared=most

+手册 # 编译与安装 http://lamp.linux.gov.cn/Apache/ApacheMenu/install.html
// 基本能解答大部份编译与安装过程中的问题。
+手册 # 在Microsoft Windows中使用Apache http://lamp.linux.gov.cn/Apache/ApacheMenu/platform/windows.html
+手册 # configure - 配置源代码树 http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html
// 可以找到所有编译参数说明
+新安装的apache,如何检查是否安装成功? http://bbs.chinaunix.net/thread-1925106-1-1.html
+如何检查apache在linux下安装成功?? http://zhidao.baidu.com/question/345872698.html?seed=0

接着,通过修改PREFIX/conf/目录(PREFIX为安装目录,下同)下的配置文件,来配置Apache HTTP服务器。

vi PREFIX/conf/httpd.conf

启动Apache:
PREFIX/bin/apachectl -k start
停止Apache:
PREFIX/bin/apachectl -k stop

安装为服务
[root@CentOS httpd-2.2.17]# /usr/local/apache2/bin/apachectl start 启动
[root@CentOS httpd-2.2.17]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

设置为开机启动

[root@CentOS httpd-2.2.17]# vi /etc/init.d/httpd
#!/bin/sh
#chkconfig:3 4 5
#description:start and stop the http server
添加以上2行。其实有chkconfig跟下面的description这2个就可以,后面随便写吧。或这样写
#chkconfig:3 4 5
#description:http
这样随便写就可以了。为了chkconfig这上命令
[root@CentOS httpd-2.2.17]#chkconfig --add httpd
[root@CentOS httpd-2.2.17]#service httpd restart

+安装apache问题 http://topic.csdn.net/u/20101024/13/f3a7f929-7e69-4f9d-9b7e-a95f0a273bcc.html

配置防火墙

+Linux下apache服务启动,本机访问正常,局域网内其他机器无法访问(已解决) http://jay-sunlei.blog.163.com/blog/static/12401819120108251743470/

+apache的静态/动态编译在apache+php+mysql的应用 http://www.5ilinux.com/apache01.html
原创粉丝点击