View previous topic :: View next topic |
Author |
Message |
calebsg Smarty Rookie
Joined: 13 Sep 2007 Posts: 5
|
Posted: Thu Nov 06, 2008 8:02 pm Post subject: blank compiled template, perms ok I think |
|
|
Hi
This is my code
Code: | <?php
error_reporting(E_ALL);
echo "Starting smarty...<br>";
require_once('smarty_setup.php');
$smarty = new Smarty_toolbox();
$smarty->debugging = true;
$smarty->assign('month',((date("n") - 1) == 0 ? 1 : date("n") - 1));
$smarty->display('index.tpl');
echo "End of Smarty. <br>";
?> |
and the templates compiled by it are blank. Permissions on the cache and compile folder are 777. If I use readfile('/path/to/index.tpl') that works. As you can see, error reporting is turned on and the 'echo' command works fine too.
Would appreciate any help...am baffled by this one.
Thanks,
Caleb[/code] |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Fri Nov 07, 2008 7:54 am Post subject: |
|
|
Do you have display_errors on?
Code: | ini_set('display_errors', 1); |
_________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
calebsg Smarty Rookie
Joined: 13 Sep 2007 Posts: 5
|
Posted: Fri Nov 07, 2008 9:21 pm Post subject: |
|
|
Thanks, I added that to the script and still no luck. Any other ideas? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
calebsg Smarty Rookie
Joined: 13 Sep 2007 Posts: 5
|
Posted: Sat Nov 08, 2008 6:24 pm Post subject: |
|
|
Hi all,
Thank you for your help so far. I followed your recommendations to use the Smarty _Test.class.php with the file index2.php:
Code: | <?php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
error_reporting(E_ALL);
// include test extension
require('Smarty_Test.class.php');
// do this instead of $smarty = new Smarty();
// if you have your own extension, then have it
// extend Smarty_Test() instead of Smarty()
$smarty = new Smarty_Test();
$smarty->template_dir = '/usr/local/apache2/smarty/templates';
$smarty->compile_dir = '/usr/local/apache2/smarty/templates_c';
$smarty->cache_dir = '/usr/local/apache2/smarty/cache';
$smarty->config_dir = '/usr/local/apache2/smarty/configs';
$smarty->plugin_dir = '/usr/local/apache2/smarty/plugins';
$smarty->debugging = true;
//$smarty->assign('name', 'Ned');
//$smarty->display('index3.tpl');
$smarty->test();
exit();
?>
|
This is the output:
Code: | testing start:
template_dir is '/usr/local/apache2/smarty/templates'
real system path: /usr/local/apache2/smarty/templates
file perms: 0755
OK.
config_dir is '/usr/local/apache2/smarty/configs'
real system path: /usr/local/apache2/smarty/configs
file perms: 0755
OK.
plugins_dir (0) is 'plugins'
real system path:
Warning: fileperms() [function.fileperms]: stat failed for plugins in /usr/local/lib/php/Smarty/Smarty_Test.class.php on line 38
file perms:
error: plugins_dir 'plugins' does not exist.
compile_dir is '/usr/local/apache2/smarty/templates_c'
real system path: /usr/local/apache2/smarty/templates_c
file perms: 0775
error: compile_dir '/usr/local/apache2/smarty/templates_c' is not writable.
cache_dir is '/usr/local/apache2/smarty/cache'
real system path: /usr/local/apache2/smarty/cache
file perms: 0775
error: cache_dir '/usr/local/apache2/smarty/cache' is not writable.
testing complete.
|
This is the directory listing:
Code: | [root@toolbox smarty]# ls -l
total 20
drwxrwxr-x 2 nobody nobody 4096 Nov 8 09:55 cache
drwxr-xr-x 2 nobody nobody 4096 Sep 7 2007 configs
drwxr-xr-x 2 nobody nobody 4096 Nov 8 09:29 plugins
drwxr-xr-x 2 nobody nobody 4096 Nov 6 12:41 templates
drwxrwxr-x 2 nobody nobody 4096 Nov 8 10:17 templates_c
|
I thought I had the permissions right but clearly something is wrong...I haven't been on a Linux box for several months so I must be missing something. Also I am unsure of the plugins folder piece--it doesn't appear in the installation instructions: http://www.smarty.net/manual/en/installing.smarty.basic.php
Thanks
Caleb |
|
Back to top |
|
calebsg Smarty Rookie
Joined: 13 Sep 2007 Posts: 5
|
Posted: Sat Nov 08, 2008 6:45 pm Post subject: |
|
|
I changed the user and group on the templates_c folder to 'daemon' (the httpd user) and the error message on the templates_c folder changed to:
Code: | compile_dir is '/usr/local/apache2/smarty/templates_c'
real system path: /usr/local/apache2/smarty/templates_c
file perms: 0775
error: unable to write to /usr/local/apache2/smarty/templates_c/test_file |
It creates test_file in the folder:
Code: | [root@toolbox smarty]# ls -l templates_c
total 0
-rw-r--r-- 1 daemon daemon 0 Nov 8 10:42 test_file |
And clearly the permissions aren't right on that file. Not sure what piece affects the permissions on the new file though.
Caleb |
|
Back to top |
|
stew_mcgruff Smarty n00b
Joined: 30 Apr 2007 Posts: 2
|
Posted: Mon Dec 15, 2008 7:25 pm Post subject: |
|
|
I realize this thread was a bit old, but I was having the same problem today and came across it.
For me, the problem was being out of disk space. |
|
Back to top |
|
jaslorax Smarty n00b
Joined: 05 Jun 2009 Posts: 4
|
Posted: Fri Jun 05, 2009 1:48 am Post subject: Can't lick this problem |
|
|
Getting blank pages served (0kb files being created in templates_c)
Here's the situation:
We are setting up a new server (latest smarty stable release 2.6.25) and are having a problem with read/write and owner settings (form smarty template engine created files) that work or don't work depending on the user apache runs as (Due to Verio's [our host ] compile of suexec/apache we have to run apache as "user www group www" and smarty fails this way).
I am using the smarty_test.php and the test class as found here: double-u(3)-dot-phpinsider-dot-com/smarty-forum/viewtopic.php?t=4500 (sorry my user level doesn't permit url's yet)
I receive 2 errors: both are unable to write (to "templates_c" and "cache" directories). The test script creates the file "test_file" in the "cache" and "templates_c" directory and when the test passes it removes the created files. When I receive an error the created files have a user/group of www/www and permissions of 644.
If I do the following to the files that it creates in the above directories and run again then it works:
# chown myUser test_file
# chmod 664 test_file
If I run apache as User/Group of myUser/myUser it works - but this kills our cgi script execution as stated previously.
I have tried setting the SUID/GUID of the directories in question as well as setting umask to 2, but none of that had any effect on the files created in those directories. Is there some dependency I am missing? Why does the test script say it can't write when the files are clearly being created? Have also tried setting the directories to 777 - currently 775 and that has no effect - seems to be primarily a file permissions issue but I am uncertain exactly how smarty creates those files and how to control the process in a place with less effect on the security of my server - in other words without changing how suexec/apache runs . . .
Current Server:
httpd
Server version: Apache/2.2.11 (Unix)
Server built: Jan 6 2009 12:04:11
php
PHP 5.2.9 with Suhosin-Patch 0.9.7 (cli) (built: Mar 16 2009 18:29:43)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
FYI - Old Server History:
On our old server smarty had been working while running apache as www/www with a user/group of myUser/myUser set in the virtual host section of httpd.conf - some error recently occurred there (no clue what) and smarty stopped working so I set apache to run as user/group of myUser/myUser and now smarty works there - it did not affect our cgi on that server presumably because it is not using suexec, but I am uncertain of all of that servers settings as I did not take part in its configuration. The files of the user directory were originally set to user/group of myUser/www so that is what I have done on the new server - myUser is not a member of www group nor is www a member of myUser group . . .
-- update
set umask to 2 and that part works but then:
I was surprised to get a different result with a simple php write script then with the one smarty forums provided (here: www-dot-phpinsider-dot-com/smarty-forum/viewtopic.php?t=4500).
The one from the link above fails to write, but with a simple php write script (link below) with an already created file - & all the same permissions as the smarty test one I get success. Why would the smarty one fail when I can clearly read and write a file?
The Simple PHP script that writes successfully is from : us3-dot-php-dot-net/manual/en/function.fwrite.php - Example #1 . . . |
|
Back to top |
|
|