Chinaunix首页 | 论坛 | 博客
  • 博客访问: 107298
  • 博文数量: 9
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 157
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-09 12:11
文章分类

全部博文(9)

文章存档

2015年(2)

2014年(7)

我的朋友

分类: LINUX

2014-06-13 15:27:00

      虚拟机上做了太多的lamp环境下的实验,往往我们不屑于用源码去安装apache、mysql、php,有人觉得是浪费时间,也有人觉得源码安装实在过于复杂(我就这么认为),其实在我们图yum install(此为redhat,当然在其他系统上可能是apt-get install等) 一时之便的同时,却与sorce code安装的安装渐行渐远,想作为一个称职的运维工程师,源码安装的技能必不可少。如果说configure、make、make install 是源码安装的黄金三部曲,那么有太多的软件包安装已经属于变奏曲了,废话不多说了,就以apache的新版本httpd-2.4.9.tar.gz为例

点击(此处)折叠或打开

  1. [root@https ~]# ls apr* httpd-2.4.9.tar.gz 
  2. apr-1.5.1.tar.gz            #这两个是apache的依赖包
  3. apr-util-1.4.1.tar.gz
  4. httpd-2.4.9.tar.gz     
  5. [root@https ~]# tar -xvf httpd-2.4.9.tar.gz -C /usr/src^C
  6. [root@https ~]# cd /usr/src/httpd-2.4.9/
  7. [root@https httpd-2.4.9]# vim INSTALL          #看看INSTALL文件介绍的安装软件的环境要求
     根据INSTALL文件的指引,apache依赖apr和apr-util 这两个包,并且需要将这两个包解压在apache源码目录下srclib目录中,注意不要带版本号。我尝试过用yum install apr* -y安装,虽然有包被安装上,但configure  apache的时候还是会提示缺少APR包,只要放弃rpm包的方式。由于接触linux不久,暂且也只这样。
   
     我们先试着在不看INSTALL文件的情况下直接configure会有什么报错

点击(此处)折叠或打开

  1. [root@https httpd-2.4.9]# ./configure --prefix=/usr/local
  2. checking for chosen layout... Apache
  3. checking for working mkdir -p... yes
  4. checking for grep that handles long lines and -e... /bin/grep
  5. checking for egrep... /bin/grep -E
  6. checking build system type... x86_64-unknown-linux-gnu
  7. checking host system type... x86_64-unknown-linux-gnu
  8. checking target system type... x86_64-unknown-linux-gnu
  9. configure:
  10. configure: Configuring Apache Portable Runtime library...
  11. configure:
  12. checking for APR... no
  13. configure: error: APR not found. Please read the documentation.  #提示APR没有找到

解决办法:

点击(此处)折叠或打开

  1. [root@https ~]# tar -xvf apr-1.5.1.tar.gz -C /usr/src/httpd-2.4.9/srclib/
  2. [root@https ~]# tar -xvf apr-util-1.4.1.tar.gz -C /usr/src/httpd-2.4.9/srclib/               #必须解压到这个位置
  3. [root@https ~]# cd /usr/src/httpd-2.4.9/srclib/
  4. [root@https srclib]# ls
  5. apr-1.5.1 apr-util-1.4.1 Makefile
  6. [root@https srclib]# mv apr-1.5.1 apr               #不能带版本号
  7. [root@https srclib]# mv apr-util-1.4.1 apr-util
  8. [root@https srclib]# ls
  9. apr apr-util Makefile.in
  10. [root@https srclib]# cd apr     
  11. [root@https apr]# ./configure 
  12. [root@https apr]# make && make install 
  13. [root@https apr]# cd ..
  14. [root@https srclib]# cd apr-util/
  15. [root@https apr-util]# ./configure --with-apr=/usr/local/apr/         #必须指定刚才apr安装的目录,默认在/usr/local
  16. [root@https apr-util]# make && make install 



在完成了apr和apr-util安装的前提下我们再来configure一次apache,看看会有什么效果

点击(此处)折叠或打开

  1. [root@https httpd-2.4.9]# ./configure --prefix=/usr/local/apache2 --enable-modules=all --with-included-apr   
  2. ..............................
  3. checking for suffix of object files... o
  4. checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -E
    checking for gcc option to accept ISO C99... -std=gnu99
    checking for pcre-config... false
    configure: error: pcre-config for libpcre not found. PCRE is required and available from
     虽然这里依然有error,但是我们发现APR not found 这种问题已经没有出现了,说明前面的操作还是有用的。至于这里没有找到的pcre是个perl库,应该是在make的时候需要用到,通常出现xxx not found ,首先想到就是yum install 去安装,刚好pcre在redhat镜像里有,而且它的安装要求没有apr和apr-util那么苛刻。

点击(此处)折叠或打开

  1. [root@https httpd-2.4.9]# yum install pcre* -y        #能够成功安装
  2. [root@https httpd-2.4.9]# ./configure --prefix=/usr/local/apache2 --enable-modules --with-included-apr      
  3. ....................
  4. config.status: creating build/rules.mk
    config.status: creating build/pkg/pkginfo
    config.status: creating build/config_vars.sh
    config.status: creating include/ap_config_auto.h
    config.status: executing default commands            #执行configure发现不再报任何错误
  5. [root@https httpd-2.4.9]# make && make install        #一鼓作气安装apache
      按照上面的步骤,2.4.9版本的apache不出意外应该就能安装上了,值得一提的是,我在make install 的时候出现了小小的插曲,居然提示
cannot install `libaprutil-1.la' to a directory not ending in /usr/local/apache2/apr ,问过度娘,虽然有很多朋友都遇到这种报错,但每个人操作过程不同,解决办法也
不一二足,我没有太多时间去一个个试,考虑到我是新装的系统,索性放了个绝招——make clean 之后再次 make && make install (我一向认为重启服务器、重启服务或者同样的动作再做一次能够解决80%的问题),结果是大快人心的,莫名其妙的安装成功了。

点击(此处)折叠或打开

  1. [root@https httpd-2.4.9]# ls /usr/local/apache2/            #成功安装后,该目录下会生成这些文件和目录
  2. bin build cgi-bin conf error htdocs icons include lib logs man manual modules
  3. [root@https httpd-2.4.9]# cd /usr/local/apache2/
  4. [root@https apache2]# cd bin
  5. [root@https bin]# netstat -lanput|grep 80             #查看80端口是否开启,这里还没有开启
  6. [root@https bin]# ./apachectl start                      #启动apache服务
  7. AH00557: httpd: apr_sockaddr_info_get() failed for https.host.com
  8. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName
  9. [root@https bin]# netstat -lanput|grep 80
  10. tcp        0      0 :::80                       :::*                        LISTEN      19267/httpd         #此时80端口已打开



 
阅读(2701) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~