Chris James Champeau
Chris James Champeau

Reputation: 994

500 internal server error with .htaccess file directly copied from working server

I am getting an internal server error, I think everything is setup correctly, I brought the whole site from my old host to a new host and now I am getting the error. same .htaccess file that looks like this

 # Mod Rewrite
 Options +FollowSymLinks
 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]

 ## adjust memory limit

 # php_value memory_limit 64M 
 php_value memory_limit 256M 
 php_value max_execution_time 18000

Not sure what the issue is, any help is appreciated

note that the site is now hosted on godaddy and I was told I needed to add the following lines to the htaccess for modrewrite

#Fix Rewrite
Options -Multiviews

still not working

Okay so finally got the error report on this,

[Wed Oct 10 15:05:09 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhapsmisspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:05:10 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:06:07 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:06:07 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:06:51 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:06:51 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:07:10 2012] [warn] [client 64.60.65.18] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Oct 10 15:07:10 2012] [error] [client 64.60.65.18] Premature end of script headers: index.php
[Wed Oct 10 15:07:10 2012] [warn] [client 64.60.65.18] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Oct 10 15:07:10 2012] [error] [client 64.60.65.18] Premature end of script headers: index.php
[Wed Oct 10 15:07:12 2012] [warn] [client 64.60.65.18] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Oct 10 15:07:12 2012] [error] [client 64.60.65.18] Premature end of script headers: index.php
[Wed Oct 10 15:07:12 2012] [warn] [client 64.60.65.18] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Oct 10 15:07:12 2012] [error] [client 64.60.65.18] Premature end of script headers: index.php
[Wed Oct 10 15:07:13 2012] [warn] [client 64.60.65.18] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Oct 10 15:07:13 2012] [error] [client 64.60.65.18] Premature end of script headers: index.php
[Wed Oct 10 15:07:13 2012] [warn] [client 64.60.65.18] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Oct 10 15:07:13 2012] [error] [client 64.60.65.18] Premature end of script headers: index.php
[Wed Oct 10 15:07:18 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Oct 10 15:07:18 2012] [alert] [client 64.60.65.18] /var/chroot/home/content/23/9953123/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

Upvotes: 2

Views: 3899

Answers (2)

Frank Jernigan
Frank Jernigan

Reputation: 131

I have been trying to figure this out for days. Like the original question shows, my Apache error log was also reporting "Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration"

Finally, coming across the comment "You can't set php_value when apache is using fastcgi / mod_fcgid" was a clue. Since I didn't know what that meant but it sounded relevant to my problem, I googled around and learned a lot of important things:

1) PHP can run either as an Apache module or as a CGI binary and that makes a huge difference in setting php values. To find out which yours is, run phpinfo() [google it if you don't know how to do that]. If the output shows "php-fpm" then yours is running as a CGI and not as an Apache module.

2)If yours is running as a CGI, then you cannot put php_value or any other php settings in .htaccess . You must set them in php.ini (whose location is given in the phpinfo output also) or in your php code via the function ini_set. For example

ini_set('display_errors', '1');

3) Most importantly: If you change php.ini and then restart Apache and find that your settings do not change, it probably means you are running as CGI and not as an Apache module. It makes sense then that restarting Apache will not reload php.ini because it isn't running php. To get the changes to occur, you have to restart the php-fpm service! (I've been pulling my hair out for days because every answer about setting values in php.ini that I could find said you change php.ini and restart Apache and that just works. But it did not work for me. This is why.) On the system I am building, which is on Amazon AWS Linux 2 instance, the command to restart the service is:

sudo systemctl restart php-fpm

Yours may be different.

I hope this answer helps some people who are as frustrated like I have been.

Frank

Upvotes: 0

user3739393
user3739393

Reputation: 31

You can't set php_value when apache is using fastcgi / mod_fcgid

Try commenting out those values, or encasing them like

<IfModule mod_php5.c>
   php_value something_something  164M
</IfModule>

I just ran into the same problem when my host upgraded servers. After removing them from .htaccess I put my php_value statements into the php; I think there's more than one way to re-implement them.)

Upvotes: 3

Related Questions