编译安装LAMP实现PHP作为模块、FastCGI分离等方式
源码包:httpd-2.4.9Apache2.4.9编译安装包
apr-1.5.1Apache可移植运行库
apr-util-1.5.3Apache可移植运行库工具
php-5.5.30PHP源码包
mysql-5.5.47通用二进制版( Generic)
一、PHP作为模块编译LAMP:
注:1、由于PHP作为Apache的模块,所以编译PHP的时候,需要在httpd之后。2、这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。3、PHP连接MySQL数据库需要mysql客户端的开发组件支持,不过:如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
1.编译apr-1.5.1:
1
2
3
4
5
# yum install -y pcre-devel #安装perl正则表达式的依赖包
# cd lamp/
# tar xf apr-1.5.1.tar.gz
# cd apr-1.5.1
# ./configure --prefix=/usr/local/apr && make && make install
2.编译apr-util-1.5.3:
1
2
3
# tar xf apr-util-1.5.3.tar.bz2
# cd apr-util-1.5.3
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ && make && make install
3.编译httpd-2.4.9:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# tar xf httpd-2.4.9.tar.gz
# cd httpd-2.4.9
# ./configure --prefix=/usr/local/httpd-2.4.9 \#指定安装目录
> --sysconfdir=/etc/httpd \ #配置文件目录
> --enable-modules=most \ #编译进大多数常用模块
> --enable-mods-shared=most \ #将常用模块编译为动态模块,shared
> --enable-so \ #使Apache支持动态加载模块
> --enable-ssl \ #支持ssl
> --enable-mpms-shared=all \ #将所有支持的MPM模块编译为动态模块
> --with-apr=/usr/local/apr \ #指定apr所在位置
> --with-apr-util=/usr/local/apr-util \ #指定apr-util位置
> --with-mpm=event \ #指定默认MPM为event
> --enable-proxy \ #开启代理模块
> --enable-proxy-fcgi \ #开启fcgi模块,需要一并开启--enable-proxy选项
> --enable-deflate \ #支持压缩
> make && make install #安装
#############安装完成后,还需要对运行环境做些配置################
# ln -sv /usr/local/httpd-2.4.9 /usr/local/httpd #将目录链接为httpd,方便以后升级
# vim /etc/profile.d/httpd.sh #提供命令搜索路径
1.添加一行:export PATH=/usr/local/httpd/bin:$PATH
# ln -sv /usr/local/httpd/include/ /usr/include/httpd#链接头文件到系统默认搜索位置:/usr/include
`/usr/include/httpd' -> `/usr/local/httpd/include/'
# vim /etc/man.config #编辑man文档目录
1.添加一行:MANPATH /usr/local/httpd/man
4.解压mysql:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# tar xf mysql-5.5.47-linux2.6-x86_64.tar.gz -C /usr/local/
#############安装完成后,还需要对运行环境做些配置################
#ln -sv /usr/local/mysql-5.5.47-linux2.6-x86_64/ /usr/local/mysql #将mysql-5.5.47目录链接为mysql
`/usr/local/mysql' -> `/usr/local/mysql-5.5.47-linux2.6-x86_64/'
# vim /etc/profile.d/mysql.sh #提供命令搜索路径
1.添加一行:export PATH=/usr/local/mysql/bin:$PATH
# ln -sv /usr/local/mysql/include/ /usr/include/mysql #链接头文件
`/usr/include/mysql/include' -> `/usr/local/mysql/include/'
# vim /etc/ld.so.conf.d/mysql.conf #库文件
1.添加一行:/usr/local/mysql/lib
# ldconfig #重读库文件
5.编译php-5.5.30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# yum install -y openssl-devel bzip2-devel libmcrypt-devel
# cd php-5.5.30
./configure --prefix=/usr/local/php-5.5.30 \ #指定安装目录
> --with-mysql=/usr/local/mysql \ #指定MySQL安装目录
> --with-openssl \ #使用openssl库,需要安装openssl-devel包
> --with-mysqli=/usr/local/mysql/bin/mysql_config \ #指定mysql_config
> --enable-mbstring \ #开启多字符串支持
> --with-freetype-dir \
> --with-jpeg-dir \ #支持jpeg
> --with-png-dir \ #支持png
> --with-zlib \ #指定zlib
> --with-libxml-dir=/usr \ #指定libxml库
> --enable-xml\ #开启xml
> --enable-sockets \ #开启套接字方式支持
> --with-apxs2=/usr/local/apache/bin/apxs \ #apxs是Apache的模块支持库,要想编译为Apache模块,依赖于apxs
> --with-mcrypt \ #指定加密库,需要libmcrypt-devel包
> --with-config-file-path=/etc \ #指定配置文件所在目录
> --with-config-file-scan-dir=/etc/php.d \ #指定附加目录
> --with-bz2\ #指定bz2压缩库,需要bzip2-devel
> --enable-maintainer-zts #支持apache的worker或event这两个MPM
#############安装完成后,还需要对运行环境做些配置################
# ln -sv /usr/local/php-5.5.30/ /usr/local/php
`/usr/local/php' -> `/usr/local/php-5.5.30/
# ln -sv /usr/local/php-5.5.30/include/ /usr/include/php
`/usr/include/php' -> `/usr/local/php-5.5.30/include/'
# vim /etc/profile.d/php.sh
1.添加一行:export PATH=/usr/local/php/bin:$PATH
# vim /etc/ld.so.conf.d/php.conf
1.添加一行:/usr/local/php/lib
7.配置httpd:
页:
[1]