的安裝過程總是相同的apache的,但包管理器和包名稱會有所不同,具體取決於使用的分發版本,版本和/或存儲庫。一般而言,步驟是:
a) at first, user privilege escalation is required, either obtained with the commands su
or sudo
.
b) then one can install the absent PHP module with a package manager.
c) after that, restarting the apache2
HTTP daemon is required to load the module.
d) at last, one can run php -m | grep imap
to see if the PHP module is now available.
在Ubuntu的的APT
包php5-imap
(或php-imap
)可以BEI安裝有apt-get
:
apt-get install php5-imap
service apache2 restart
在的Debian,所述APT
包php5-imap
可以是(或apt-get
):
aptitude install php5-imap
apache2ctl graceful
在CentOS的和的Fedora的RPM
包php-imap
可以yum
安裝(提示:包的名稱使用Webtatic回購時可能有一些相似php56w-imap
或php71w-imap
):
yum install php-imap
service httpd restart
在systemd
系統上,當使用systemd units時,重啓單元httpd.service
的命令爲:
systemctl restart httpd.service
上述的解決方案有問題,當模塊中已經提到:
/etc/php5/apache2/php.ini
它可能拋出:
PHP Warning: Module 'imap' already loaded in Unknown on line 0
出現這種情況,因爲它是在默認引用php.ini
文件(至少在Ubuntu 12.04上)和PHP模塊最多隻能引用一次。使用INI
片段加載模塊建議,而該目錄/etc/php5/conf.d/
(該路徑也可以變化)正被掃描INI
文件:
/etc/php5/conf.d/imap.ini
的Ubuntu還具有專有命令來管理PHP模塊,在重新啓動前執行該網絡服務器:
php5enmod imap
php5dismod imap
一旦IMAP
模塊加載到服務器時,應PHP IMAP Functions然後變得可用;在嘗試使用它之前,最好的做法可能是檢查模塊是否被加載到了。
你能告訴你的代碼? – 2012-03-11 11:20:19
@Waynn代碼已添加。 – Sumit 2012-03-11 11:26:21
請在PHP中添加PHP標籤。 – 2012-07-17 00:07:54