Created
August 25, 2014 06:59
-
-
Save topwebmaster/bc633c055cda0aff267d to your computer and use it in GitHub Desktop.
полу Автоматическое добавление хостов
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 | |
echo "Creating Virtual Host" | |
cd /etc/apache2/sites-available | |
cat <<EOF >> "$1" | |
<VirtualHost 127.0.0.1:80> | |
ServerAdmin webmaster@localhost | |
ServerName $1 | |
ServerAlias www.$1 | |
DocumentRoot "/var/www/$1" | |
<Directory /> | |
Options All | |
AllowOverride All | |
</Directory> | |
<Directory "/var/www/$1"> | |
Options All | |
AllowOverride All | |
Order allow,deny | |
allow from all | |
</Directory> | |
ErrorLog /var/log/apache2/error.log | |
# Possible values include: debug, info, notice, warn, error, crit, | |
# alert, emerg. | |
LogLevel warn | |
CustomLog /var/log/apache2/access.log combined | |
ServerSignature On | |
</VirtualHost> | |
EOF | |
mkdir "/var/www/$1" | |
cd /etc/apache2/sites-enabled | |
ln -s "/etc/apache2/sites-available/$1" "/etc/apache2/sites-enabled/$1.conf" | |
echo "Editing /etc/hosts" | |
cat <<EOF >> "/etc/hosts" | |
127.0.0.1 $1 | |
EOF | |
echo "Set permissions" | |
chmod 0777 -R "/var/www/$1" | |
sudo chown -R $USER:$USER /var/www/$1 | |
echo "Restarting Apache2" | |
/etc/init.d/apache2 restart | |
echo "Finished!" | |
echo "Local address: /var/www/$1" | |
echo "Web address: http://$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment