![]() |
PHP doc_root
I am looking for guidance on how to change the document root setting for a website i have. in my HTDOCS folder in my installation of Apache i have several folders each for a different web project. However when when calling php global variables like $_SERVER['PHP_SELF'] i get a return of /holidaywebsite/index.php when what i want back is /index.php
I assume this is just a case of resetting the root in php? Can i do this in the php.ini file and if so how if, for example, i have my web project in a folder called holidaywebsite? Thanks in advance for any help. |
This is a server setting which PHP's $_SERVER values are based on.
Why don't you create a virtualhost in apache pointing to your /var/www/holidaywebsite and now your $_SERVER['PHP_SELF'] would return index.php |
Thanks Tony. How do i create a virtual host in Apache? Is there no way to set this the php.ini file or use an htaccess file in the folder i have holidaywebsite?
|
You would have to modify the httpd.conf file, personally I use cPanel on CentOS, the typically default virtual host entry would look something like this:
Quote:
|
Thanks mjwalsh but I have zilch linux experience and very little apache experience. Maybe one for the future. is there any way i can throw something in the .htaccess file in the website directory to tell the server this is the root folder? Its Apache installed on Windows XP i'm running.
|
It can't be done with just the .htaccess file. It's been a while since I've use windows and apache, here is what I would have done:
1.) The host file needs to be changed. In WinXP is the folder C:\WINDOWS\system32\drivers\etc\. You should be seen this already Code:
127.0.0.1 localhostCode:
127.0.0.1 localhost2.) Now about the virtual hosts or vhosts. That depends what method you used to install your Apache server like using WAMP or XAMPP or just normal installation. I don't know, but I will assume you install it using the apache .exe file. The config file for vhosts is in C:\Program Files\Apache Group\Apache2\conf\vhosts.conf then add this: Code:
<VirtualHost *:80>Code:
Include conf/vhosts.confCode:
Include conf/vhosts.confThat is a rough estimate of what needs to be done for a virtualhost. |
Sorted. Thanks Tony. the vhosts file was already there in the extra folder and was pointed to in the httpd.conf file just needed the # removed. Required a bit of repointing to where my website resided in the Apache folder structure but a restart and i see the holidaywebsite folder prefix has gone when I access it through the browser and i echo $_SERVER['php-self'] in the code. Many thanks.
Any advice - I am currently running Apache on Windows XP but my shared webspace is Linux. Obviously i dont notice any difference because i dont see the server. But was thinking of moving to a Linux CentOS virtual server environment and trying to install that on my laptop as a development environment. I have literally never used Linux in my life. Is it easy to isnatll/get to grips with and is CentOS the best installation of it? Cheers. |
I don't have much of a say on CentOS. Some servers at work use it, but they have been there since I was here. I've use openSUSE (very little) and I have use Ubuntu for the last 6 years. For starters, from what I see CentOS, Gentoo, Debian, and Ubuntu are good.
As of PHP very few things change from Windows Server to a Linux server, when you start. The manual tells you which functions/classes/libraries work only in linux. But if you want to start into the server world, just start with some linux distro and you will get the hang of it. |
CentOS is definitely a favorite amongst web hosts for the linux distro. I am personally a linux systems admin so I do favor linux a bit over windows but in my opinion Linux is a lot easier to handle than windows is. It's also a lot more light when it comes to resources used. I think you'll like it once you get used to it a bit.
|
I suppose my key consideration is my current webspace hosting package has all kinds of limits like 2 mysql databases each with a max space limit of 100Mb. I have a live website that is growly slowly but at some point i'm going to need the ability to do stuff on the server myself so was thinking of moving to a virtual server where there are several Linux options the default being CentOS. So want to make sure i'm not going to move to that and find i cant make head nor tail of it as ive never used Linux before. Sounds like CentOS is fine. I'll prob do some reading up on it. many thanks for your help guys.
|
Welcome to mmoggg website to buy RS Gold, offer a lot, of course, Diablo 3 Gold and Cheap RS Gold, to be purchased at any time, at any time shipment, and Diablo 3 Gold Kaufen look forward to your visit!
|
| All times are GMT. The time now is 07:03 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0