Automatically configure apache vhosts or denwer for Mac

    Probably many had to manually configure vhosts, place all sorts of test styats on different ports, constantly remember where what lies. Pretty tedious task. I think this is one of the reasons novice web developers love Denver so much, which relieves them of the need to configure apache. Driving once again a new vhost, I decided to somehow change the situation.

    Recalling that an article about tools like inotify, incrontab and using them to automatically start services was already running on the hub, I began to look for similar solutions for Mac Os X. During trial and error, I found out that you can create your own service that will run on events file system. What you need.
    After a day of picking bash, I wrote a php script in half an hour.

    The script operation algorithm turned out to be simple and looks something like this:
    1. get a list of folders with sites
    2. filter out invalid names
    3. if the resulting list does not match the current settings, generate new settings
    4. request administrator password
    5. prescribe the settings in / ect / hosts and / etc / apache2 / vhosts

    If growlnotify is installed in the system , then messages about what will happen will be displayed in pop-up windows.

    If you are suddenly interested in this tool, you can download it here . The installation procedure is not very trivial (for Mac Os X):
    • need to unzip the archive
    • in the terminal run the command "<folder with files> /agent.php --install [<folder with sites>]"
    • add the line “Include /etc/apache2/other/*.conf” to the end of /etc/apache2/httpd.conf and create the folder “/ etc / apache2 / vhosts”
    • to restart a computer

    The folder with sites should contain folders with sites. If nothing is specified, the default value is "~ / Sites". For the settings to take effect, you need to change something in the “folder with sites” or run in the terminal “agent.php [<folder with sites>]”.

    After installation, you can go to the Sites folder, create the test folder there, index.html in it and check the performance in the browser.

    Notes.
    1. If before changing the value of the ALLOW_PRECONFIGRE_HTTPD parameter in the config.php file, then at startup the script itself can add the necessary line to /etc/apache2/httpd.conf and create a folder. But the script does not check anything, and if suddenly something breaks, blame yourself.
    2. Rebooting is necessary for the normal operation of the authorization procedure. Without a reboot, the password request window does not appear.


    PS. I understand that Denwer is much more than what is presented in the article, but this is the part of denwer that I needed.

    Also popular now: