Username
Forgot password?
Welcome to our site!
Or Join with FTTF

Error in Exception handler: : file_put_contents(php.log): failed to open stream: Permission denied

1

3205 views
Hi,

Per installation instructions, I set the following permissions:

chmod -R g+w /home/username/public_html/myapp/www 
chmod -R g+w /home/username/public_html/myapp/www/w

When I try to access "index.php" on the browser, I get the following errors:

Error in Exception handler: : file_put_contents(php.log): failed to open stream: Permission denied line 196#0 [internal function]: LampcmsErrorHandler(2, 'file_put_conten...', '/home/username/pub...', 196, Array) #1 /home/username/public_html/myapp/lib/Lampcms/Log.php(196): file_put_contents('php.log', '?April 17, 2012...', 10) #2 /home/username/public_html/myapp/lib/Lampcms/Log.php(219): Lampcms\Log::l('LampcmsError ex...', 2) #3 /home/username/public_html/myapp/!inc.php(306): Lampcms\Log::d('LampcmsError ex...', 2) #4 /home/username/public_html/myapp/lib/Lampcms/Exception.php(241): d('LampcmsError ex...') #5 /home/username/public_html/myapp/!inc.php(78): Lampcms\Exception::formatException(Object(ErrorException)) #6 [internal function]: exception_handler(Object(ErrorException)) #7 {main} Fatal error: Exception thrown without a stack frame in Unknown on line 0

Where did I go wrong?


 
Edited April 17, 2012 11:56 am AMT
Typos
asked April 17, 2012 at 10:52 AM

 us

1 Answer

2
Best answer
 
This means that program cannot write to php debug log.
What this also means is that there was some kind of exception thrown, then exception handler tried to write the error message to php debug log and was unable to do it.

The default debug log is located in www dir, which is a bad place to have your log file.
You should set a path to your own writable directory where you want to keep debug log.
Look in your !config.ini file - search for LOG_FILE_PATH setting and edit it.
Set it to full path to your own writable directory anywhere on your server.
For example something like /var/logs/lampcms.log

flag
answered April 18, 2012 at 5:56 AM
That fixed that problem. Thanks! Now I'm getting this error: Error: session_start(): ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) error code: 8 file: /home/username/public_html/Lampcms/www/index.php line: 66 The universal answer I got from all forums was to change "session.gc_probability" value from 1 to 0 in php.ini and restart apache but that didn't solve the problem. What else could be the reason? I have Ubuntu 10.04 Lucid server. PHP 5.3.2
flag
Apr 18 '12 at 21:03
Something is wrong with you system's permission. That session related error means php cannot delete stale session files on your server. gc_probability has nothing to do with this other than telling php to NEVER delete session files. This is wrong way and by doing this to solve your current problem you will create a much bigger problem for yourslef as your session directory will grow to tens of thousands of files or more and accessing session will become extremely slow. Fix you permissions - find where php is saving the session files and make that directory permission writable to php
flag
Apr 18 '12 at 21:19
@Dmitri Snytkine
Thanks Dmitri. I think session files are saved in /var/lib/php5. The command below show current permissions. What changes do I need to make? name@server:/var/lib/php5$ sudo ls -la total 8 drwx-wx-wt 2 root root 4096 Apr 19 02:23 . drwxr-xr-x 37 root root 4096 Apr 16 02:31 .. -rw------- 1 www-data www-data 0 Apr 19 02:23 sess_m6xx..
flag
Apr 18 '12 at 22:56
@Dmitri Snytkine
I set session path to session.save_path = "/tmp" in php.ini(uncommented it) since it's a writable directory, and the problem was solved. Thanks again Dmitri
flag
Apr 18 '12 at 23:07

Your answer

Join with account you already have

FTTF

Preview

Alert