Search code examples
apachegithtdocs

Set the Apache htdocs/subfolder as GIT working dir


I have just started trying to learn Git and I have got a little stuck. We are using Github to hold our "stable" project but I am having trouble working with the repo.

I want to know if its possible to use a local webservers htdocs/[projectname] as the working directory - this way I could clone the repo from github, work on it on the local server ( so it works as the application should allowing me to test everything i write properly ) and then stage -> commit from there.

I am working on a Mac using the MAMP environment. The application is a PHP based CMS. We are holding it on Github on a private repository. Currently Git seems to be using /Users/Ben/Core-CMS as the working dir but this makes it very hard to test things out - it would be much better if the working dir was inside the apache htdocs dir

I bought Pro Git but I am having a very hard time learning the concepts of git - I have purposely avoided using the GUI's as I wish to learn the inner workings of Git properly before I start 'cheating'!


Solution

  • If you have the permission to write in the htdocs dir, just move /Users/Ben/Core-CMS to htdocs/Core-CMS and access it at http://localhost/Core-CMS.

    If you cannot write in the htdocs dir, I'd create /Users/Ben/web, put my projects in there and tell apache to serve from there. To tell apache to look in /Users/Ben/web to serve your projects, look for the following line in your apache conf:

    DocumentRoot /path/to/htdocs
    

    and replace it with:

    DodumentRoot /Users/Ben/web