cancel
Showing results for 
Search instead for 
Did you mean: 

/tmp file filling up and causing scripts to fail

megapixel
Dabbler
Posts: 24
Registered: ‎30-07-2007

/tmp file filling up and causing scripts to fail

Hi,
My ccgi website is currently displaying warning messages top and bottom about the tmp file, e.g:
"Warning: session_start() [function.session-start]: open(/tmp/sess_65a65ca1a5937199859b10f39dcc1714, O_RDWR) failed: File too large (27)"
"Warning: Unknown: open(/tmp/sess_65a65ca1a5937199859b10f39dcc1714, O_RDWR) failed: File too large (27) in Unknown on line 0"

I currently have a ticket raised with PN that goes back to Christmas when it started, at which time PN said: "We have become aware of an issue on another of our user's CGI space, which was causing the tmp file to fill up. This resulted in scripts failing, and we apologise for the inconvenience. However we have now taken action such that the problem should not recurr." Unfortunately the problem did recur and keeps on recurring and evidently the 'fix' (if one was produced) hasn't worked.  Sad
If that wasn't bad enough, the problem actually goes back years. In 2007  Shocked when it began happening (but might have been even earlier) PN said "...it does look like one of our CCGI servers ran out of disk space in the /tmp directory whilst it was trying to write the session cookie to disk. Unfortunately the message gives no hint as to which server this occurred on."
Am I being unreasonable to expect PN to have fixed the problem after 4 years? Is it really that insoluble?
If anyone got any suggestions, pleeeeeeeeeeease let PN know cos it's driving me mad. Thanks.

16 REPLIES 16
Peter_Vaughan
Community Veteran
Posts: 14,469
Registered: ‎30-07-2007

Re: /tmp file filling up and causing scripts to fail

The cgi kit is very old and PN are not willing to spend any money on it to upgrade the disk arrays. They no longer sell webspace as part of their products so it is not something they are interested in fixing when there is a work-a-round anyone can use.
Just configure a local php.ini file to use your own home folder or a folder within your home folder as temp storage. See http://community.plus.net/forum/index.php/topic,83568.msg696223.html#msg696223 - note: I don't think you need the full file, only a php.ini containing the parameters you want to change.
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: /tmp file filling up and causing scripts to fail

Quote from: Peter
note: I don't think you need the full file, only a php.ini containing the parameters you want to change.

Unlike ini_set, a local php.ini file completely replaces the master php.ini file. Any values not set will revert to the php default values rather than the master settings. This may lead to unintended results.
Incidentally, it's also a good idea to set session.gc_probability = 1
Gabe
megapixel
Dabbler
Posts: 24
Registered: ‎30-07-2007

Re: /tmp file filling up and causing scripts to fail

Thanks for the suggestions. I will investigate further...  Smiley
niggle09
Newbie
Posts: 5
Registered: ‎05-05-2009

Re: /tmp file filling up and causing scripts to fail

I have exactly the same problem as Megapixel and PN have pointed me here for a solution!
I have purchased a program (TNG8) which allows me to put my family tree on the web and all works fine for a few days - then the errors appear, generally for a day or two. Then they disappear and the site is once again useable - until the next time.  As I bought a ready made package, my experience of php and webspace is very limited.
PN tells me “ …the /tmp global shared folder fills up ….and we suggest you alter your code so it uses your own local space to act as the temp directory for your site rather than using the shared directory.”  They also say they have a cron job to purge the file which I guess is why it clears and reappears - however this is obviously not a useful solution.
My problem is that I do not understand how to alter the code.
Also, if I make a php.ini of my own (as I do not see one anywhere at present), where does it need to go?
Do I need all the file referred to at  http://community.plus.net....msg696223.html#msg696223 ?
I hope someone may be able to help - but keep it simple , please.
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: /tmp file filling up and causing scripts to fail

Trying to simplify things:
If you save the following script with a .cgi extension (e.g. phpini.cgi), upload it to your web root folder as ascii, set permissions to 700, and call it in a browser, it should create a tmp folder and a php.ini file for you and add the appropriate lines to the php.ini and put symlinks to the php.ini in all folders containing .php scripts.

#!/bin/bash
echo "Content-type: text/html"
echo
mkdir tmp && chmod 710 tmp
cp /etc/php5/cgi/php.ini ~ && chmod 600 php.ini
if [ -e php.ini ]
then
cat >> php.ini <<EOF
; Override section
display_errors = Off
expose_php = Off
register_globals = Off
upload_tmp_dir = $(pwd)/tmp
session.save_path = $(pwd)/tmp
session.use_only_cookies = 1
session.gc_probability = 1
soap.wsdl_cache_dir="$(pwd)/tmp"
EOF
for file in $(find . -mindepth 1 -type d -print0 | xargs -0)
do
[[ $(ls "$file") =~ \.php ]] && ln -s "$(pwd)/php.ini" "$file/php.ini" && echo "$file/php.ini<br>"
done
fi

