基本环境约定:
1.CentOS5.8 x86_64位 采用最小化安装,系统经过了基本优化篇
2.mysql安装路径:/usr/local/mysql
3.源码包存放位置:/home/oldboy/tools
4.源码包编译安装位置:/application
如果你清楚lanp环境搭建,参考以下文章:
A.php和apache编译安装方法
B.mysql5.1编译方法和步骤
一.PHP扩展安装实验安装环境
1.检查对应的版本
cat /etc/redhat-release
uname -m
/application/apache/bin/apachectl -v
/application/php/bin/php -v
mysqladmin -uroot -pmybaby3306 -S /data/3306/mysql.sock "version"
2.准备环境
[[email protected] ~]# cat /etc/redhat-release
CentOS release 5.10 (Final)
[[email protected] ~]# uname -m
x86_64
[[email protected] ~]# /application/apache/bin/apachectl -v
Server version: Apache/2.2.29 (Unix)
Server built: Oct 9 2014 09:44:14
[[email protected] ~]# /application/php/bin/php -v
PHP 5.3.29 (cli) (built: Oct 19 2014 10:12:02)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
[[email protected] ~]# mysqladmin -uroot -pmybaby3306 -S /data/3306/mysql.sock "version"
mysqladmin Ver 8.42 Distrib 5.1.73, for unknown-linux-gnu on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.1.73-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /data/3306/mysql.sock
Uptime: 6 hours 51 min 58 sec
Threads: 1 Questions: 13 Slow queries: 0 Opens: 14 Flush tables: 1 Open tables: 8 Queries per second avg: 0.0
二.功能和加速模块安装
1.eAccelerator加速模块,是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。 它还有对脚本起优化作用,以加快其执行效率。使您的PHP程序代码执效率能提高1-10倍。
2.用到命令:
cd /home/oldboy/tools/
tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
cd eaccelerator-eaccelerator-42067ac
/application/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/application/php/bin/php-config
make && make install
3.安装过PDO扩展为PHP访问数据库定义了一个轻量级的、一致性的接口,它提供了一个数据访问抽象层,这样,无论使用什么数据库,都可以通过一致的函数执行查询和获取数据。PDO随PHP5.1发行,在PHP5.0的PECL扩展中也可以使用,无法运行于之前的PHP版本。程
[[email protected] tools]# rz
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring eaccelerator-eaccelerator-42067ac.tar.gz...
100% 128 KB 128 KB/sec 00:00:01 0 Errors
[[email protected] tools]# tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
[[email protected] tools]# cd eaccelerator-eaccelerator-42067ac
[[email protected] eaccelerator-eaccelerator-42067ac]# /application/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[[email protected] eaccelerator-eaccelerator-42067ac]# ./configure --enable-eaccelerator=shared \
> --with-php-config=/application/php/bin/php-config
[[email protected] tools]# make && make install
[[email protected] no-debug-zts-20090626]# !1047
cd /application/php/lib/php/extensions/no-debug-zts-20090626/
[[email protected] no-debug-zts-20090626]# ll
total 420
-rwxr-xr-x 1 root root 425136 Oct 27 19:03 eaccelerator.so
三.memcache安装
1.介绍:
Memcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像、视频、文件以及数据库检索的结果等。简单的说就是将数据调用到内存中,然后从内存中读取,从而大大提高读取速度。
2.安装命令:
cd /home/oldboy/tools/
wget http://www.memcached.org/files/memcached-1.4.17.tar.gz
tar zxf memcached-1.4.17.tar.gz
cd memcached-1.4.17
./configure --with-php-config=/application/php/bin/php-config
make && make install
3.安装过程:
[[email protected] tools]# wget http://pecl.php.net/get/memcache-2.2.7.tgz
--2014-10-27 20:19:54-- http://pecl.php.net/get/memcache-2.2.7.tgz
Resolving pecl.php.net... 76.75.200.106
Connecting to pecl.php.net|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 36459 (36K) [application/octet-stream]
Saving to: `memcache-2.2.7.tgz‘
100%[======================================================================================>] 36,459 6.62K/s in 5.4s
2014-10-27 20:20:01 (6.62 KB/s) - `memcache-2.2.7.tgz‘ saved [36459/36459]
[[email protected] tools]# tar xzf memcache-2.2.7.tgz
[[email protected] tools]# cd memcache-2.2.7
[[email protected] memcache-2.2.7]# /application/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[[email protected] memcache-2.2.7]# ./configure --with-php-config=/application/php/bin/php-config
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
#(中间省略)
----------------------------------------------------------------------
Build complete.
Don‘t forget to run ‘make test‘.
Installing shared extensions: /application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/
[[email protected] memcache-2.2.7]# ll /
[[email protected] memcache-2.2.7]# ll /application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/
total 644
-rwxr-xr-x 1 root root 425136 Oct 27 19:03 eaccelerator.so
-rwxr-xr-x 1 root root 222254 Oct 27 21:10 memcache.so
四.动态添加功能模块pdo_mysql
1.介绍:PDO扩展为PHP访问数据库定义了一个轻量级的、一致性的接口,它提供了一个数据访问抽象层,这样,无论使用什么数据库,都可以通过一致的函数执行查询和获取数据。PDO随PHP5.1发行,在PHP5.0的PECL扩展中也可以使用,无法运行于之前的PHP版本。
2.用到命令:
cd /home/oldboy/tools/
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xzf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
./configure --with-php-config=/application/php/bin/php-config \
--with-pdo-mysql=/usr/local/mysql/
make && make install
注.下载/PDO_MYSQL-1.0.3.tgz未安装成功,make时提示:
/home/oldboy/tools/PDO-1.0.3/pdo.c:78: error: too few arguments to function ‘zend_exception_get_default’
暂未找到决办法
3.安装过程:
[[email protected] tools]# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
--2014-10-27 21:48:59-- http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
Resolving pecl.php.net... 76.75.200.106
Connecting to pecl.php.net|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14778 (14K) [application/octet-stream]
Saving to: `PDO_MYSQL-1.0.2.tgz‘
100%[======================================================================================>] 14,778 19.5K/s in 0.7s
2014-10-27 21:49:11 (19.5 KB/s) - `PDO_MYSQL-1.0.2.tgz‘ saved [14778/14778]
[[email protected] tools]# tar xzf PDO_MYSQL-1.0.2.tgz
[[email protected] tools]# cd PDO_MYSQL-1.0.2
[[email protected] PDO_MYSQL-1.0.2]# /application/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[[email protected] PDO_MYSQL-1.0.2]# ./configure --with-php-config=/application/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
checking for egrep... grep -E
[[email protected] PDO_MYSQL-1.0.2]# ll /application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/
total 784
-rwxr-xr-x 1 root root 425136 Oct 27 19:03 eaccelerator.so
-rwxr-xr-x 1 root root 222254 Oct 27 21:10 memcache.so
-rwxr-xr-x 1 root root 135439 Oct 27 21:50 pdo_mysql.so
五.功能模块:imagemagick安装
1.imagemagick介绍:
mageMagick是一套功能强大、稳定而且开源的工具集和开发包,可以用来读、写和处理超过89种基本格式的图片文件,包括流行的TIFF、JPEG、GIF、 PNG、PDF以及PhotoCD等格式。利用ImageMagick,你可以根据web应用程序的需要动态生成图片, 还可以对一个(或一组)图片进行改变大小、旋转、锐化、减色或增加特效等操作,并将操作的结果以相同格式或其它格式保存,对图片的操作,即可以通过命令行进行,也可以用C/C++、Perl、Java、PHP、Python或Ruby编程来完成。同时ImageMagick提供了一个高质量的2D工具包,部分支持SVG。ImageMagic的主要精力集中在性能,减少bug以及提供稳定的API和ABI上。
2.安装命令
cd /home/oldboy/tools/
wget http://www.imagemagick.org/download/ImageMagick-6.8.9-9.tar.gz
tar xzf ImageMagick-6.8.9-9.tar.gz
cd ImageMagick-6.8.9-9
./configure
make
make install
#装模块,要建立在上一步安装imagemagick软件的基础上
wget http://pecl.php.net/get/imagick-3.1.2.tgz
tar xzf imagick-3.1.2.tgz
cd imagick-3.1.2
/application/php/bin/phpize
./configure --with-php-config=/application/php/bin/php-config
make
make install
ll /application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/
3.安装过程:
[[email protected] ~]# cd /home/oldboy/tools/
[[email protected] tools]# tar xzf ImageMagick-6.8.9-9.tar.gz
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
[[email protected] tools]# wget http://www.imagemagick.org/download/ImageMagick-6.8.9-9.tar.gz
--2014-10-28 10:11:04-- http://www.imagemagick.org/download/ImageMagick-6.8.9-9.tar.gz
Resolving www.imagemagick.org... 209.191.186.187
Connecting to www.imagemagick.org|209.191.186.187|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12336784 (12M) [application/x-gzip]
Saving to: `ImageMagick-6.8.9-9.tar.gz‘
100%[======================================================================================>] 12,336,784 72.6K/s in 2m 44s
2014-10-28 10:14:09 (73.4 KB/s) - `ImageMagick-6.8.9-9.tar.gz.1‘ saved [12336784/12336784]
[[email protected] tools]# tar xzf ImageMagick-6.8.9-9.tar.gz
[[email protected] ImageMagick-6.8.9-9]# ./configure
configuring ImageMagick 6.8.9-9
checking build system type... x86_64-unknown-linux-gnu
#(.............省略)
[[email protected] ImageMagick-6.8.9-9]# make && make instal
[[email protected] ImageMagick-6.8.9-9]# cd ..
[[email protected] tools]# wget http://pecl.php.net/get/imagick-3.1.2.tgz
--2014-10-28 10:50:22-- http://pecl.php.net/get/imagick-3.1.2.tgz
Resolving pecl.php.net... 76.75.200.106
Connecting to pecl.php.net|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 94657 (92K) [application/octet-stream]
Saving to: `imagick-3.1.2.tgz‘
100%[======================================================================================>] 94,657 61.4K/s in 1.5s
2014-10-28 10:50:24 (61.4 KB/s) - `imagick-3.1.2.tgz‘ saved [94657/94657]
[[email protected] tools]# tar xzf imagick-3.1.2.tgz
[[email protected] tools]# cd imagick-3.1.2
[[email protected] imagick-3.1.2]# /application/php/bin/phpize \
> ;
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[[email protected] imagick-3.1.2]# ./configure --with-php-config=/application/php/bin/php-config
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
#(.............省略)
[[email protected] imagick-3.1.2]# make
[[email protected] imagick-3.1.2]# make install
[[email protected] imagick-3.1.2]# ll /application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/
total 1940
-rwxr-xr-x 1 root root 425136 Oct 27 19:03 eaccelerator.so
-rwxr-xr-x 1 root root 1178470 Oct 28 10:58 imagick.so
-rwxr-xr-x 1 root root 222254 Oct 27 21:10 memcache.so
-rwxr-xr-x 1 root root 135439 Oct 27 21:50 pdo_mysql.so
六.配置以上模块
1.修改php.ini
sed -i ‘s#; extension_dir = "./"#extension=/application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/#g‘ php.ini
vi php.ini +1000,添加如下模块
extension=memcache.so
extension=pdo_mysql.so
extension=imagick.so
extension=eaccelerator.so
2.配置参数:
cat >> /application/php/lib/php.ini<<EOF
[eaccelerator]
extension=eaccelerator.so
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
EOF
七.phpize介绍:
1. 安装php(fastcgi模式)的时候,常常有这样一句命令:/usr/local/webserver/php/bin/phpize
phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块
比如你想在原来编译好的php中加入memcached或者ImageMagick等扩展模块,可以使用phpize,通过以下几步工作。
当php编译完成后,php的bin目录下会有phpize这个脚本文件。在编译你要添加的扩展模块之前,执行以下phpize就可以了;
你可能还对如下内容感兴趣:
1.mysql启动命令大全
2.mysql多实例安装方法和详细步骤