天天看点

Apache安装

Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache

Apache官网www.apache.org

cd /usr/local/src/

apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows)

2.2的apr和2.4所依赖的apr版本是不一样的。Centos的yum安装的apr和2.4是不匹配的。所以需要自己编译

tar zxvf httpd-2.4.27.tar.gz

tar zxvf apr-util-1.5.4.tar.gz

tar zxvf apr-1.5.2.tar.gz

cd apr-1.6.3

./configure --prefix=/usr/local/apr

make && make install

cd /usr/local/src/apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

cd /usr/local/src/httpd-2.4.27

./configure \ //这里的反斜杠是脱义字符,加上它我们可以把一行命令写成多行

--prefix=/usr/local/apache2.4 \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--enable-so \ //支持动态扩展模块

--enable-mods-shared=most //绝大多数用到的模块都加载

/usr/local/apache2.4/bin/apachectl start //启动

cd /usr/local/apache2.4/

ls bin/httpd //二进制脚本

bin/httpd

ls conf/httpd.conf //配置文件

conf/httpd.conf

ls htdocs/ //访问页。默认网站

index.html

ls /usr/local/apache2.4/modules

/usr/local/apache2.4/bin/apachectl -M //apachectl脚本调用了二进制httpd文件

/usr/local/apache2.4/bin/httpd -M //查看加载的模块

so_module (static) //说明是在httpd里面的

http_module (static)

mpm_event_module (static)

authn_file_module (shared) //说明是扩展模块。是一个可以看到的.so文件在/usr/local/apache2.4/modules/下

问题!!make报错

collect2: error: ld returned 1 exit status

make[2]: [htpasswd] 错误 1

make[2]: 离开目录“/usr/local/src/httpd-2.4.27/support”

make[1]: [all-recursive] 错误 1

make[1]: 离开目录“/usr/local/src/httpd-2.4.27/support”

make: *** [all-recursive] 错误 1

解决办法:

cp -r apr-1.6.2  /usr/local/src/httpd-2.4.27/srclib/apr

cp -r apr-util-1.6.0  /usr/local/src/httpd-2.4.27/srclib/apr-util

#./configure --with-included-apr --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

#make &&make install

错误!!

1.xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录

#include <expat.h>

[root@lsx-02 apr-util-1.6.0]# yum list |grep 'expat.'

2.configure: error: no acceptable C compiler found in $PATH

yum install -y gcc

yum list |grep -i PCRE

yum install -y pcre-devel.x86_64

本文转自 虾米的春天 51CTO博客,原文链接:http://blog.51cto.com/lsxme/2050916,如需转载请自行联系原作者