Probably many had to manually configure the vhost-s, place all sorts of test stays on different ports, always remember where everything lies. Pretty tedious. I think this is one of the reasons why novice web developers are so fond of Denver, who are relieved by the need to set up apache. Driving once again a new vhost, I decided to somehow change the situation.
Remembering that an article about tools like inotify, incrontab and using these to automatically start services was already running through Habré, 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 be launched by events file system. What you need.
After a day of picking bash, I wrote a php script in half an hour.
The algorithm of the script turned out to be simple and looks like this:
- get a list of folders with sites
- we screen out invalid names
- if the resulting list does not match the current settings, generate new settings
- ask for administrator password
- we register settings in / ect / hosts and / etc / apache2 / vhosts
If the system has
growlnotify installed, then messages about what is happening will be displayed in pop-up windows.
If you are interested in this tool, you can download it
here . The installation procedure is not very trivial (for Mac Os X):
- need to unpack 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 the file /etc/apache2/httpd.conf and create the folder "/ etc / apache2 / vhosts"
- to restart a computer

In the folder with the sites should be a folder with sites. If you do not specify anything, then 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 a test folder there, index.html in it, and test its performance in the browser.
Notes.
- If you change the value of the ALLOW_PRECONFIGRE_HTTPD parameter to true before 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 something suddenly breaks, blame yourself.
- A reboot is necessary for the normal operation of the authorization procedure. Without a reboot, a password prompt window is not displayed.
Ps. I understand that Denwer is a lot more than it’s in the article, but this is the part of denwer that I needed.