include_path fatal error xampp
Make XAMPP/Apache serve file outside of htdocs
- Open C:\xampp\apache\conf\extra\httpd-vhosts.conf.
- Un-comment line 19 (
Add your virtual host (~line 36):
<VirtualHost *:80> DocumentRoot C:\Projects\transitCalculator\trunk ServerName transitcalculator.localhost <Directory C:\Projects\transitCalculator\trunk> Order allow,deny Allow from all </Directory> </VirtualHost>
Open your hosts file (C:\Windows\System32\drivers\etc\hosts).
127.0.0.1 transitcalculator.localhost #transitCalculator
to the end of the file (before the Spybot - Search & Destroy stuff if you have that installed).
- Save (You might have to save it to the desktop, change the permissions on the old hosts file (right click > properties), and copy the new one into the directory over the old one (or rename the old one) if you are using Vista and have trouble).
- Restart Apache.
Now you can access that directory by browsing to http://transitcalculator.localhost/.
Starting ~line 200 of your
http.conffile, copy everything between
</Directory>(~line 232) and paste it immediately below with
C:/xampp/htdocsreplaced with your desired directory (in this case
C:/Projects) to give your server the correct permissions for the new directory.
<IfModule alias_module></IfModule>section (~line 300) and add
Alias /transitCalculator "C:/Projects/transitCalculator/trunk"
(or whatever is relevant to your desires) below the
Aliascomment block, inside the module tags.
Edit ~line 176 in C:\xampp\apache\conf\httpd.conf; change
#DocumentRoot "C:/Projects"(or whatever you want).
Edit ~line 203 to match your new location (in this case
- You have to use forward slashes "/" instead of back slashes "\".
- Don't include the trailing "/" at the end.
- restart your server.
I've installed Xampp 1.8.3 with the installer and I'm trying to move my htdocs folder from
C:\Users\Håvard\htdocs. I've done the necessary edits to the
httpd.conf file in xampp and Apache is starting, no problem there.
I've been struggling with this problem for a few days now, I even posted a question on it here earlier. Since then I've gotten a little bit further in my quest for a solutiion and I've come to the conclusion that this is a problem regarding the norwegian letter in my Windows-username (and therefore userfolder)
When I try to open my PHP project as
localhost/project/index.php i get this message:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:/Users/Håvard/htdocs/project/index.php' (include_path='.;C:\xampp\php\pear\') in Unknown on line 0
The reason that I believe the norwegian letter is the reason for this message is that if I change the DocumentRoot and Directory in httpd.conf to anything else besides this folder (ex: C:/Users/Daniel) it works like a charm.
Why am I getting this error message? There is nothing wrong with my index.php as I've tried it with a different documentroot... Why is the "Håvard"-folder the problem? Is it the norwegian letter, or something else I have overlooked?
A VirtualHost would also work for this and may work better for you as you can host several projects without the need for subdirectories. Here's how you do it:
httpd.conf (or extra\httpd-vhosts.conf relative to httpd.conf. Trailing slashes "\" might cause it not to work):
NameVirtualHost *:80 # ... <VirtualHost *:80> DocumentRoot C:\projects\transitCalculator\trunk\ ServerName transitcalculator.localhost <Directory C:\projects\transitCalculator\trunk\> Order allow,deny Allow from all </Directory> </VirtualHost>
HOSTS file (c:\windows\system32\drivers\etc\hosts usually):
# localhost entries 127.0.0.1 localhost transitcalculator.localhost
Now restart XAMPP and you should be able to access http://transitcalculator.localhost/ and it will map straight to that directory.
This can be helpful if you're trying to replicate a production environment where you're developing a site that will sit on the root of a domain name. You can, for example, point to files with absolute paths that will carry over to the server:
<img src="/images/logo.png" alt="My Logo" />
whereas in an environment using aliases or subdirectories, you'd need keep track of exactly where the "images" directory was relative to the current file.
I found a solution to the problem. It was the encoding of the httpd.conf file. Here's what I did (I guess there's several ways to do this):
- Open httpd.conf in Notepad++
- Change Notepad++ settings in the section 'New Document' to UTF-8
- Create new document
- Copy and paste everything from httpd.conf to the new docuement
- Save and overwrite as httpd.conf
This answers my question, but it didn't solve my overall issue of the norwegian letter causing problems with my xampp installation. Here's the next problem I faced.