7) 安装pear中的相关套件;
===============================================
參考網站:
http://pear.php.net/
yum list | grep php-devel; #安装pear需要调用PHP的开发工具phpize;
yum install php-devel; #用yum命令安装PHP开发工具;
看看是否还有遗漏的pear套件需要安装:
yum list | grep php-pear; (CentOS4.4中的搜尋結果)
------------------------------------------------------------------------------
php-pear.i386 4.3.9-3.22.3 installed
pearpc.i386 0.3.1-1.2.el4.rf dag
php-pear-excel.noarch 0.9.0-1.el4.rf dag
php-pear-log.noarch 1.9.3-1.2.el4.rf dag
php-pear-mail_mime.noarch 1.3.1-1.2.el4.rf dag
php-pear-ole.noarch 0.5-2.2.el4.rf dag
php-pear-phpunit.noarch 1.3.1-1.2.el4.rf dag
------------------------------------------------------------------------------
yum list | grep php-pear; (CentOS5中的搜尋結果)
------------------------------------------------------------------------------
php-pear.noarch 1:1.4.9-4 installed
php-pear-date.noarch 1.4.6-1.el5.rf dag
php-pear-excel.noarch 0.9.0-1.el5.rf dag
php-pear-file.noarch 1.2.2-1.el5.rf dag
php-pear-log.noarch 1.9.3-1.el5.rf dag
php-pear-mail_mime.noarch 1.3.1-1.el5.rf dag
php-pear-ole.noarch 0.5-2.el5.rf dag
------------------------------------------------------------------------------
yum install php-pear-date; #
yum install php-pear-ole; #
yum install php-pear-excel; #肯能會跟php-pear-1.4.9-4有沖突錯誤;
yum install php-pear-file; #
yum install php-pear-log; #肯能會跟php-pear-1.4.9-4有沖突錯誤;
yum install php-pear-mail_mime; #肯能會跟php-pear-1.4.9-4有沖突錯誤;
yum list | grep php-pecl;
------------------------------------------------------------------------------
php-pecl-fileinfo.i386 1.0.4-1.el5.rf dag
php-pecl-mailparse.i386 2.1.1-1.el5.rf dag
php-pecl-memcache.i386 2.1.2-1.el5.rf dag
php-pecl-session_mysql.i386 1.9-1.el5.rf dag
yum install php-pecl-fileinfo;
yum install php-pecl-mailparse;
yum install php-pecl-memcache;
yum install php-pecl-session_mysql;
------------------------------------------------------------------------------
请注意: 用YUM安装pear模块会自动在pear中做好相关配置,pear自身也有命令可安装模块,
如果相关模块没有YUM套件可供安装,那么也可以嘗試用pear自己的命令来安装.
pear list; #显示当前pear已经安装的套件列表;
请注意: Horde官方网站推荐使用Fileinfo和memcache. 因为Fileinfo允许Horde GWE模块
通过分析文件内容来猜测其MIME类型,如果不启用Fileinfo, Horde GWE将会调用它自己的
PHP 代码来执行MIME匹配, 然而这种匹配是较慢速和不精确的, 而且其所能检测的类型比
PECL扩展功能所能检测的类型更少.
执行如下pear命令安装套件: #如有需要,可用whereis pear检查当前pear路经;
pecl install fileinfo;
pecl install memcache;
檢查安裝結果(請留意生成so路径):
ll /usr/lib/php4/fileinfo.so;
ll /usr/lib/php4/memcache.so;
在CentOS5中可能是如下路徑:
ll /usr/lib/php/modules/fileinfo.so;
ll /usr/lib/php/modules/memcache.so;
如有需要,可以执行如下命令安装相关模块(正常情况下相关模块应该已经配置好了):
pear install -o Log Mail Mail_Mime DB Date File;
pear -d preferred_state=beta install -a Services_Weather;
如有需要,赋予模块文件执行权限:
chmod 755 /usr/lib/php4/fileinfo.so;
chmod 755 /usr/lib/php4/memcache.so;
說明:
pear list-all; (顯示所有套件)
pear list; (顯示已裝套件)
pear list; #再检查一下,显示新安装的套件列表;
------------------------------------------------------------------------------
Installed packages:
===================
Package Version State
Archive_Tar 1.1 stable
Console_Getopt 1.2 stable
DB 1.6.2 stable
Fileinfo 1.0.4 stable #注: 这是新安装的
HTTP 1.2.2 stable
Mail 1.1.3 stable
Net_SMTP 1.2.3 stable
Net_Socket 1.0.1 stable
PEAR 1.3.2 stable
XML_Parser 1.0.1 stable
XML_RPC 1.1.0 stable
memcache 2.1.0 stable #注: 这是新安装的
------------------------------------------------------------------------------
注意: 运行上述pear命令,會调用到PHP功能,而且必须引用或者写入/var和/usr以及/tmp等
目录,请确认HTTPD和PHP具有讀寫相关目錄的权限.例如,请检查php.ini文件中的safe_mode
和open_basedir设置是否适当.
==============================================================================
8) 配置PHP扩展模组,检查PHP的相关扩展功能是否正确安装和正常调用;
==============================================================================
若上述PHP擴展模組是用YUM命令自動安裝的(或者是下載RPM套件來安裝的),安裝程序也許
已經自動將其so文件復制到PHP的模組目錄下(/usr/lib/php4/或/usr/lib/php/modules),
并會自動在PHP的配置文檔掃描目錄(由編譯項目with-config-file-scan-dir所指定,通常
是/etc/php.d/)下生成附加的ini文件, 那么PHP在啟動時就會自動掃描這些目錄下的相關
文件,并自動加載相關模塊.
但上述两个用pear命令产生的模块,則可能不會自動配置其在PHP中的加載項目, 而必须您
自己手工去修改php.ini中的設置,令PHP在啟動時加载相關项目, 才能使PHP正确调用擴展
模組的功能(所以本手冊極力推薦用YUM或RPM方式來安裝);
當Horde安裝完成後,您可以利用它所提供的測試頁面(test.php)來檢查各項功能是否正常,
您也可以用PHP的phpinfo()函數的返回信息,來判斷當前PHP是否已經正確加載相關模組,或
也可以用如下命令行方式,來檢查當前PHP所能支持的模組:
/usr/bin/php -i | grep '[sS]upport';
如果相關模組并未顯示在檢測信息中,就必須調整設置,方法如下:
首先检查php.ini中extension_dir的設置值,找出擴展模組的文檔路徑,例如:
extension_dir = /usr/lib/php4
或者:
extension_dir = "/usr/lib/php/modules"
然后檢查此路徑和相關的擴展模塊的模組文件:
ll /usr/lib/php4/; #检查一下这个目录中都有什么模组文件(*.so);
ll /etc/php.d/; #检查一下附加文件,对比上述模组文件(*.ini);
要配置PHP正确调用扩展模组的功能,首先要将扩展模块的so文件放置在指定的模块目录下.
例如: 上一步骤中pear命令所生成的so文件,已经自动放置在PHP的模组目录下,可选择如下
(a)或(b)两种方法中的任意一种,來配置PHP加载模组文件:
------------------------------------------------------------------------------
a) 在/etc/php.d/目录下手工创建一个ini文件,让PHP自动扫描识别扩展模组;
------------------------------------------------------------------------------
vi /etc/php.d/fileinfo.ini; #请输入如下两行内容
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Enable mysql fileinfo module
extension=fileinfo.so
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
chown root.root /etc/php.d/fileinfo.ini;
chmod 644 /etc/php.d/fileinfo.ini;
vi /etc/php.d/memcache.ini; #请输入如下两行内容
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Enable memcache extension module
extension=memcache.so
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
chown root.root /etc/php.d/memcache.ini;
chmod 644 /etc/php.d/memcache.ini;
------------------------------------------------------------------------------
------------------------------------------------------------------------------
b) 在php.ini配置文件中添加扩展模组加载语句;
------------------------------------------------------------------------------
vi /etc/php.ini; #添加如下两行,加载上述两个模组:
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
extension=fileinfo.so
extension=memcache.so
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
------------------------------------------------------------------------------
然后重新啟動HTTPD服務,令PHP加載擴展模組之后,就可用web頁面顯示 phpinfo() 函数的
返回信息,請搜索一下 phpinfo()的輸出內容,以判斷PHP是否正确加载了上述擴展模組.也
可以直接用如下命令來顯示PHP的加載結果:
/usr/bin/php -i | grep '[sS]upport' | grep fileinfo;
/usr/bin/php -i | grep '[sS]upport' | grep memcache;
------------------------------------------------------------------------------
參考附录: PHP配置文件上载支持:
------------------------------------------------------------------------------
File upload support is required to allow attachments in mail composition and to
allow various importing features to work (e.g. importing PGP or S/MIME keys,
importing mbox files). To enable file upload support:
In your php.ini file, the following line must be present:
file_uploads = On
Your temporary upload directory must be writable to the user the web server is
running as. If you leave the configuration option upload_tmp_dir blank in php.ini,
PHP will use the default directory compiled into it (normally /tmp on Unix-like
systems).
Set the maximum size of the uploaded files via the upload_max_filesize configuration
option in php.ini. For example, to allow 5 MB attachments, place the following
line in your php.ini file:
upload_max_filesize = 5M
If either file_uploads is turned off, or your temporary upload directory is not
writable by the server, all file upload functionality will be disabled by Horde
Groupware Webmail Edition and will not be available to the user.
disabled memory_limit :
If PHP's internal memory limit is turned on and if not set high enough Horde
will not be able to handle large data items (e.g. large mail attachments in IMP).
If possible, you should disable the PHP memory limit by recompiling PHP without
the "--enable-memory-limit" flag. If this is not possible, then you should set
the value of memory_limit in php.ini to a sufficiently high value(Default value
of memory_limit: 32M).
------------------------------------------------------------------------------