搜尋此網誌

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/

沒有留言:

張貼留言