Last active
August 29, 2015 14:22
-
-
Save bvandreunen/5f39580ee796bff914e3 to your computer and use it in GitHub Desktop.
Generate vhosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ************************************ | |
# Vhost template | |
# ************************************ | |
<VirtualHost *:80> | |
ServerName %template% | |
## Vhost docroot | |
DocumentRoot "/var/www/%template%/app/html" | |
<Directory "/var/www/%template%/app/html"> | |
Options Indexes FollowSymlinks MultiViews | |
AllowOverride All | |
Require all granted | |
<FilesMatch "\.php$"> | |
Require all granted | |
SetHandler proxy:fcgi://127.0.0.1:9000 | |
</FilesMatch> | |
</Directory> | |
## Logging | |
ErrorLog "/var/log/apache2/%template%_error.log" | |
ServerSignature Off | |
CustomLog "/var/log/apache2/%template%_access.log" combined | |
## SetEnv/SetEnvIf for environment variables | |
SetEnv APP_ENV dev | |
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ************************************ | |
# Vhost template | |
# ************************************ | |
<VirtualHost *:80> | |
ServerName %template% | |
## Vhost docroot | |
DocumentRoot "/var/www/%template%/app/www" | |
<Directory "/var/www/%template%/app/www"> | |
Options Indexes FollowSymlinks MultiViews | |
AllowOverride All | |
Require all granted | |
<FilesMatch "\.php$"> | |
Require all granted | |
SetHandler proxy:fcgi://127.0.0.1:9000 | |
</FilesMatch> | |
</Directory> | |
## Logging | |
ErrorLog "/var/log/apache2/%template%_error.log" | |
ServerSignature Off | |
CustomLog "/var/log/apache2/%template%_access.log" combined | |
## SetEnv/SetEnvIf for environment variables | |
SetEnv APP_ENV dev | |
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: $ ./vhost.sh loc.sitename.com | |
# | |
# No need for sudo in vagrant/puphpet setup | |
#sudo -v | |
echo "Creating a vhost for $1" | |
sudo cp /etc/apache2/sites-available/template.conf /etc/apache2/sites-available/$1.conf | |
sudo sed -i 's/%template%/'$1'/g' /etc/apache2/sites-available/$1.conf | |
echo "Creating subdomain vhost for static HTML site" | |
sudo cp /etc/apache2/sites-available/template-html.conf /etc/apache2/sites-available/html.$1.conf | |
sudo sed -i 's/%template%/html.'$1'/g' /etc/apache2/sites-available/html.$1.conf | |
sudo a2ensite $1.conf | |
sudo a2ensite html.$1.conf | |
sudo service apache2 reload | |
echo "Done: vhosts for http://$1 and http://html.$1 configured." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment