Go Back   Web Hosting UK Forums | Linux Windows Dedicated Server and cPanel VPS Hosting Forum > Support > php issues.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-29-2007, 09:27 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default PHP.ini issue

Hi all, I use $_SERVER["DOCUMENT_ROOT"]in a lot of my scripts to locate files from the root (public_html) of my websites. I have installed a website here and now $_SERVER["DOCUMENT_ROOT"] points to the document root of Apache.
I have asked support if this can be changed but they say it can't. I am moving from an Apache and linux setup where my scripts worked ok, so....I am just wondering why this is different?

It's no big deal, it is just much easier to use $_SERVER["DOCUMENT_ROOT"] and copy and paste it into different php pages.

php.ini ???

thx
Jon
Reply With Quote
  #2 (permalink)  
Old 01-29-2007, 10:21 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

I thought I maybe able to change it in php.ini but I couldn't find the settings
Reply With Quote
  #3 (permalink)  
Old 01-29-2007, 10:34 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

Well, the domain has just resolved on my VPS and the $_SERVER["DOCUMENT_ROOT"] works! So it must be pointing to public_html.

I have been testing the site using the ip/~username which points to Apache docs but the domain name doesn't.

I am sure there is a good reason why this is so, but who cares, as long as it is pointing to public_html when the domains resolve, I'm am happy
Reply With Quote
  #4 (permalink)  
Old 01-30-2007, 01:23 PM
Administrator
 
Join Date: Mar 2006
Posts: 1,702
Default

Thats what confused me.

I am quite sure that when you use the domain name then it will consider your public_html as document root coz apache configuration has got your public_html as the document root for your domain name but the IP address points to /usr/local/apache/htdocs so when you access your website with IP/~username/ then it shows the document root of the IP address.

You can change the document root of your IP address from /usr/local/apache/conf/httpd.conf
__________________
Web Hosting UK - ASP MSSQL Hosting - cPanel Linux Hosting
AIM : webredback || msn : andrew @ webhosting.uk.com
Toll Free : 0808 262 0855
Reply With Quote
  #5 (permalink)  
Old 01-30-2007, 01:50 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

Quote:
Originally Posted by Administrator View Post
Thats what confused me.

I am quite sure that when you use the domain name then it will consider your public_html as document root coz apache configuration has got your public_html as the document root for your domain name but the IP address points to /usr/local/apache/htdocs so when you access your website with IP/~username/ then it shows the document root of the IP address.

You can change the document root of your IP address from /usr/local/apache/conf/httpd.conf
AAH!

Thanks, now I understand. I have just edited my php.ini using SSH which may seen insignificant to most, but a giant leap for me. I take it that I would edit or view the httpd.conf the same way using vi ? (if I wanted to edit it)
Reply With Quote
  #6 (permalink)  
Old 01-30-2007, 02:02 PM
Administrator
 
Join Date: Mar 2006
Posts: 1,702
Default

Yeah. You can do it through vi but I am permanent customer of pico editor.

using vi you will need to type following to locate the first virtualhost entry of your IP which is considered as the default one :-

/87.117.236.*:80

If you replace /usr/local/apache/htdocs with your /home/username/public_html then default root of the IP address will change.

ESC + ! + w + q

ENTER
__________________
Web Hosting UK - ASP MSSQL Hosting - cPanel Linux Hosting
AIM : webredback || msn : andrew @ webhosting.uk.com
Toll Free : 0808 262 0855
Reply With Quote
  #7 (permalink)  
Old 01-30-2007, 03:14 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

Many thanks Admin for info.
Reply With Quote
  #8 (permalink)  
Old 03-05-2007, 01:46 PM
Senior Member
 
Join Date: Feb 2007
Posts: 110
Default

I've just worked through the same issue. I am swapping a website over to this hosting and I wanted to test it before changing the domain name to point to it's new home. The way I got around it was to add this to the root .htaccess file:

Code:
Options +FollowSymlinks
RewriteEngine on

rewriterule (.*)\.php http://ip/~username/wrapper.phtml?page=$1.php [r=301,nc,l]
With this code in the wrapper.phtml:

Code:
$_SERVER['DOCUMENT_ROOT'] = '/home/username/public_html';
include $_GET['page'];
It's not perfect, for instance relative link urls have their address relative to the directory that wrapper.phtml is in. But if you manually type any relative links in they works.
Reply With Quote
  #9 (permalink)  
Old 03-10-2007, 08:47 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

Thanks for the info, I haven't been in this situation since, but if I do I will look at your work-around.

Thx
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:19 AM.
Copyright 2002-2007 WebHosting.uk.com. All rights reserved.
Web Hosting UK Forum