php 5.4.4追加モジュール(memcache,Xcache,ImageMagick,PDO_MYSQL)
14290 ワード
コンパイルインストールapache
phpとphpモジュールをコンパイルするにはmysqlが必要ですので、mysqlデータベースをインストールしてから次の手順に従います.
php5.4
公式サイトにphp 5.4.4をダウンロードします
関連モジュールのインストール(memcache,xcache,PDO_mysql,ImageMagick):
memcache
xcache
php 5.4 eaccelerator-0.9.6.1の互換性ができていない場合、インストールプロセスが間違っています.
代わりにxcacheを使います
PDO_MYSQL
ImageMagick
imagickは最新バージョンが必要ですが、古いバージョンのインストールであればエラーが発生します.私がここで使っているのはimagick-3.1.0 RC 2.tgzです.
php.ini構成
/usr/local/php/etc/php.iniに次の内容を追加します.
xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"
結果はecho-n"123456"|md 5 sumを使用する必要があります
hash値を求める
apacheの構成
2行を/etc/httpd/httpd.confファイルに追加
LoadModule php 5_の確認module modules/libphp5.so この行が有効になっているかどうか
コメントされている場合は有効にします
httpdを起動します 方法
/usr/local/webserver/apache/bin/apachectl -k start|stop|restart
テストページを書いてモジュールのロードが正常かどうかをテストできます.
phpinfo();
?>
phpとデータベースの接続が正常かどうかをテストします
$link=mysql_connect('root',"localhost","passwd");
if (!$link)
echo "connecting faild..";
else
echo "connecting successful!!";
mysql_close();
?>
また、コマンドを使用してモジュールのロードに成功したかどうかを確認することもできます.
/usr/local/php/bin/php -m
- wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.22.tar.gz
- tar xf httpd-2.2.22.tar.gz
- cd httpd-2.2.22
- ./configure --prefix=/usr/local/webserver/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib
- make&& make install
phpとphpモジュールをコンパイルするにはmysqlが必要ですので、mysqlデータベースをインストールしてから次の手順に従います.
php5.4
公式サイトにphp 5.4.4をダウンロードします
- cd php-5.4.4
- ./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
- make ZEND_EXTRA_LIBS='-liconv'
- make install
関連モジュールのインストール(memcache,xcache,PDO_mysql,ImageMagick):
memcache
- tar zxvf memcache-2.2.5.tgz
- cd memcache-2.2.5/
- /usr/local/webserver/php/bin/phpize
- ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
- make
- make install
- cd ../
xcache
php 5.4 eaccelerator-0.9.6.1の互換性ができていない場合、インストールプロセスが間違っています.
- eaccelerator-0.9.6.1/eaccelerator.c:1938: error: ‘eaccelerator_functions’ undeclared here (not in a function)
代わりにxcacheを使います
- wget -c http://xcache.lighttpd.net/pub/Releases/2.0.1/xcache-2.0.1.tar.gz
- tar xf xcache-2.0.1.tar.gz
- cd xcache-2.0.1
- /usr/local/webserver/php/bin/phpize
- ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
- make&&make install
-
PDO_MYSQL
- ln -sv /usr/local/webserver/mysql/include/* /usr/local/include/
- tar zxvf PDO_MYSQL-1.0.2.tgz
- cd PDO_MYSQL-1.0.2/
- /usr/local/webserver/php/bin/phpize
- ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
- make
- make install
- cd ../
ImageMagick
- tar zxvf ImageMagick.tar.gz
- cd ImageMagick-6.5.1-2/
- ./configure
- make
- make install
- cd ../
- wget http://pecl.php.net/get/imagick
imagickは最新バージョンが必要ですが、古いバージョンのインストールであればエラーが発生します.私がここで使っているのはimagick-3.1.0 RC 2.tgzです.
- [root@localhost software]# tar xf imagick-3.1.0RC2.tgz
- [root@localhost imagick-3.1.0RC2]# /usr/local/webserver/php/bin/phpize
- Configuring for:
- PHP Api Version: 20100412
- Zend Module Api No: 20100525
- Zend Extension Api No: 220100525
- [root@localhost imagick-3.1.0RC2]# ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
- [root@localhost imagick-3.1.0RC2]# make install
- Installing shared extensions: /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525/
- Installing header files: /usr/local/webserver/php/include/php/
php.ini構成
- 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"
#' /usr/local/webserver/php/etc/php.ini
/usr/local/php/etc/php.iniに次の内容を追加します.
- [xcache-common]
- zend_extension = /usr/local/php/lib/php/extensions/xcache.so
- [xcache.admin]
- ; Change xcache.admin.user to your preferred login name
- xcache.admin.user = "admin"
- ; Change xcache.admin.pass to the MD5 fingerprint of your password
- ; Use md5 -s "your_secret_password" to find the fingerprint
- xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"
- [xcache]
- ; Change xcache.size to tune the size of the opcode cache
- xcache.size = 24M
- xcache.shm_scheme = "mmap"
- xcache.count = 2
- xcache.slots = 8K
- xcache.ttl = 0
- xcache.gc_interval = 0
- ; Change xcache.var_size to adjust the size of variable cache
- xcache.var_size = 8M
- xcache.var_count = 1
- xcache.var_slots = 8K
- xcache.var_ttl = 0
- xcache.var_maxttl = 0
- xcache.var_gc_interval = 300
- xcache.test = Off
- xcache.readonly_protection = On
- xcache.mmap_path = "/tmp/xcache"
- xcache.coredump_directory = ""
- xcache.cacher = On
- xcache.stat = On
- xcache.optimizer = Off
- [xcache.coverager]
- xcache.coverager = On
- xcache.coveragedump_directory = ""
xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"
結果はecho-n"123456"|md 5 sumを使用する必要があります
hash値を求める
apacheの構成
2行を/etc/httpd/httpd.confファイルに追加
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
LoadModule php 5_の確認module modules/libphp5.so この行が有効になっているかどうか
コメントされている場合は有効にします
httpdを起動します 方法
/usr/local/webserver/apache/bin/apachectl -k start|stop|restart
テストページを書いてモジュールのロードが正常かどうかをテストできます.
phpinfo();
?>
phpとデータベースの接続が正常かどうかをテストします
$link=mysql_connect('root',"localhost","passwd");
if (!$link)
echo "connecting faild..";
else
echo "connecting successful!!";
mysql_close();
?>
また、コマンドを使用してモジュールのロードに成功したかどうかを確認することもできます.
/usr/local/php/bin/php -m