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