看板 Knuckles_note
作者 標題 [CentOS] PHP 安裝與設定
時間 2013年09月09日 Mon. PM 12:32:57
安裝環境: Linode 的 CentOS 6.5 64bit
新版 CentOS 7 請改至 [CentOS] PHP 安裝與設定 (CentOS 7) - KnucklesNote板 - Disp BBS
◎ 安裝 PHP
先安裝 Apache http://disp.cc/b/11-6vX5
安裝Apache的模組 mod_php
$ yum install php
安裝常用的 php 的模組
$ php-mbstring php-gd php-mysql php-xml
CentOS 6.5 安裝的是 PHP 5.3.3
重新啟動 httpd
$ service httpd restart
檢查看看有沒有裝成功
$ php -v
PHP 5.3.3 (cli) (built: Jul 12 2013 20:35:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
利用 phpinfo() 檢查看看 httpd 與 php 是否正常
$ vim /var/www/html/test_httpd.php
建立一個php網頁檔,內容輸入:
<?php phpinfo(); ?>
打開瀏覽器,網址輸入 http://(server的ip位址)/test_httpd.php
可以看到 PHP 版本為 5.3.3、Apache 版本為 2.2.15
![[圖]](http://knuckles.disp.cc/pic/pick/20140422_001_53.png)
◎ 修改 PHP 設定檔
# vim /etc/php.ini
;是否要使用像這種 <?=$foo?> 的簡寫符號
short_open_tag = Off
;output_buffering
output_buffering = 4096
;記憶體用量限制
memory_limit = 128M
;不顯示error,而是記錄在 /var/log/httpd/error_log
display_errors = Off
log_errors = On
;ignore_repeated_errors = Off
ignore_repeated_errors = On
;ignore_repeated_source = Off
ignore_repeated_source = On
設定error的log檔位置
;error_log = php_errors.log
error_log = /var/log/php_errors.log
;設定時區
;date.timezone =
date.timezone = Asia/Taipei
; cookie存活時間(秒),設為0的話瀏覽器關掉即到期
;session.cookie_lifetime = 0
session.cookie_lifetime = 3600
; session存活時間
;session.gc_maxlifetime = 1440
session.gc_maxlifetime = 3600
重啟 apache
$ service httpd reload
==== 錯誤解決記錄 ====
使用 phpmailer 時出現
Mailer Error: Language string failed to load: connect_host
→ 安裝 openssl 即可
$ yum install openssl
--
※ 作者: Knuckles 時間: 2013-09-09 12:32:57
※ 編輯: Knuckles 時間: 2017-02-14 14:54:41
※ 同主題文章:
06-25 19:15 □ [CentOS] Apache+PHP+MySQL 安裝與設定 (CentOS6.2)
09-09 11:53 □ [CentOS] Apache 安裝與設定 (CentOS 6.5)
● 09-09 12:32 □ [CentOS] PHP 安裝與設定 (CentOS 6.5)
09-09 15:19 □ [CentOS] MySQL 安裝與設定 (CentOS 6.5)
09-09 18:01 □ [CentOS] phpMyAdmin 安裝與設定
※ 看板: KnucklesNote 文章推薦值: 1 目前人氣: 0 累積人氣: 1705
回列表(←)
分享