PHP 5.3 and 5.2 same time in CentOS 6 server

MitchellOnline

New member
Joined
Jul 22, 2012
Messages
4
I have followed exactly the guide from this link: http://www.jomyut.net/2011/04/install-php-5-25-3-in-the-same-machine.html#codesyntax_6

Everything went well and now PHP 5.3.15 is my main PHP version.

I have add the following 3 lines to the top of the .htaccess file from one of my customers webhosting account, to let him have php 5.2.17:

PHP:
<FilesMatch "\.php$">
AddHandler x-httpd-php6 .php
</FilesMatch>

DirectoryIndex index.php
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla! 
#                              
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
# 
########## End - Rewrite rules to block out some common exploits

But when I open his website, I get a 500 Internal Server Error.

Hopefully you can help me sort this out, I really need your help!
 
Note that when you convert to CGI (suPhp) from CLI.. it will be much more strict with it's rules about permissions and owernship. If you get any "internal server errors", 500, etc... check the /var/log/httpd/suphp.log to see why, as well as /var/log/httpd/domains/domain.com.error.log and domain.com.log. Ensure your files are chowned to your user (not root, or apache) and chmod to no more than 755. With suPhp, you can run php files as chmod 700 for improved security.

From http://help.directadmin.com/item.php?id=262
 
Thanks for your reaction!

I am now chmod-ing folders to 755 and the files to 644.

Hopefully the website wil work by then, I will let you know as soon the folder rights are fixed.
 
I did chmod all the files and folders but there is still the 500 Internal Server Error.

In the .htaccess file (located inside public_html) I placed this on top:

PHP:
<FilesMatch "\.php$"> 
AddHandler x-httpd-php6 .php 
</FilesMatch>

I have no suphp.log file in the directory /var/log/httpd

And the /var/log/httpd/domains/domain.com.error.log gives me this information:

[Sun Jul 22 21:53:08 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:53:31 2012] [error] [client 66.249.67.40] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:53:31 2012] [error] [client 66.249.67.40] Premature end of script headers: index.php
[Sun Jul 22 21:53:31 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:53:32 2012] [error] [client 65.52.110.18] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:53:32 2012] [error] [client 65.52.110.18] Premature end of script headers: index.php
[Sun Jul 22 21:53:32 2012] [error] [client 65.52.110.18] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:53:44 2012] [error] [client 66.249.67.40] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:53:44 2012] [error] [client 66.249.67.40] Premature end of script headers: index.php
[Sun Jul 22 21:53:44 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:53:54 2012] [error] [client 66.249.67.40] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:53:54 2012] [error] [client 66.249.67.40] Premature end of script headers: index.php
[Sun Jul 22 21:53:54 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:54:04 2012] [error] [client 65.52.109.199] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:54:04 2012] [error] [client 65.52.109.199] Premature end of script headers: index.php
[Sun Jul 22 21:54:04 2012] [error] [client 65.52.109.199] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:54:29 2012] [error] [client 66.249.67.40] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:54:29 2012] [error] [client 66.249.67.40] Premature end of script headers: index.php
[Sun Jul 22 21:54:29 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:54:40 2012] [error] [client 66.249.67.40] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:54:40 2012] [error] [client 66.249.67.40] Premature end of script headers: index.php
[Sun Jul 22 21:54:40 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
[Sun Jul 22 21:54:50 2012] [error] [client 66.249.67.40] SecurityException in Application.cpp:175: Calling user is not webserver user!
[Sun Jul 22 21:54:50 2012] [error] [client 66.249.67.40] Premature end of script headers: index.php
[Sun Jul 22 21:54:50 2012] [error] [client 66.249.67.40] File does not exist: /home/ljmpacbier/domains/iloverestaurants.nl/public_html/500.shtml
 
OK, it seems as if you try to use mod_ruid2 with suPHP, by default it's impossible, you should disable mod_ruid2 for vhost where you want to use PHP-CGI, as you add

Code:
<FilesMatch "\.php$">  
AddHandler x-httpd-php6 .php  
</FilesMatch>
 
OK, it seems as if you try to use mod_ruid2 with suPHP, by default it's impossible, you should disable mod_ruid2 for vhost where you want to use PHP-CGI, as you add

Code:
<FilesMatch "\.php$">  
AddHandler x-httpd-php6 .php  
</FilesMatch>

How can I disable this? And do I need to install a alternative for mod_ruid2?
 
How can I disable this?

Some time has passed since I did it for a customer of mine, I don't remember details, but once enabled globally mod_ruid can not be disabled for a single virtual host. So there is no way to disable it for a single vhost, but the way to enable it selectively.

And do I need to install a alternative for mod_ruid2?

suPHP is alternative for mod_ruid2.

If you want both PHP versions, then you'd better have them both in PHP-CGI (suPHP) implementation without mod_ruid2.
 
Back
Top