由于天涯PHP博客前几天重新格了硬盘,把以前的Windows7+Ubuntu双系统彻底更换为只保留Ubuntu-14.04了,所以重新配置下Ubuntu-14.04下的LAMP环境,因为前几天PHP初学者官方群[168159147]中有成员问过编译的问题,天涯PHP博客就顺便记录下自己的安装过程。

  1. 安装C++编译相关组件:
phpha@asus:~/lamp$ sudo apt-get install build-essential
  1. 编译安装apr
phpha@asus:~/lamp$ tar -zxf apr-1.5.1.tar.gz
phpha@asus:~/lamp$ cd apr-1.5.1/
phpha@asus:~/lamp/apr-1.5.1$ ./configure --prefix=/usr/local/apr
phpha@asus:~/lamp/apr-1.5.1$ sudo make
phpha@asus:~/lamp/apr-1.5.1$ sudo make install
  1. 编译安装apr-util
phpha@asus:~/lamp$ tar -zxf apr-util-1.5.3.tar.gz
phpha@asus:~/lamp$ cd apr-util-1.5.3
phpha@asus:~/lamp/apr-util-1.5.3$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
phpha@asus:~/lamp/apr-util-1.5.3$ sudo make
phpha@asus:~/lamp/apr-util-1.5.3$ sudo make install
  1. 编译安装pcre
phpha@asus:~/lamp$ tar -zxf pcre-8.35.tar.gz
phpha@asus:~/lamp$ cd pcre-8.35
phpha@asus:~/lamp/pcre-8.35$ ./configure --prefix=/usr/local/pcre
phpha@asus:~/lamp/pcre-8.35$ sudo make
phpha@asus:~/lamp/pcre-8.35$ sudo make install
  1. 编译安装zlib
phpha@asus:~/lamp$ tar -zxf zlib-1.2.8.tar.gz
phpha@asus:~/lamp$ cd zlib-1.2.8
phpha@asus:~/lamp/zlib-1.2.8$ ./configure --prefix=/usr/local/zlib
phpha@asus:~/lamp/zlib-1.2.8$ sudo make
phpha@asus:~/lamp/zlib-1.2.8$ sudo make install
  1. 安装zlib1g-dev
phpha@asus:~/lamp$ sudo apt-get install zlib1g-dev

需要说明的是,zlib1g-dev和zlib-dev是两个不同的包,如果未安装zlib1g-dev会在下面编译安装apache时报错:
configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

  1. 编译安装apache
phpha@asus:~/lamp$ tar -zxf httpd-2.4.10.tar.gz
phpha@asus:~/lamp$ cd httpd-2.4.10
phpha@asus:~/lamp/httpd-2.4.10$ ./configure --prefix=/usr/local/apache --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
phpha@asus:~/lamp/httpd-2.4.10$ sudo make
phpha@asus:~/lamp/httpd-2.4.10$ sudo make install

标签:Apache / Ubuntu