php5.4.4添加模塊(memcache,Xcache,ImageMagick,PDO_MYSQL)

編譯安裝apache 

  1. wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.22.tar.gz 
  2. tar xf httpd-2.2.22.tar.gz 
  3. cd httpd-2.2.22 
  4. ./configure --prefix=/usr/local/webserver/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib 
  5. make&& make install 
 
編譯php和php模塊需要用到mysql ,所以要安裝好mysql數據庫後在進行下面的步驟
php5.4
到官網下載php5.4.4
 
  1. cd php-5.4.4 
  2. ./configure --prefix=/usr/local/php --with-mysql=/usr/local/webserver/mysql --with-openssl --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --with-apxs2=/usr/local/webserver/apache/bin/apxs --with-openssl --with-mhash --disable-rpath --enable-discard-path --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --with-config-file-path=/usr/local/php/etc 
  3. make ZEND_EXTRA_LIBS='-liconv' 
  4. make install 
 
相關模塊安裝(memcache,xcache,PDO_mysql,ImageMagick):
memcache
 
  1. tar zxvf memcache-2.2.5.tgz 
  2. cd memcache-2.2.5/ 
  3. /usr/local/webserver/php/bin/phpize 
  4. ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 
  5. make 
  6. make install 
  7. cd ../ 

xcache
php5.4對於eaccelerator-0.9.6.1的兼容沒有做好,安裝過程會報錯
 
  1. eaccelerator-0.9.6.1/eaccelerator.c:1938: error: ‘eaccelerator_functions’ undeclared here (not in a function) 
我們使用xcache代替
 
  1. wget -c http://xcache.lighttpd.net/pub/Releases/2.0.1/xcache-2.0.1.tar.gz 
  2. tar xf xcache-2.0.1.tar.gz 
  3. cd xcache-2.0.1 
  4. /usr/local/webserver/php/bin/phpize 
  5. ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 
  6. make&&make install 
  7.   
PDO_MYSQL
 
  1. ln -sv /usr/local/webserver/mysql/include/* /usr/local/include/ 
  2. tar zxvf PDO_MYSQL-1.0.2.tgz 
  3. cd PDO_MYSQL-1.0.2/ 
  4. /usr/local/webserver/php/bin/phpize 
  5. ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql 
  6. make 
  7. make install 
  8. cd ../ 
 
ImageMagick
 
  1. tar zxvf ImageMagick.tar.gz 
  2. cd ImageMagick-6.5.1-2/ 
  3. ./configure 
  4. make 
  5. make install 
  6. cd ../ 
  7. wget http://pecl.php.net/get/imagick 
imagick 需要是最新版本的,如果是舊版本的安裝會報錯,我這裏用的是imagick-3.1.0RC2.tgz
 
  1. [root@localhost software]# tar xf imagick-3.1.0RC2.tgz  
  2. [root@localhost imagick-3.1.0RC2]# /usr/local/webserver/php/bin/phpize  
  3. Configuring for: 
  4. PHP Api Version:         20100412 
  5. Zend Module Api No:      20100525 
  6. Zend Extension Api No:   220100525 
  7. [root@localhost imagick-3.1.0RC2]# ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 
  8. [root@localhost imagick-3.1.0RC2]# make install 
  9. Installing shared extensions:     /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525/ 
  10. Installing header files:          /usr/local/webserver/php/include/php/ 
 
php.ini配置
 
  1. sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "imagick.so"\n#' /usr/local/webserver/php/etc/php.ini 
 
在/usr/local/php/etc/php.ini中添加如下內容
 
  1. [xcache-common] 
  2. zend_extension = /usr/local/php/lib/php/extensions/xcache.so  
  3. [xcache.admin]  
  4. ; Change xcache.admin.user to your preferred login name  
  5. xcache.admin.user = "admin"  
  6. ; Change xcache.admin.pass to the MD5 fingerprint of your password  
  7. ; Use md5 -s "your_secret_password" to find the fingerprint  
  8. xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"  
  9. [xcache]  
  10. ; Change xcache.size to tune the size of the opcode cache  
  11. xcache.size = 24M  
  12. xcache.shm_scheme = "mmap"  
  13. xcache.count = 2  
  14. xcache.slots = 8K  
  15. xcache.ttl = 0  
  16. xcache.gc_interval = 0  
  17. ; Change xcache.var_size to adjust the size of variable cache  
  18. xcache.var_size = 8M  
  19. xcache.var_count = 1  
  20. xcache.var_slots = 8K  
  21. xcache.var_ttl = 0  
  22. xcache.var_maxttl = 0  
  23. xcache.var_gc_interval = 300  
  24. xcache.test = Off  
  25. xcache.readonly_protection = On  
  26. xcache.mmap_path = "/tmp/xcache"  
  27. xcache.coredump_directory = ""  
  28. xcache.cacher = On  
  29. xcache.stat = On  
  30. xcache.optimizer = Off  
  31. [xcache.coverager]  
  32. xcache.coverager = On  
  33. xcache.coveragedump_directory = "" 
 xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e" 
結果需要使用echo -n "123456" | md5sum
求出hash值
 
apache的配置
將着兩行添加到/etc/httpd/httpd.conf文件中去
 
  1. AddType application/x-httpd-php  .php 
  2. AddType application/x-httpd-php-source  .phps 
檢查LoadModule php5_module        modules/libphp5.so  這一行是否被啓用
如果被註釋 就將它啓用起來 
 
然後啓動httpd  方法
/usr/local/webserver/apache/bin/apachectl -k start|stop|restart
 
你可以寫個測試頁面測試模塊加載是否正常 
<?php
phpinfo();
?>
 
測試php和數據庫連接是否正常
<?php
$link=mysql_connect('root',"localhost","passwd");
if (!$link)
echo "connecting faild..";
else
echo "connecting successful!!";
mysql_close();
?>

你也可以使用命令方式查看是否成功加載模塊:

 

/usr/local/php/bin/php -m

 
 
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章