gitapachevisual-studio-codeweb-hostingvirtualhost

Point Apache2 virtual host to a specific branch


I'm coding in VSCode and I just created a repository in my server and point the virtual host Apache port80 to this, but no matter the branch I work, the ctrl-S make the changes instantly visible to the users browser by web. Don't should it happen just if I commit? I'm working just with local repository by now. How can I make Apache2 point the port80 just to a specific branch, like the master branch, so when I work in some other branch, the changes don't become visible to the users? And what about the ctrl-S issue? this is my Apache configurations:

<VirtualHost *:443>
    ServerName example.com.br
    ServerAdmin myemailo@gmail.com

    DocumentRoot /var/www/myRepository

    

    <Directory /var/www/myRepository/>
        Options -Indexes -FollowSymLinks
        AllowOverride All
    </Directory>

    <DirectoryMatch "/var/www/myRepository/(\.|protected|themes/\w+/views|uploads/file)">
        Order Deny,Allow
        Deny from all
    </DirectoryMatch>

    <FilesMatch "^\.">
        Order Deny,Allow
        Deny from all
    </FilesMatch>

<VirtualHost *:80>
    ServerName example.com.br
    DocumentRoot /var/www/myRepository
</VirtualHost>

I've tried change to another branch with Git checkout, and tried too write /var/www/myRepository/master in Apache configuration


Solution

  • Apache doesn't know anything about git. It just serves whatever files are in the directory. So whatever you checkout into that directory, or whatever file you save there (checked in or not) is going to get served.

    If you want a production environment and a development environment you would generally checkout TWO copies of your project into two different directories. You would do development in one directory and set up the Apache virtual host to point to the other.

    Then to do a release you would check in to your development checkout, push the changes, go to your production checkout, and pull the changes.