|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!ApacheHTTPServer(简称Apache)是Apache软件基金会的一个开放源代码的网页办事器,能够在年夜多半电脑操纵体系中运转,因为其跨平台(能够用于UNIX/Linux体系,乃至还能够用于Windows体系)、宁静性而且可经由过程复杂的API扩大,将Perl/Python等注释器编译到办事器中被普遍利用,是最盛行的Web办事器端软件之一,可是默许只要256个并发毗连,运转速率偏慢,效力较低。官方网站http://httpd.apache.org,Apache有两个版天职支:1.x和2.x,今朝利用的都是2.x版本,最新版本为2.4.7,在体系中的历程名为httpd。
YUM装置Apache
1、检察体系是不是装置Apache:
[root@justin~]#rpm-qa|grephttpd
httpd-2.2.15-15.el6_2.1.i686
httpd-tools-2.2.15-15.el6_2.1.i686
[root@justin~]#
体系默许装置了Apache,版本是2.2.15,公布号为15,el6暗示在rhel6系列版本中公布,i686指32位PC架构
2、装置Apache:
[root@justin~]#yumremovehttpd*-y
Removed:
httpd.i6860:2.2.15-15.el6_2.1
httpd-tools.i6860:2.2.15-15.el6_2.1
DependencyRemoved:
gnome-user-share.i6860:2.28.2-3.el6
Complete!
[root@justin~]#rpm-qa|grephttpd
[root@justin~]#
先卸载失落已装置的
[root@justinsrc]#yuminstallhttpd-y
Installed:
httpd.i6860:2.2.15-29.el6.centos
DependencyInstalled:
httpd-tools.i6860:2.2.15-29.el6.centos
Complete!
[root@justinsrc]#rpm-qa|grephttpd
httpd-2.2.15-29.el6.centos.i686
httpd-tools-2.2.15-29.el6.centos.i686
[root@justinsrc]#
3、启动Apache办事:
[root@justin~]#chkconfig--level35httpdon
[root@justin~]#/etc/init.d/httpdstart
正在启动httpd:httpd:apr_sockaddr_info_get()failedforjustin
httpd:Couldnotreliablydeterminetheserversfullyqualifieddomainname,using127.0.0.1forServerName
[断定]
[root@justin~]#
4、检察Apache占用的端口:
1
2
3
[root@justin~]#netstat-antp|grephttpd
tcp00:::80:::*LISTEN4814/httpd
[root@justin~]#
Apache利用的是80端口,Apache中默许设置了一个站点,此时间接在客户端IE里输出http://ServerIP就能够会见默许站点:http://10.15.72.38
Tips:假如没法会见确认防火墙和SeLinux形态
源码装置Apache
在临盆情况中,多数是接纳源码编译体例装置Apache,如许可天真定制各类功效、实时猎取软件的最新版本和便于从此在分歧的体系之间移植。
[root@justinsrc]#cd/usr/local/src/&&wgethttp://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.7.tar.gz
[root@justinhttpd-2.4.7]#tarzxvfhttpd-2.4.7.tar.gz
[root@justinhttpd-2.4.7]#cdhttpd-2.4.7
[root@justinhttpd-2.4.7]#mkdir-p/usr/local/apache
[root@justinhttpd-2.4.7]#./configure--prefix=/usr/local/apache/
checkingforchosenlayout...Apache
checkingforworkingmkdir-p...yes
checkingforgrepthathandleslonglinesand-e.../bin/grep
checkingforegrep.../bin/grep-E
checkingbuildsystemtype...i686-pc-linux-gnu
checkinghostsystemtype...i686-pc-linux-gnu
checkingtargetsystemtype...i686-pc-linux-gnu
configure:
configure:ConfiguringApachePortableRuntimelibrary...
configure:
checkingforAPR...no
configure:error:APRnotfound.Pleasereadthedocumentation.
[root@justinhttpd-2.4.7]#
设置报错configure:error:APRnotfound.Pleasereadthedocumentation.未发明APR,这个是Apache联系关系软件,装置和apache版原形符版本,版本过早前面也会提醒相似:configure:error:APRversionx.x.xorlaterisrequired的毛病
[root@justinhttpd-2.4.7]#wgethttp://archive.apache.org/dist/apr/apr-1.5.0.tar.gz-P/usr/local/src/
[root@justinhttpd-2.4.7]#cd..
[root@justinsrc]#tarzxvfapr-1.5.0.tar.gz
[root@justinsrc]#cdapr-1.5.0
[root@justinapr-1.5.0]#mkdir-p/usr/local/apr
[root@justinapr-1.5.0]#./configure--prefix=/usr/local/apr/
checkingbuildsystemtype...i686-pc-linux-gnu
checkinghostsystemtype...i686-pc-linux-gnu
checkingtargetsystemtype...i686-pc-linux-gnu
ConfiguringAPRlibrary
Platform:i686-pc-linux-gnu
checkingforworkingmkdir-p...yes
APRVersion:1.5.0
checkingforchosenlayout...apr
checkingforgcc...no
checkingforcc...no
checkingforcl.exe...no
configure:error:in`/usr/local/src/apr-1.5.0:
configure:error:noacceptableCcompilerfoundin$PATH
See`config.logformoredetails
[root@justinapr-1.5.0]#
又呈现了毛病configure:error:noacceptableCcompilerfoundin$PATH,从字面意义大抵意义是没有发明可承受的C编纂器,因而必要装置下gcc套件
[root@justinapr-1.5.0]#yuminstallgcc-y
再次设置、编译、装置
[root@justinapr-1.5.0]#./configure--prefix=/usr/local/apr/
[root@justinapr-1.5.0]#make
[root@justinapr-1.5.0]#makeinstall
apr装置好了再来装置apache
[root@justinsrc]#cdhttpd-2.4.7
[root@justinhttpd-2.4.7]#./configure--prefix=/usr/local/apache/
checkingforchosenlayout...Apache
checkingforworkingmkdir-p...yes
checkingforgrepthathandleslonglinesand-e.../bin/grep
checkingforegrep.../bin/grep-E
checkingbuildsystemtype...i686-pc-linux-gnu
checkinghostsystemtype...i686-pc-linux-gnu
checkingtargetsystemtype...i686-pc-linux-gnu
configure:
configure:ConfiguringApachePortableRuntimelibrary...
configure:
checkingforAPR...yes
settingCCto"gcc"
settingCPPto"gcc-E"
settingCFLAGSto"-g-O2-pthread"
settingCPPFLAGSto"-DLINUX-D_REENTRANT-D_GNU_SOURCE-D_LARGEFILE64_SOURCE"
settingLDFLAGSto""
configure:
configure:ConfiguringApachePortableRuntimeUtilitylibrary...
configure:
checkingforAPR-util...no
configure:error:APR-utilnotfound.Pleasereadthedocumentation.
[root@justinhttpd-2.4.7]#
再次堕落configure:error:APR-utilnotfound.Pleasereadthedocumentation.没有找到APR-util,下载APR-util
[root@justinhttpd-2.4.7]#wgethttp://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz-P/usr/local/src/
[root@justinhttpd-2.4.7]#cd..
[root@justinsrc]#tarzxvfapr-util-1.5.3.tar.gz
[root@justinsrc]#cdapr-util-1.5.3
[root@justinapr-util-1.5.3]#mkdir-p/usr/local/apr-util
[root@justinapr-util-1.5.3]#./configure--prefix=/usr/local/apr
apr/apr-util/
[root@justinapr-util-1.5.3]#./configure--prefix=/usr/local/apr-util/--with-apr=/usr/local/apr/bin/apr-1-config
[root@justinapr-util-1.5.3]#make&&makeinstall
再次回到装置apache
[root@justinapr-util-1.5.3]#cd../httpd-2.4.7
[root@justinhttpd-2.4.7]#./configure--prefix=/usr/local/apache/
checkingforchosenlayout...Apache
checkingforworkingmkdir-p...yes
checkingforgrepthathandleslonglinesand-e.../bin/grep
checkingforegrep.../bin/grep-E
checkingbuildsystemtype...i686-pc-linux-gnu
checkinghostsystemtype...i686-pc-linux-gnu
checkingtargetsystemtype...i686-pc-linux-gnu
configure:
configure:ConfiguringApachePortableRuntimelibrary...
configure:
checkingforAPR...yes
settingCCto"gcc"
settingCPPto"gcc-E"
settingCFLAGSto"-g-O2-pthread"
settingCPPFLAGSto"-DLINUX-D_REENTRANT-D_GNU_SOURCE-D_LARGEFILE64_SOURCE"
settingLDFLAGSto""
configure:
configure:ConfiguringApachePortableRuntimeUtilitylibrary...
configure:
checkingforAPR-util...no
configure:error:APR-utilnotfound.Pleasereadthedocumentation.
[root@justinhttpd-2.4.7]#
已装置好了APR-util仍是提醒没装置,我们必要在设置是指定他地位
[root@justinhttpd-2.4.7]#./configure--prefix=/usr/local/apache/--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util/
checkingforchosenlayout...Apache
checkingforworkingmkdir-p...yes
checkingforgrepthathandleslonglinesand-e.../bin/grep
checkingforegrep.../bin/grep-E
checkingbuildsystemtype...i686-pc-linux-gnu
checkinghostsystemtype...i686-pc-linux-gnu
checkingtargetsystemtype...i686-pc-linux-gnu
configure:
configure:ConfiguringApachePortableRuntimelibrary...
configure:
checkingforAPR...yes
settingCCto"gcc"
settingCPPto"gcc-E"
settingCFLAGSto"-g-O2-pthread"
settingCPPFLAGSto"-DLINUX-D_REENTRANT-D_GNU_SOURCE-D_LARGEFILE64_SOURCE"
settingLDFLAGSto""
configure:
configure:ConfiguringApachePortableRuntimeUtilitylibrary...
configure:
checkingforAPR-util...yes
checkingforgcc...gcc
checkingwhethertheCcompilerworks...yes
checkingforCcompilerdefaultoutputfilename...a.out
checkingforsuffixofexecutables...
checkingwhetherwearecrosscompiling...no
checkingforsuffixofobjectfiles...o
checkingwhetherweareusingtheGNUCcompiler...yes
checkingwhethergccaccepts-g...yes
checkingforgccoptiontoacceptISOC89...noneneeded
checkinghowtoruntheCpreprocessor...gcc-E
checkingforgccoptiontoacceptISOC99...-std=gnu99
checkingforpcre-config...false
configure:error:pcre-configforlibpcrenotfound.PCREisrequiredandavailablefromhttp://pcre.org/
[root@justinhttpd-2.4.7]#
编译装置就是这么坑,你必要办理一系列的依附干系,再次提醒毛病configure:error:pcre-configforlibpcrenotfound.PCREisrequiredandavailablefromhttp://pcre.org/,一样我们必要先装置这个pcre
[root@justinsrc]#wgethttp://jaist.dl.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.zip-P/usr/local/src/
[root@justinhttpd-2.4.7]#cd..
[root@justinsrc]#unzip-opcre-8.34.zip
[root@justinsrc]#cdpcre-8.34
[root@justinpcre-8.34]#mkdir/usr/local/pcre
[root@justinpcre-8.34]#./configure--prefix=/usr/local/pcre/
checkingfordirent.h...yes
checkingwindows.husability...no
checkingwindows.hpresence...no
checkingforwindows.h...no
configure:error:YouneedaC++compilerforC++support.
[root@justinpcre-8.34]#
configure:error:YouneedaC++compilerforC++support.必要装置C++,后面装置gcc的时分能够一同装置了,以免这步又的装置
[root@justinpcre-8.34]#yuminstallgcc-c++-y
装置好再来装置pcre
[root@justinpcre-8.34]#./configure--prefix=/usr/local/pcre/
[root@justinpcre-8.34]#make&&makeinstall
最初再回到装置Apache
[root@justinhttpd-2.4.7]#./configure--prefix=/usr/local/apache/--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util/--with-pcre=/usr/local/pcre/
config.status:creatingbuild/pkg/pkginfo
config.status:creatingbuild/config_vars.sh
config.status:creatinginclude/ap_config_auto.h
config.status:executingdefaultcommands
[root@justinhttpd-2.4.7]#make&&makeinstall
mkdir/usr/local/apache/man/man8
mkdir/usr/local/apache/manual
make[1]:Leavingdirectory`/usr/local/src/httpd-2.4.7
[root@justinhttpd-2.4.7]#
总算没有再报错,源码编译装置固然天真可是装置很庞大,必要办理一系列依附干系成绩,这里只是地道的装置Apache办事。仅能供应最基础的静态网站数据罢了,想要完成静态网站的话,最好仍是要PHP与MySQL的撑持
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|