Apache是一个基金会名字,httpd才是我们需要安装的软件包,httpd早期的名字叫做Apache;
Apache官网www.apache.org
下载地址
2.2源码包: http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
2.4源码包: http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
apr: http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
apr-util: https://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以方便移植(Linux移植到Windows)
apache安装条件:必须先安装gcc包、pcre包、apr与apr-util;
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
wget https://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
tar zxvf apr-util-1.6.1.tar.gz
tar zxvf apr-1.6.3.tar.gz
tar zxvf httpd-2.4.29.tar.gz
cd apr-1.6.3/
./configure --prefix=/usr/local/apr
//检查下命令是否正常运行echo $?
make && make install
cd /usr/local/src/apr-util-1.6.1/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
告错:
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
那么就搜索提示的expat
yum list |grep -i expat
[root@shu-test apr-util-1.6.1]# yum list |grep -i expat
expat.x86_64 2.1.0-10.el7_3 @anaconda
expat-devel.x86_64 2.1.0-10.el7_3 @base
expat.i686 2.1.0-10.el7_3 base
expat-devel.i686 2.1.0-10.el7_3 base
expat-static.i686 2.1.0-10.el7_3 base
expat-static.x86_64 2.1.0-10.el7_3 base
[root@shu-test apr-util-1.6.1]#
安装expat-devel包
yum install -y expat-devel
cd /usr/local/src/httpd-2.4.29/
./configure --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
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
提示:缺少PCRE;
解决:查询与安装pcre
yum list |grep -i pcre
yum install -y pcre-devel
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] 错误 1
make[2]: 离开目录“/usr/local/src/httpd-2.4.29/support”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.29/support”
make: *** [all-recursive] 错误 1
解决方案:
删除文件,重新解压源码包安装,先复制文档,在configure后加上 “--with-included-apr”。再重新编译;
cd /usr/local/src/
cp -r apr-1.6.3 /usr/local/src/httpd-2.4.29/srclib/apr
cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.29/srclib/apr-util
cd /usr/local/src/httpd-2.4.29/
./configure --prefix=/usr/local/apache2.4 --with-included-apr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
make && make install
/usr/local/apache2.4/bin/apachectl start
查询httpd是否启动
ps aux |grep httpd
netstat -lntp
apache2.4文件夹下
conf文件夹:配置文件
htdocs:主页文件
logs文件夹:日志文件
modules:模块存放
查看apache调用的模块
/usr/local/apache2.4/bin/httpd -M
/usr/local/apache2.4/bin/apachectl -M
转载于:https://blog.51cto.com/shuzonglu/2073717