More settings can be added above the second EOF, if desired.
Gabe
niggle09
Newbie
Posts: 5
Registered: ‎05-05-2009

Re: /tmp file filling up and causing scripts to fail

Gabe
Many thanks for the prompt reply.
I am unable to deal with this now until Monday but I will get back to you then.
Thanks again
niggle09
Newbie
Posts: 5
Registered: ‎05-05-2009

Re: /tmp file filling up and causing scripts to fail

Gabe
That seems to have done the job.
Opening the .cgi in the browser resulted in a string of entries such as
./admin/pnp.ini
./templates/template1/php.ini
etc
On examination, these folders each now have links to php.ini
There is a new tmp folder in my web root folder along with a php.ini file (which looks like the one listed in the previous post).
The web site appears to work just fine and time will tell if this has resolved the original problem.
I cannot thank you enough for your help. I certainly could not have done this myself.
I will now get on with uploading more data to the site now I have the confidence that it will work OK.
Thanks once again.
Nigel
megapixel
Dabbler
Posts: 24
Registered: ‎30-07-2007

Re: /tmp file filling up and causing scripts to fail

@Gabe - thanks also from me. I couldn't work out how to solve it myself but I've followed your suggestion and so far so good.  Smiley
However, my newly created tmp folder is empty. Is that what you would expect?
@Nigel - interested to see that your problem was in connection with TNG, which has been my problem too! I contacted DL about it and he recommended that I "just need to set the
session.save_path variable to a writeable folder on your site
". Unfortunately he didn't explain how exactly to do that, and I didn't feel I could press him for more help.
Chris
niggle09
Newbie
Posts: 5
Registered: ‎05-05-2009

Re: /tmp file filling up and causing scripts to fail

Chris
Just to let you know that all has been well with my TNG site over the past 6 weeks or so  since following Gabe's suggestion.
My tmp folder has a number of session ID's in it (I think these are kept for about a week).
At least you got a reply from TNG, my post to their forum only got one response and that was from someone else with the same problem!
Nigel

juton
Dabbler
Posts: 11
Registered: ‎14-03-2009

Re: /tmp file filling up and causing scripts to fail

Quote from: Gabe
Trying to simplify things:
If you save the following script with a .cgi extension (e.g. phpini.cgi), upload it to your web root folder as ascii, set permissions to 700, and call it in a browser, it should create a tmp folder and a php.ini file for you and add the appropriate lines to the php.ini and put symlinks to the php.ini in all folders containing .php scripts.
Gabe

Gabe
I tried this, wrote the file as ascii and uploaded to my root. Wh=ent into my browser and attempted to open, but all I got was '403 forbidden'.
Nothing appeared in my directories. I have two sites hosted in my webspace.
Should this be in the root of each subdirectory or in the main root?
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,370
Fixes: 75
Registered: ‎06-04-2007

Re: /tmp file filling up and causing scripts to fail

403 forbidden errors are usually caused by file permissions being set incorrectly, including those on any .htaccess files. Have you previously set *all* file and directory permissions to those required? See the CGI Platform PHP Upgrade FAQ. The easiest way to set permissions on PHP, Perl and cgi files is using the script here.
Note: your cgi webroot is '/', and you've only the one. You mentioned hosting two sites - are these are in separate subdirectories with a .htaccess file in /  to direct browsers to the appropriate subdirectory? That .htaccess file needs permissions 640 which you will need to set using your FTP program (though 640 might be the default).
Make sure you upload the cgi scripts (and .htaccess) in ASCII transfer mode. Just a single copy of phpini.cgi needs to be run, and that needs to go into /. The uploaded cgi scripts must have their permissions set to 700.
David
David
strider
Grafter
Posts: 55
Thanks: 2
Registered: ‎24-09-2010

Re: /tmp file filling up and causing scripts to fail

@Gabe
Thank you very much for your script.  It worked a dream on my site.
I would have been pulling my hair out if I had not come across it.
Just need to sort out some coding issues I have and everything will be fine.
s
Astronut
Dabbler
Posts: 17
Thanks: 3
Registered: ‎31-01-2010

Re: /tmp file filling up and causing scripts to fail

I think I may be being a bit dense!
I ran into the same problem and tried the script, but I ran into a server error:
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: phpini.cgi
If you think this is a server error, please contact the webmaster.
Error 500
Any ideas? Please?
Jon
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,370
Fixes: 75
Registered: ‎06-04-2007

Re: /tmp file filling up and causing scripts to fail

Do you have any .htacess files (if so, what do they contain)? Have you set file permissions correctly? Did you upload phpini.cgi in ASCII transfer mode?
David