Jump to content

php.ini in webroot breaks site - Internal server error


dave
 Share

Recommended Posts

I've got a user that's having trouble uploading images. So I take a look at my phpinfo.php and see that post_max_size is set to 8M. Figuring the user is trying to upload large images I decide 8m is too small.  Simple problem, right? So I toss a php.ini file in the web root. 

post_max_size = 32M
max_execution_time = 300

If I do that, phpinfo() tells me all is well, but my Processwire site stops working entirely. Whether I try to view the homepage or go to /processwire/ all I get is:

<h1>Internal Server Error</h1>
<p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p>
<p>Error has been logged. </p>

Setting  $config->debug to true doesn't give me any more info on the error, and nothing shows up in my cPanel's Error Log. If I delete every line in php.ini and just leave a blank file, the error still occurs. So it seems like I can't have a php.ini at all. 

I asked my hosting company if they had another way of changing the post_max_size and they just went ahead and threw another php.ini in there and crashed the site again. 

Any ideas?

Edited by dave
Link to comment
Share on other sites

Thanks Tom. I've tried various combinations of things in php.ini, and as I mentioned even an empty php.ini. I went ahead and tried just post_max_size and upload_max_filesize as you suggested and got the same result as always. It doesn't seem to matter what's in it, the site just doesn't work if there's a file named php.ini in the web root.

Link to comment
Share on other sites

Thanks Tom. I've tried various combinations of things in php.ini, and as I mentioned even an empty php.ini. I went ahead and tried just post_max_size and upload_max_filesize as you suggested and got the same result as always. It doesn't seem to matter what's in it, the site just doesn't work if there's a file named php.ini in the web root.

How strange, some hosts block the usage of php.ini. But as you said they added a php.ini file. It would seem weird for them to add it if they didn't support it. From the top of my head I can't see for whatever reason ProcessWire would conflict with php.ini. 

So I might be tempted to say, even though your host added it, they don't actually support it. I would instead add this to the bottom of your .HTACCESS file:

php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 300
php_value max_input_time 300

It can also be completely possible that your host has blocked that too. So the final way of doing is via PHP itself. (However I'll have to do some research into where to add that in ProcessWire). Possibly add this at the bottom of /site/config.php/, but I'm just guessing there.

ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');

I really would recommend against adding it via PHP. 

Link to comment
Share on other sites

@SiNNut That succeeded in changing the local values in my phpinfo() and it didn't crash the site. Thanks!

Still having an issue with some uploads, but that's probably a topic for another thread. 

  • Like 1
Link to comment
Share on other sites

Glad that that worked out dave. To be honest i find it pretty strange that your hoster was not able to solve this, even worse they tried putting a php.ini in your root themselves. Shouldn't they know how their stuff is configured? It's not related to PW as far as i can tell.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...