PHP 5.6.0 & Apache 2.4 环境安装设置 (Ubuntu 14.04)

Setup PHP 5.6.0 & Apache 2.4 from Ubuntu 14.04

1. Apache编译与安装

 1# 安装APR依赖库
 2axl@MMPC:~$ sudo apt-get install libapr1-dev
 3axl@MMPC:~$ sudo apt-get install libaprutil1-dev
 4
 5# 配置Apache源文件
 6axl@MMPC:~$ cd /source/software/php/httpd-2.4.10
 7axl@MMPC:/source/software/php/httpd-2.4.10$ ./configure --enable-so --prefix=/opt/appservers/httpd-2.4.10
 8
 9# 编译Apache
10axl@MMPC:/source/software/php/httpd-2.4.10$ make -s
11
12# 安装Apache
13axl@MMPC:/source/software/php/httpd-2.4.10$ sudo make install -s
14
15# 根据--prefix配置 Apache已经被安装至/opt/appservers/httpd-2.4.10

2. PHP编译与安装

 1# 安装依赖库
 2axl@MMPC:~$ sudo apt-get install libxml2-dev
 3axl@MMPC:~$ sudo apt-get install libgd-dev
 4axl@MMPC:~$ sudo apt-get install libmcrypt-dev
 5
 6# 安装freetype 2库
 7# download link:
 8# http://sourceforge.net/projects/freetype/files/freetype2/2.5.3/"
 9# default lib path = /usr/local/lib
10axl@MMPC:~$ cd /source/software/php/
11axl@MMPC:/source/software/php$ tar -xf freetype-2.5.3.tar.gz
12axl@MMPC:/source/software/php$ cd freetype-2.5.3
13axl@MMPC:/source/software/php/freetype-2.5.3$ ./configure
14axl@MMPC:/source/software/php/freetype-2.5.3$ make -s
15axl@MMPC:/source/software/php/freetype-2.5.3$ sudo make install -s
16
17# 配置PHP源文件
18./configure --prefix=/opt/appservers/php-5.6.0 --with-apxs2=/opt/appservers/httpd-2.4.10/bin/apxs --with-mysql --with-config-file-path=/opt/appservers/php-5.6.0/php.ini --with-gd --enable-gd-native-ttf --with-png --with-ttf --with-freetype-dir=/usr/local/lib --enable-mbstring --with-mcrypt --with-pdo-mysql
19
20# 编译PHP
21make -s
22
23# 安装PHP
24make install -s
25
26# 根据--prefix配置,PHP已经被安装至/opt/appservers/php-5.6.0
27# 根据--with-apxs2配置,PHP已经关联/opt/appservers/httpd-2.4.10/bin/apxs
28# 根据--with-config-file-path配置,PHP配置文件指定为/opt/appservers/php-5.6.0/php.ini

3. 基本配置

 1# 复制默认的PHP配置文件
 2axl@MMPC:~$ cp /source/software/php/php-5.6.0/php.ini-development /opt/appservers/php-5.6.0/php.ini
 3
 4# 编辑Apache配置文件,增加虚拟主机配置
 5axl@MMPC:~$ vi /opt/appservers/httpd-2.4.10/conf/httpd.conf
 6
 7# 增加以下内容
 8-begin----------------------------------------
 9# Axl configure php file filter
10<FilesMatch \.php$>
11    SetHandler application/x-httpd-php
12</FilesMatch>
13
14<VirtualHost *:80>
15    DocumentRoot /opt/appservers/vhosts/smd
16    ServerName smdhost
17</VirtualHost>
18
19<VirtualHost *:80>
20    DocumentRoot /opt/appservers/vhosts/wphost
21    ServerName wphost
22</VirtualHost>
23
24<VirtualHost *:80>
25    DocumentRoot /opt/appservers/vhosts/pshost
26    ServerName pshost
27</VirtualHost>
28
29<DirectoryMatch "^/opt/appservers/vhosts/.+">
30    Options Indexes FollowSymLinks
31    AllowOverride None
32    Require all granted
33    DirectoryIndex index.html
34    DirectoryIndex index.php
35</DirectoryMatch>
36-end------------------------------------------

4. 启动/停止Apache

1# 启动
2axl@MMPC:~$ sudo /opt/appservers/httpd-2.4.10/bin/apachectl start
3
4# 停止
5axl@MMPC:~$ sudo /opt/appservers/httpd-2.4.10/bin/apachectl stop
作者|Author: RockSolid
发表日期|Publish Date: Oct 13, 2014
修改日期|Modified Date: Oct 13, 2014
版权许可|Copyright License: CC BY-NC-ND 3.0 CN