| View previous topic :: View next topic |
| Author |
Message |
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 1:50 pm Post subject: help! temp files 'partially' created? |
|
|
hey guys
I hope someone can help. I'm sure this problem has cropped up before but I seem to have my own version of it so hopefully someone can help.
I have set up the four required directories to run Smarty (templates, templates_c, cache and config)
At first I had some openbasedir errors, but I have changed my vhost config and used CHMOD / CHOWN to fix these issues. However, when I run a test page I am getting the following error:
Warning: Smarty error: problem writing temporary file '/var/www/vhosts/myhost.com/templates_c/wrt4d6e479ce5964' in /var/www/vhosts/myhost.com/httpdocs/lib/smarty/Smarty.class.php on line 1091
however, when I look in that directory, temporary files with random names, but with a file size of zero are created. So the system can access the directory and write to it at some level, but then seems to get stuck. Therefore I am completely at a loss to understand what I've done wrong here. I've spent several hours on this trying various combinations before posting - any help would be much appreciated.
thanks in advance. |
|
| Back to top |
|
ericdeng Smarty Rookie
Joined: 01 Mar 2011 Posts: 9
|
Posted: Wed Mar 02, 2011 1:53 pm Post subject: Re: help! temp files 'partially' created? |
|
|
| Quote: | | Maybe this folder is incomplete or you have permission problems. |
|
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 2:11 pm Post subject: |
|
|
I'm not sure I understand - how can a folder be incomplete?
I obviously have some kind of permission issue but I can't figure out what it is - how could the script be able to create files in the directory at all?It's not saying it can't create them - in fact it seems to get half way, i.e it creates some empty files (size zero) with random names, but then something goes wrong. Each time I try to access the page, two randomly name files of size zero are created in the compile folder. |
|
| Back to top |
|
ericdeng Smarty Rookie
Joined: 01 Mar 2011 Posts: 9
|
Posted: Wed Mar 02, 2011 2:21 pm Post subject: |
|
|
| highryse wrote: | I'm not sure I understand - how can a folder be incomplete?
I obviously have some kind of permission issue but I can't figure out what it is - how could the script be able to create files in the directory at all?It's not saying it can't create them - in fact it seems to get half way, i.e it creates some empty files (size zero) with random names, but then something goes wrong. Each time I try to access the page, two randomly name files of size zero are created in the compile folder. |
The frist one depending on your config.php file for smarty
The second you need give the fully W/R permission for compile file if u r using Xnix OS.
empty files mean some issue with ur smarty_presentation_object file |
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 3:04 pm Post subject: |
|
|
thanks - however I am still not sure how I can fix these problems. I have tried setting the directory to 777 to see if this would work but this made no difference. Also I am not sure where the config file is for Smarty. I added
$smarty->use_sub_dirs = false;
to see if this would work, but sadly not.
by the way, the server is linux / centos. |
|
| Back to top |
|
ericdeng Smarty Rookie
Joined: 01 Mar 2011 Posts: 9
|
Posted: Wed Mar 02, 2011 3:12 pm Post subject: |
|
|
Config file need defined by urself base on your requirement
directory to 777 (templates_c)
This a demo for config.php
| Code: |
<?php
// SITE_ROOT contains the full path to the root folder
define('SITE_ROOT', dirname(dirname(__FILE__)));
define('PRESENTATION_DIR', SITE_ROOT . '/presentation/');
define('SMARTY_DIR', SITE_ROOT . '/libs/');
define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates');
define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c');
define('CONFIG_DIR', SITE_ROOT . '/include/configs/');
define('CACHE_DIR', SITE_ROOT . '/cache/');
?>
|
After this setup ur Smarty's constructor base on ur current version.
FYI that's all i can told so far.
Last edited by ericdeng on Wed Mar 02, 2011 3:13 pm; edited 1 time in total |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7038 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 02, 2011 3:13 pm Post subject: |
|
|
| are there any errors in php, apache, or system logs that might give a clue? |
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 5:39 pm Post subject: |
|
|
no clues in the error log from what I can see. I am really stuck, no idea what to do  |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7038 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 02, 2011 5:44 pm Post subject: |
|
|
| That is very strange that a file gets written with no content. Is this a vanilla install of Smarty? Can you make a very simple install for a test? Did you try both Smarty 2 and 3 just for a test? I'm going to guess that this is a file permission problem, or some other issue related to your environment. That is why I urge to search the php/apache/system logs for any file-based errors or warnings. |
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 6:05 pm Post subject: |
|
|
I'll have a look again in the system logs.
I can't use Smarty 3 as the PHP version is only 5.1 currently. I could upgrade but would rather not do so as I have other sites running on this server. However I think it is an early version of Smarty 2 so I could try a newer one. - EDIT - it says version 2.6.9 so I don't think this is the problem.
Because of all the problems I've been having, I have done this as a simple install which looks like this:
ini_set('display_errors', 1);
error_reporting(E_ALL);
require('/var/www/vhosts/mysite.com/httpdocs/lib/smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->debugging = TRUE;
$smarty->use_sub_dirs = false;
$smarty->template_dir = '/var/www/vhosts/mysite.com/templates';
$smarty->compile_dir = '/var/www/vhosts/mysite.com/templates_c';
$smarty->config_dir = '/var/www/vhosts/mysite.com/config';
$smarty->cache_dir = '/var/www/vhosts/mysite.com/cache';
$smarty->assign('name', 'Ned');
$smarty->display('index.tpl'); |
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 6:45 pm Post subject: |
|
|
ok, I started again from scratch. I put Smarty in the folder recommended in the tutorial, and followed all the installation instructions. I set the permissions correctly and worked through the whole quick install process.
and.... EXACTLY the same problem. Two random, empty files created in the compile directory, and then the usual errors.
I also tried
$smarty->testInstall();
but it seems this is only in version 3.
I'm about ready to give up, I've spent more than a whole day on this  |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7038 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 02, 2011 6:48 pm Post subject: |
|
|
| Give Smarty 3 a shot with 5.1. The problem we had on 5.1 ended up not being a Smarty problem but a configuration problem, but we left the requirement at 5.2 for good measure. Give that a shot and see what it does. Somehow I don't think this is a Smarty issue though. |
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 6:52 pm Post subject: |
|
|
It's very, very confusing because I have Smarty running on another vhost with no problem.
I will try Smarty 3 and see what happens.
For reference, here is an example of the files that get created:
wrtMxgaBY
that is the filename - no extensions, and empty. Each time I try to load the page, two files like this are created, all beginning with 'wrt' and then random. |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7038 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 02, 2011 6:59 pm Post subject: |
|
|
| what does the php.ini settings look like? do you have any file operations restrictions? |
|
| Back to top |
|
highryse Smarty Rookie
Joined: 16 Dec 2010 Posts: 25
|
Posted: Wed Mar 02, 2011 7:02 pm Post subject: |
|
|
I can have a look at php.ini - what should I be looking for?
I tried it with Smarty 3, and I get the message below. A single empty file with the name 'wrtXXXXX' is made. (where XXXXX is random).
Fatal error: Uncaught exception 'SmartyException' with message 'unable to write file /var/www/vhosts/mysite.com/smarty/templates_c/wrt4d6e91b4006bc' in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_write_file.php:36 Stack trace: #0 /usr/local/lib/php/Smarty/sysplugins/smarty_internal_template.php(272): Smarty_Internal_Write_File::writeFile('/var/www/vhosts...', '<?php /* Smarty...', Object(Smarty)) #1 /usr/local/lib/php/Smarty/sysplugins/smarty_internal_template.php(422): Smarty_Internal_Template->compileTemplateSource() #2 /usr/local/lib/php/Smarty/sysplugins/smarty_internal_template.php(567): Smarty_Internal_Template->renderTemplate() #3 /usr/local/lib/php/Smarty/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #4 /usr/local/lib/php/Smarty/Smarty.class.php(382): Smarty->fetch('index.tpl', NULL, NULL, NULL, true) #5 /var/www/vhosts/mysite.com/httpdocs/smartytest.php(25): Smarty->display('index.tpl') #6 {main} thrown in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_write_file.php on line 36 |
|
| Back to top |
|
|