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?
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 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.
(Note: I usually put .local on my local domains, but you don't need to)
2.) 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:
The value of DocumentRoot is the folder where your website resides. Don't forget the trailing slash. If that file doesn't exists, create it. Then add this line to the C:\Program Files\Apache Group\Apache2\conf\httpd.conf file.
3.) Do a quick configuration check. Open C:\Program Files\Apache Group\Apache2\conf\httpd.conf your file and make sure that the following part is not commented out by a preceeding # character:
4.) Restart Apache.
That 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.