当前位置: 首页 > Linux

从源码安装apache(遇到问题及解决方法附后)

时间:2023-04-06 01:27:24 Linux

版本说明CentOS版本:CentOSrelease6.8(Final)安装包版本:httpd-2.4.29.tar.gzapr-1.6.3.tar.gzapr-util-1.6.1pcre-8.41.tar.gz安装过程路径说明安装包一般放在:/usr/local/src安装路径一般为:/usr/local安装(使用root用户)安装必要applications#yuminstall-ygccgcc-c++#yuminstall-yexpat-devel//错误1??#yuminstall-ypcre-devel//错误2#yuminstall-yopenssl-devel//错误3#yuminstall-ylibxml2-devel//error4aprinstall#tarzvxfapr-1.6.3.tar.gz#cdapr-1.6.3#./configure--prefix=/usr/local/apr/#make#makeinstallapr-utilinstall#tarzvxfapr-util-1.6.1.tar.gz#cdapr-util-1.6.1#./configure--prefix=/usr/local/apr-util/--with-apr=/usr/local/apr/#make#makeinstallpcreinstall#tarzvxfpcre-8.41.tar.gz#cdpcre-8.41#./configure--prefix=/usr/local/pcre/#make#makeinstallapacheinstall#./配置\--prefix=/usr/local/apache2.4\--sbindir=/usr/local/apache2.4/sbin\--with-apr=/usr/local/apr/\--with-apr-util=/usr/本地/apr-util\--with-pcre=/usr/local/pcre/\--enable-ssl\--with-ssl=shared\--enable-proxy=shared\--enable-so\--enable-mods-shared=all#make#makeinstallstartandview将命令复制到服务级别#cp/usr/local/apache2.4/sbin/httpd/etc/rc.d/init.dstart#servicehttpd-kstartstop#servicehttpd-kstoprestart#servicehttpd-krestart查看状态#servicehttpd-T通过80端口查看状态#sudonetstat-antp|grep80通过进程查看#ps-ef|grephttpd访问查看是否访问启动成功:http://ip:80出现了!恭喜你已经成功开启https访问生成证书#cd/usr/local/apache2.4/conf#opensslreq-new-x509-nodes-outserver.crt-keyoutserver.keyedithttpd.conf,打开以下注释包括conf/extra/httpd-ssl.confLoadModulessl_modulemodules/mod_ssl.soLoadModulesocache_shmcb_modulemodules/mod_socache_shmcb.so重新启动apache以查看和访问端口443:#sudonetstat-antpgrep443access:https://ip:443,如果有效!恭喜你,你成功了。实现与tomcat集成编辑httpd.conf,打开如下注释LoadModuleproxy_ajp_modulemodules/mod_proxy_ajp.soLoadModuleproxy_ajp_modulemodules/mod_proxy_ajp.so通过443端口跳转编辑/conf/extra/httpd-ssl.conf(添加跳转443虚拟机tomcat)ProxyPassajp://127.0.0.1:#tomcat的ajp端口#/apache_tomcat_test重启apache访问:https://ip:443/apache_tomcat_test跳转通过80端口(使用https,关闭http访问)编辑/conf/extra/httpd-ssl.conf(添加跳转tomcat到80虚拟机)SSLEngineonSSLCertificateFile"/usr/local/apache2/conf/server.crt"SSLCertificateKeyFile"/usr/local/apache2/conf/server.key"ProxyPassajp://127.0.0.1:#tomcat的ajp端口#/apache_tomcat_test重启apache访问:https://ip:80/apache_tomcat_test安装报错及报错1apr-util-1.6.1errorwhencompilingmake[1]:Enteringdirectory`/usr/local/apr-util-1.6.1'/bin/sh/usr/local/apr//build-1/libtool--silent--mode=compilegcc-g-O2-pthread-DHAVE_CONFIG_H-DLINUX-D_REENTRANT-D_GNU_SOURCE-I/usr/local/apr-util-1.6.1/include-I/usr/local/apr-util-1.6.1/include/private-I/usr/local/apr//include/apr-1-oxml/apr_xml.lo-cxml/apr_xml.c&&touchxml/apr_xml.loxml/apr_xml.c:35:19:error:expat.h:Nosuchfileordirectoryxml/apr_xml.c:66:错误:'XML_Parser'xml/apr_xml.c之前的预期说明符限定符列表:在函数'cleanup_parser':xml/apr_xml.c:364:错误:'apr_xml_parser'没有名为'xp'的成员xml/apr_xml.c:365:错误:“apr_xml_parser”没有名为“xp”的成员'在'*'之前tokenxml/apr_xml.c:在函数'apr_xml_parser_create':xml/apr_xml.c:401:error:'apr_xml_parser'hasnomembernamed'xp'xml/apr_xml.c:402:error:'apr_xml_parser'没有名为“xp”xml/apr_xml.c:410的成员:错误:“apr_xml_parser”没有名为“xp”xml/apr_xml.c:411的成员:错误:“apr_xml_parser”没有成员名称d'xp'xml/apr_xml.c:412:错误:'apr_xml_parser'没有名为'xp'xml/apr_xml.c:424的成员:错误:'apr_xml_parser'没有名为'xp'xml/apr_xml.c的成员:424:error:'default_handler'undeclared(firstuseinthisfunction)xml/apr_xml.c:424:error:(Eachundeclaredidentifierisreportedonceoncexml/apr_xml.c:424:error:foreachfunctionitappearsin.)xml/apr_xml.c:在函数“do_parse”中:xml/apr_xml.c:434:错误:“apr_xml_parser”没有名为“xp”的成员xml/apr_xml.c:438:错误:“apr_xml_parser”没有名为“的成员”xp'xml/apr_xml.c:442:错误:'apr_xml_parser'没有名为'xp_err'的成员xml/apr_xml.c:442:错误:'apr_xml_parser'没有名为'xp'的成员'apr_xml_parser_geterror':xml/apr_xml.c:500:错误:'apr_xml_parser'没有名为'xp_err'的成员xml/apr_xml.c:500:错误:'apr_xml_parser'没有名为'xp_err'的成员[1]:*[xml/apr_xml.lo]Error1make[1]:Leavingdirectory`/usr/local/apr-util-1.6.1'make:*[all-recursive]Error1原因:缺少expat库,估计没有提供apr-util-1.6,apr-util-1.5没有这个错误解决方法:#yuminstall-yexpat-develerror2apache./configureerrorcheckingforpcre-config...falsereason:missingpcrelibrary解决方法:#yum-yinstallpcre-develerror3apache./configureerrorcheckingforOpenSSLversion>=0.9.8a...FAILEDconfigure:WARNING:OpenSSLversionistooold原因:OpenSSLversionisold解决方法:#yuminstall-yopenssl-develerror4errorduringapachemake/usr/local/apr-util//lib/libaprutil-1.so:undefinedreferenceto`XML_ParserCreate'/usr/local/apr-util//lib/libaprutil-1.so:对`XML_GetErrorCode'的未定义引用/usr/local/apr-util//lib/libaprutil-1.so:对`XML_SetUserData'的未定义引用/usr/local/apr-util//lib/libaprutil-1.so:未定义对“XML_ErrorString”的引用/usr/local/apr-util//lib/libaprutil-1.so:未定义对“XML_SetEntityDeclHandler”的引用/usr/local/apr-utilutil//lib/libaprutil-1.so:对`XML_ParserFree'的未定义引用/usr/local/apr-util//lib/libaprutil-1.so:对`XML_Se的未定义引用tElementHandler'/usr/local/apr-util//lib/libaprutil-1.so:对`XML_StopParser'的未定义引用/usr/local/apr-util//lib/libaprutil-1.so:对`XML_Parse'的未定义引用/usr/local/apr-util//lib/libaprutil-1.so:对`XML_SetCharacterDataHandler'的未定义引用collect2:ld返回1exitstatusmake[2]:*[htpasswd]Error1make[2]:Leavingdirectory`/usr/local/httpd-2.4.29/support'make[1]:*[all-recursive]Error1make[1]:Leavingdirectory`/usr/local/httpd-2.4.29/support'make:*[all-recursive]错误1原因:缺少xml相关的库,导致引用无效解决方法:#yuminstall-ylibxml2-devel注意:安装libxml2-devel后,需要删除apr-util,重新安装apache依赖的其他解释即可减少到1.5,就不会出现上面的错误了。apr-1.5.2apr-util-1.5.2pcre-8.41