这篇文章给大家分享的是有关怎么通过源码编译的方式安装apache2.4的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。

本文档使用的源码包地址 链接:https://pan.baidu.com/s/110RWf3VC8J3oJhgYq5jU2w 提取码:pdc0

实战

[root@Jaking12~]#yuminstall-ygccpcrepcre-develexpat-develbzip2openssl-develzlib*libtool[root@Jaking12src]#rz[root@Jaking12src]#tarxvfapr-1.7.0.tar.gz[root@Jaking12src]#lsapr-1.7.0apr-1.7.0.tar.gz[root@Jaking12src]#cdapr-1.7.0[root@Jaking12apr-1.7.0]#./configure--prefix=/usr/local/apr[root@Jaking12apr-1.7.0]#make[root@Jaking12apr-1.7.0]#makeinstall[root@Jaking12apr-1.7.0]#cd..[root@Jaking12src]#rzrzwaitingtoreceive.zmodemtrl+Cȡ100%541KB541KB/s00:00:010Errors..[root@Jaking12src]#lsapr-1.7.0apr-1.7.0.tar.gzapr-util-1.6.1.tar.gz[root@Jaking12src]#tarxfapr-util-1.6.1.tar.gz[root@Jaking12src]#lsapr-1.7.0apr-1.7.0.tar.gzapr-util-1.6.1apr-util-1.6.1.tar.gz[root@Jaking12src]#cdapr-util-1.6.1[root@Jaking12apr-util-1.6.1]#./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr[root@Jaking12apr-util-1.6.1]#make[root@Jaking12apr-util-1.6.1]#makeinstall更多的选项可以通过./configure--help了解官方的编译选项文档http://httpd.apache.org/docs/current/programs/configure.html--prefix=/usr/local/apache--sysconfdir=/etc/httpd//指定配置文件在安装在哪个路径。如不指定,配置文件就在程序安装的目录;如指定/etc目录--with-apr=/usr/local/apr//指定依赖的apr路径。注意必须指明路径,否则编译时会自动去找/usr下的apr,而不是编译的高版本apr,下同--with-apr-util=/usr/local/apr-util--with-mpm=MPM//指定默认的[prefork|worker|event]如3种MPM模块都编译了,则通过此项指定默认使用哪种--with-pcre//依赖pcre库用于解决正则表达式问题。##安装pcre-devel(兼容Perl的正则表达式库)--enable-so//打开so模块,启用动态装载模块功能--enable-ssl//启用ssl功能。注意要先安装,https使用--enable-cgi//启用cgi功能,为非线程方式工作的mpm使用--enable-cgid//以线程工作(worker/event)的mpm使用--enable-rewrite//支持URL重写--enable-zlib//通用压缩机制--enable-module=most//[all|most|……]指定启用哪些模块。可指定具体的模块名,也可使用all表示启用所有模块,most表示启用大多数常用模块。一般使用most即可--enable-mpms-shared=all//启用MPM支持的模式,启用哪种mpm(prefork,worker,event),使用worker或event时要另外一种方式编译php(编译时使用了–enable-maintainer-zts选项)--enable-deflate//传输压缩机制,节约带宽提供对内容的压缩传输编码支持一般是html、js、css等内容的站点。使用此参数会大大提高传输速度提升访问者访问的体验。在生产环境中这是apache调优的一个重要选项之一[root@Jaking12apr-util-1.6.1]#cd..[root@Jaking12src]#rzrzwaitingtoreceive.zmodemtrl+Cȡ100%8983KB8983KB/s00:00:010Errors[root@Jaking12src]#lsapr-1.7.0apr-1.7.0.tar.gzapr-util-1.6.1apr-util-1.6.1.tar.gzhttpd-2.4.39.tar.gz[root@Jaking12src]#tarxfhttpd-2.4.39.tar.gz[root@Jaking12src]#lsapr-1.7.0apr-util-1.6.1httpd-2.4.39apr-1.7.0.tar.gzapr-util-1.6.1.tar.gzhttpd-2.4.39.tar.gz[root@Jaking12src]#cdhttpd-2.4.39[root@Jaking12httpd-2.4.39]#./configure--prefix=/usr/local/apache24--enable-so--enable-ssl--enable-cgi--enable-rewrite--with-zlib--with-pcre--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--enable-modules=most--enable-mods-shared=most--enable-mpms-shared=all--with-mpm=event[root@Jaking12httpd-2.4.39]#make[root@Jaking12httpd-2.4.39]#makeinstall所有组件/usr/local/apache24主配置文件/usr/local/apache24/conf启动脚本/usr/local/apache24/bin/apachectl[root@Jaking12httpd-2.4.39]#ls/usr/local/apache24/binbuildcgi-binconferrorhtdocsiconsincludelogsmanmanualmodules[root@Jaking12httpd-2.4.39]#ls/usr/local/apache24/conf/extrahttpd.confmagicmime.typesoriginal[root@Jaking12httpd-2.4.39]#ls/usr/local/apache24/bin/abapxsdbmmanageenvvars-stdhtcachecleanhtdigesthttpdlogresolveapachectlcheckgidenvvarsfcgistarterhtdbmhtpasswdhttxt2dbmrotatelogs[root@Jaking12httpd-2.4.39]#ll/usr/local/apache24/bin/apachectl-rwxr-xr-x1rootdip3440Mar1016:45/usr/local/apache24/bin/apachectl

启动 apache2.4

[root@Jaking12httpd-2.4.39]#/usr/local/apache24/bin/apachectlAH00558:httpd:Couldnotreliablydeterminetheserver'sfullyqualifieddomainname,usingfe80::250:56ff:fe2c:fe97%ens33.Setthe'ServerName'directivegloballytosuppressthismessage这是一个提示,问题不大(⊙o⊙)…重启 apache2.4

[root@Jaking12httpd-2.4.39]#/usr/local/apache24/bin/apachectlgraceful查看 apache2.4 相关信息

[root@Jaking12httpd-2.4.39]#netstat-pantul|grep80tcp000.0.0.0:220.0.0.0:*LISTEN807/sshdtcp600:::80:::*LISTEN35199/httpdtcp600:::22:::*LISTEN807/sshd[root@Jaking12httpd-2.4.39]#grepDocumentRoot/usr/local/apache24/conf/httpd.conf#DocumentRoot:ThedirectoryoutofwhichyouwillserveyourDocumentRoot"/usr/local/apache24/htdocs"#accesscontentthatdoesnotliveundertheDocumentRoot.[root@Jaking12httpd-2.4.39]#ls/usr/local/apache24/htdocsindex.html[root@Jaking12httpd-2.4.39]#cat/usr/local/apache24/htdocs/index.htmlItworks!

自定义首页内容

[root@Jaking12httpd-2.4.39]#vim/usr/local/apache24/htdocs/index.htmlItworks!HelloWorld!

设置文件共享服务

[root@Jaking12httpd-2.4.39]#cd/usr/local/apache24/htdocs/[root@Jaking12htdocs]#lsindex.html[root@Jaking12htdocs]#touchfile{1..10}[root@Jaking12htdocs]#lsfile1file10file2file3file4file5file6file7file8file9index.html[root@Jaking12htdocs]#mvindex.htmlindex.html.bak[root@Jaking12htdocs]#lsfile1file10file2file3file4file5file6file7file8file9index.html.bak

感谢各位的阅读!关于“怎么通过源码编译的方式安装apache2.4”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!