Page 1 of 1

Document root outside htdocs (apache vhosts)

PostPosted: 14. September 2014 22:51
by appyape
Hello

I have installed Xampp and edited httpd-vhosts.conf file to make changes for virtual hosts. I put this entry in the file ...

Code: Select all
<VirtualHost *:80>
    ServerAdmin myname@mymail.com
    DocumentRoot "C:/xampp1.8.2/htdocs"
    ServerName localhost
</VirtualHost>


and then I could access http://localhost homepage without any issues.

Now I moved the projects directory outside Xampp folder and specified virtual host as shown below ...

Code: Select all
<VirtualHost *:80>
    ServerAdmin myname@mymail.com
    DocumentRoot "C:/myprojects/project1php5.3"
    ServerName local.myproject1
</VirtualHost>


when I go to local.myproject1 url, I get access forbidden error (error 403) ... Am I doing it wrong way?

What i am trying to achieve here is to keep all the projects in a common directory outside Xampp folder ( I am using different Xampp version for different php versions depending upon which project I am working on) ...it looks something like this ...
Code: Select all
C:/xampp1.8.2
C:/xampp1.7.7
C:/myprojects
C:/myprojects/project1php5.3
C:/myprojects/project2php5.4

Just to make it clear, please note, I use one version of xampp at a time and both versions work fine individually. Can you please advise what changes do I need to make in httpd-vhosts.conf in both versions of xampp to be able to access my projects?

thanks

Re: Document root outside htdocs (apache vhosts)

PostPosted: 15. September 2014 06:30
by Altrea
Hi appyape,

You need to define Access rules for folders outside of htdocs, like so:
Code: Select all
<VirtualHost *:80>
    ServerAdmin myname@mymail.com
    DocumentRoot "C:/myprojects/project1php5.3"
    ServerName local.myproject1
    <Directory "C:/myprojects/project1php5.3">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


The reason you don't need to do this for folders inside htdocs is that there is already a default rule defined for htdocs which gets inherited.

best wishes,
Altrea

Re: Document root outside htdocs (apache vhosts)

PostPosted: 15. September 2014 08:59
by appyape
Excellent!! All working fine now. You are a star!! :)