LINUX 下源码安装 Apache

操作系统CentOS 7

linux下,默认Apache安装软件,其路径是随着开发软件人员的习惯而定,在开发过程中会经常不知道到所需的程序路径,因此手动安装程序对后续的使用会提供非常大的便利

 

一:准备

  1.安装 apr
  下载地址:http://apr.apache.org/download.cgi

  [root@lcoalhost:/usr/local/src]# tar zxvf apr-1.5.2.tar.gz

  [root@lcoalhost:/usr/local/src/apr-1.5.2]# ./configure --prefix=/usr/lcoal/apr

  [root@lcoalhost:/usr/local/src/apr-1.5.2]# make

  [root@lcoalhost:/usr/local/src/apr-1.5.2]# make install


  2.安装 apr-util
  下载地址:http://apr.apache.org/download.cgi
  [root@lcoalhost:/usr/local/src]# tar zxvf apr-util-1.5.4.tar.gz
  [root@lcoalhost:/usr/local/src/apr-util-1.5.4]# ./configure --prefix=/usr/lcoal/apr-util --with-apr=/usr/lcoal/apr

  [root@lcoalhost:/usr/local/src/apr-util-1.5.4]# make

  [root@lcoalhost:/usr/local/src/apr-util-1.5.4]# make install


  3.安装 pcre
  下载地址:http://pcre.org/
  [root@lcoalhost:/usr/local/src]# tar jxvf pcre-8.37.tar.gz
  [root@lcoalhost:/usr/local/src/pcre-8.37]# ./configure --prefix=/usr/lcoal/pcre

  [root@lcoalhost:/usr/local/src/pcre-8.37]# make

  [root@lcoalhost:/usr/local/src/pcre-8.37]# make install


  注意:如果在安装 pcre 时,遇到问题:configure: error: You need a C++ compiler for C++ support.
  解决方法:yum install -y gcc gcc-c++

二:安装Apache

  下载地址:http://httpd.apache.org/
  [root@lcoalhost:/usr/local/src]# tar zxvf httpd-2.4.16.tar.gz
  [root@lcoalhost:/usr/local/src/httpd-2.4.16]# ./configure --prefix=/usr/lcoal/apache --with-apr=/usr/lcoal/apr --with-apr-util=/usr/lcoal/apr-util --with-pcre=/usr/lcoal/pcre

  [root@lcoalhost:/usr/local/src/httpd-2.4.16]# make

  [root@lcoalhost:/usr/local/src/httpd-2.4.16]# make install

三:配置

  1.启动
  [root@localhost:/usr/local/apache]# ./bin/apachectl start

  2.开机启动
  打开文件:/etc/rc.local
  [root@localhost:/]# vim /etc/rc.local

  添加:/work/installed/apache/bin/apachectl start

  3.将里面的#ServerName localhost:80注释去掉即可,避免出现httpd: Could not reliably determine the server's fully qualified domain name错误提示

OK啦 http://localhost OR http://ip

 

posted @ 2015-09-10 14:06  八九零  阅读(195)  评论(0编辑  收藏  举报