centos7源码安装Apache Web服务器基于2.0版本

apache官网 http://httpd.apache.org/apache

下载apache2.4.39版本vim

[root@localhost devdir]# wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
--2019-05-09 18:11:14--  http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在链接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:80... 已链接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9199150 (8.8M) [application/x-gzip]
正在保存至: “httpd-2.4.39.tar.gz”

100%[======================================>] 9,199,150   2.63MB/s 用时 3.3s   

2019-05-09 18:11:27 (2.63 MB/s) - 已保存 “httpd-2.4.39.tar.gz” [9199150/9199150])

[root@localhost devdir]#

安装apr apr-util pcre组件bash

清华大学开源软件镜像站app

https://mirrors.tuna.tsinghua.edu.cn/apache/ui

[root@localhost devdir]# wget -c https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.7.0.tar.gz
[root@localhost devdir]# wget -c https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@localhost devdir]# wget -c https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
[root@localhost devdir]# cd apr-1.7.0
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr/
[root@localhost apr-1.7.0]# make &&make install
[root@localhost apr-1.7.0]# cd ../
[root@localhost devdir]# tar -zxvf apr-util-1.6.1.tar.gz 

[root@localhost devdir]# cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
[root@localhost apr-util-1.6.1]# make &&make install

没有expat-devel致使的,果断yum install -y expat-devel

r//include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
 #include <expat.h>
                   ^
编译中断。
make[1]: *** [xml/apr_xml.lo] 错误 1
make[1]: 离开目录“/root/devdir/apr-util-1.6.1”
make: *** [all-recursive] 错误 1
[root@localhost apr-util-1.6.1]# 
[root@localhost apr-util-1.6.1]# cd ../
[root@localhost devdir]# wget -c https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
[root@localhost pcre-8.43]# tar -zxvf pcre-8.43.tar.gz 

[root@localhost devdir]# cd pcre-8.43
[root@localhost pcre-8.43]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.43]# make &&make install
安装httpd
[root@localhost devdir]# tar -zxvf httpd-2.4.39.tar.gz 
[root@localhost devdir]# cd httpd-2.4.39
[root@localhost httpd-2.4.39]# ./configure --prefix=/usr/local/httpd/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
[root@localhost httpd-2.4.39]# make &&make install
---------------------------------------
/usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] 错误 1
make[2]: 离开目录“/root/devdir/httpd-2.4.39/support”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/root/devdir/httpd-2.4.39/support”
make: *** [all-recursive] 错误 1
---------------------------------------
[root@localhost httpd-2.4.39]# ll srclib/
.deps        Makefile     Makefile.in  
[root@localhost httpd-2.4.39]# cp -r ../apr-1.7.0 srclib/
[root@localhost httpd-2.4.39]# cp -r ../apr-util-1.6.1 srclib/
[root@localhost httpd-2.4.39]# make &&make install
--------------------------------------------------
configure: Configuring Apache Portable Runtime library...
configure: 
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
-------------------------------------------------
[root@localhost httpd-2.4.39]# cd srclib/
[root@localhost srclib]# ls
apr-1.7.0  apr-util-1.6.1  Makefile  Makefile.in
[root@localhost srclib]# mv apr-util-1.6.1 apr-util
[root@localhost srclib]# mv apr-1.7.0/ apr
[root@localhost srclib]# cd ../
[root@localhost httpd-2.4.39]# ./configure --with-included-apr --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
[root@localhost httpd-2.4.39]# make &&make install
安装成功!!!
[root@localhost httpd-2.4.39]# ll /usr/local/httpd/bin/
ab            apxs          envvars-std   htdigest      logresolve
apachectl     checkgid      fcgistarter   htpasswd      rotatelogs
apr-1-config  dbmmanage     htcacheclean  httpd         
apu-1-config  envvars       htdbm         httxt2dbm     
[root@localhost httpd-2.4.39]# httpd -v
-bash: httpd: 未找到命令
[root@localhost httpd-2.4.39]# vim /etc/profile
[root@localhost httpd-2.4.39]# source /etc/profile
[root@localhost httpd-2.4.39]# httpd -v
Server version: Apache/2.4.39 (Unix)
Server built:   May  9 2019 19:06:11
[root@localhost httpd-2.4.39]#

Apache配置文件 vim /usr/local/httpd/conf/httpd.conf .net

启动apache apachectl startcode

配置多个虚拟主机xml

[root@localhost httpd-2.4.39]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf 
[root@localhost httpd-2.4.39]# 
 ip

相关文章
相关标签/搜索