搜尋此網誌

2013年9月5日 星期四

PHP開啟錯誤提示、安裝Smarty(環境:CentOS 6.4 32位元)

##CentOS 6.4,PHP開啟錯誤提示:

1.開啟php.ini
# vi /etc/php.ini

2.搜尋下行,把Off值改成On
display_errors = Off

3.搜索下行
error_reporting = E_ALL & ~E_DEPRECATED
修改为
error_reporting = E_ALL | E_STRICT

4.修改httpd.conf,
# vi /etc/httpd/conf/httpd.conf

添加以下兩行:
php_flag display_errors on
php_value error_reporting 2039

5. 重新啟動Apache
# service httpd restart

///////////////////////////////////////////////
安裝Smarty在CentOS6.4上:

### 以下共3行終端機指令
su
tar zxvf Smarty-3.1.14.tar.gz
cp -r Smarty-3.1.14/libs/* /usr/lib/php/smarty
###

新建Smarty所需的相關目錄:
### 以下共8行終端機指令
cd /var/www/html
mkdir smarty
mkdir smarty/templates
mkdir smarty/templates_c
mkdir smarty/cache
mkdir smarty/configs
chmod 777 smarty/templates_c
chmod 777 smarty/cache
###

新建一个PHP檔:
# vi /var/www/html/index.php
---新增以下內容
<?php
require('/usr/lib/php/smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/var/www/html/smarty/templates';
$smarty->compile_dir = '/var/www/html/smarty/templates_c';
$smarty->cache_dir = '/var/www/html/smarty/cache';
$smarty->config_dir = '/var/www/html/smarty/configs';

$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');
?>
---

新建模板檔:
vi /var/www/html/smarty/templates/index.tpl
---新增以下內容
<html>
  <head>
    <title>Smarty</title>
  </head>
  <body>
      Hello, {$name}!
  </body>
</html>
---

打開瀏覽器看看 ->  http://localhost/

2013年9月2日 星期一

CentOS 6.4 上快速安裝LAMP環境+phpmyadmin

切換成root管理員
# su

設置LAMP環境(安裝php MySQL httpd):
# yum  -y  install  httpd  php  php-mysql  mysql  mysql-server

(非必須) 安裝記事本(圖形介面可以比較直覺編輯文檔,非圖形介面請勿安裝)
# yum -y install gedit

開機自動啟動MySQL
# chkconfig mysqld on

現在啟動MySQL
# /etc/init.d/mysqld start

開機自動啟動Web Server
# chkconfig httpd on

現在啟動Web Server
# /etc/init.d/httpd start

修改MySQL的root密碼
# mysqladmin -u root password '123456'

以下是安裝phpmyadmin:
# rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm

# yum install phpmyadmin

重啟Web Server:
# service httpd restart


Web Server ->  http://localhost/

MySQL on phpMyAdmin -> http://localhost/phpmyadmin/