-
-
Save mohamedrez/d273238d3e0cb747d342 to your computer and use it in GitHub Desktop.
New drupal site
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 | |
# This script creates virtual hosts and prepares your drupal directory. | |
# you should put it under /usr/local/bin/ | |
# and run it with sudo newvhost | |
# Set the path to your localhost | |
www=/var/www | |
echo "Enter directory name under $www" | |
read sn | |
echo "Enter the mysql password" | |
read password | |
mkdir $www/$sn | |
/home/mohamed/.composer/vendor/drush/drush/drush dl drupal --drupal-project-rename=$sn | |
mv $sn $www/ | |
chown -R www-data:www-data $www/$sn | |
# Prepare settings.php | |
chmod '777' $www/$sn/sites/default | |
cp $www/$sn/sites/default/default.settings.php $www/$sn/sites/default/settings.php | |
chmod '777' $www/$sn/sites/default/settings.php | |
# Create a database | |
mysql -uroot -p$password -e "create database $sn" | |
cd $www/$sn && /home/mohamed/.composer/vendor/drush/drush/drush site-install standard --db-url=mysql://root:$password@localhost/$sn --site-name=$sn | |
chmod '444' $www/$sn/sites/default/settings.php | |
# Create the file with VirtualHost configuration in /etc/apache2/site-available/ | |
echo "<VirtualHost *:80> | |
DocumentRoot $www/$sn/ | |
ServerName $sn.lh | |
<Directory $www/$sn/> | |
AllowOverride All | |
Order Allow,Deny | |
Allow from all | |
Require all granted | |
</Directory> | |
</VirtualHost> " > /etc/apache2/sites-available/$sn.conf | |
# Add the host to the hosts file | |
echo 127.0.0.1 $sn.lh >> /etc/hosts | |
# Enable the site | |
a2ensite $sn | |
# Reload Apache2 | |
/etc/init.d/apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment