php not working with site preview

cweb

Member
Dec 9, 2002
19
0
151
Hi

We have an apache2.2.4 server with suphp and php5.2.3 configured. When we try to access a new site before it is delegated via IP we are having issues with PHP code. HTML code is fine. Only PHP code is the issue.

If we try to access http://serverip/~username/anything.php we get the following error:
****************
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
****************

The server error log has the following
****************
SoftException in Application.cpp:214: File "/home/username/public_html/anything.php" is not in document root of Vhost "/usr/local/apache/htdocs", referer: http://servername/~username/
****************

Any ideas?
 

sparek-3

Well-Known Member
Aug 10, 2002
2,042
230
368
cPanel Access Level
Root Administrator
I was wondering how cPanel was going to tackle this problem.

When I looked at suPHP a few years ago, I ran into this problem as well. I did find some patches that I was able to apply and resolve this, but the patches do not work for the latest version of suPHP (at least that I could tell).

The cPanel developers will need to patch their release of suPHP or something will need to change in regards to their set up. suPHP is designed to have an open_basedir like protection built-in. It looks to see what the DocumentRoot for a specific VirtualHost is and if the PHP script that is being accessed is not within that DocumentRoot, then it returns the exception.

With the main server's virtualhost, the DocumentRoot is set to /usr/local/apache/htdocs and the PHP files you are trying to access are in the /home partition, which do not match, causing this exception.

The suphp included with cPanel would need to be patched to bypass this security feature or make some other type of arrangement.

It's not really a cPanel problem and it's not really a suPHP problem. Its just a case to where we have come to expect to be able to use this url syntax to check a website before the DNS propagates. suPHP is expecting you to access the VirtualHost directly, in which case the PHP files will work.
 

sparek-3

Well-Known Member
Aug 10, 2002
2,042
230
368
cPanel Access Level
Root Administrator
When I tested this a couple of weeks ago on a test machine with suPHP and Apache2, this worked. That is PHP script that were accessed by http://ip/~username worked and were executed by username.
 

sparek-3

Well-Known Member
Aug 10, 2002
2,042
230
368
cPanel Access Level
Root Administrator
You probably have mod_userdir protection enabled and don't have the defaulthost excluded, this was changed a few releases ago.

Log into root's WHM. Click on Security Center, then click on Apache mod_userdir Tweak.

If Enable mod_userdir Protection is checked, try checking the Exclude for DefaultHost (nobody).

Alternatively you can just add the user that you are trying to preview into the Additional Users textbox.
 

EWD

Well-Known Member
PartnerNOC
Aug 19, 2003
165
0
166
NY
You probably have mod_userdir protection enabled and don't have the defaulthost excluded, this was changed a few releases ago.

Log into root's WHM. Click on Security Center, then click on Apache mod_userdir Tweak.

If Enable mod_userdir Protection is checked, try checking the Exclude for DefaultHost (nobody).

Alternatively you can just add the user that you are trying to preview into the Additional Users textbox.
I have done this and still get a 404 error.

Any ideas?

Thanks
 

Sindorf

Member
Aug 3, 2007
7
0
51
Hello,

I think this is configured via mod_suphp

Log in to shell and write

pico /opt/suphp/etc/suphp.conf
and check for

; Check whether script is within DOCUMENT_ROOT
; Does NOT perform this check on included scripts.
; i.e. include_once("/test3.php"); works even though it's in the root directory
;
; Changing this to true will improve security but make all php userdir requests fail
check_vhost_docroot=false


; Allow the user and group specified by a ~userdir request to override the
; suPHP_UserGroup directive inside the source virtualhost
;
; Changing this to false will improve security but make some types of php userdir
; requests fail
userdir_overrides_usergroup=true
I think the comments on the configuration file is enough ;)

Happy new year :)

P.S. You can use nano or vi for editing, if you do not have pico installed.
 
Last edited:

Morry

Member
Aug 8, 2006
6
0
151
i face this problem with my cpanel 11 server
(centos ) with apache 1.3.39 with php 4.4.7 - Selinux Desaibled

and i searched for this file /opt/suphp/etc/suphp.conf
in my server i diden't find it

and my /opt/ is empty

did you have any idea where can i find this file suphp.conf
 

darren.nolan

Well-Known Member
Oct 4, 2007
257
0
66
Mine is at /opt/suphp/etc/suphp.conf

Try using
Code:
locate suphp.conf
(If your system supports it)