Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
lamp :: быстрое добавление домена
#!/bin/bash
echo "enter domain (without http/https/www/..; for example my-domain.com): "
read domain
if [[ $domain != "" ]]
then
domainwww="www.$domain"
echo $domain
echo $domainwww
sudo mkdir "/var/www/html/$domain"
sudo chown -R $USER "/var/www/html/$domain"
sudo cp "/etc/apache2/sites-available/000-default.conf" "/etc/apache2/sites-available/$domain.conf"
sudo sed -i "s/ServerName www.example.com/ServerName $domain\n ServerAlias $domainwww/g" "/etc/apache2/sites-available/$domain.conf"
sudo sed -i "s/\/var\/www\/html/\/var\/www\/html\/$domain/g" "/etc/apache2/sites-available/$domain.conf"
sudo sh -c "echo >> /etc/hosts"
sudo sh -c "echo 127.0.0.1 $domain >> /etc/hosts"
sudo sh -c "echo 127.0.0.1 $domainwww >> /etc/hosts"
sudo a2ensite -q "$domain.conf"
sudo systemctl restart apache2
echo "ok" >> "/var/www/html/$domain/index.php"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.