Created
March 21, 2019 19:00
-
-
Save 0xhexmex/9b9404a93446a2edd3c71e70bad4708f to your computer and use it in GitHub Desktop.
Install drupal on a linux box
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
# Another gem from Joaquim Nogueira (@lkys37en) | |
#!/bin/bash | |
#Reference:https://www.valuebound.com/resources/blog/Installing-drupal-with-drush-the-basics | |
#Reference:https://websiteforstudents.com/install-drupal-cms-on-ubuntu-16-04-lts-with-apache2-mariadb-php-7-1-and-lets-encrypt-ssl-tls/ | |
print_usage() { | |
echo "" | |
echo "Usage: $0 -v drupal-8.5.0 -p Welcome1" | |
echo | |
cat << "EOF" | |
Command line options: | |
-v Drupal version | |
-p Drupal Admin password | |
EOF | |
exit 3 | |
} | |
case "$1" in | |
--help) | |
print_usage | |
;; | |
-h) | |
print_usage | |
;; | |
esac | |
while getopts ":v:p:" opt; do | |
case "${opt}" in | |
v) | |
Version=${OPTARG} | |
;; | |
p) | |
Password=${OPTARG} | |
;; | |
: ) echo "Missing argument for -$OPTARG" | |
print_usage | |
exit 0 | |
;; | |
esac | |
done | |
read -d '' conf << EOF | |
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
DocumentRoot /var/www/html/drupal | |
ServerName example.com | |
ServerAlias www.example.com | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
<Directory /var/www/html/drupal/> | |
Options FollowSymlinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
<Directory /var/www/html/drupal> | |
RewriteEngine on | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] | |
</Directory> | |
</VirtualHost> | |
EOF | |
#Install PHP7 repo | |
apt-get update | |
apt-get install software-properties-common -y | |
echo -ne '\n'|add-apt-repository ppa:ondrej/php | |
apt-get update | |
#Install PHP7 and MYSQL | |
DEBIAN_FRONTEND=noninteractive apt-get install php7.1 libapache2-mod-php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mbstring php7.1-xmlrpc php7.1-soap php7.1-gd php7.1-xml php7.1-intl php7.1-mysql php7.1-cli php7.1-mcrypt php7.1-ldap php7.1-zip php7.1-curl mysql-server -y | |
#Create mysql database and drupal user | |
mysql -uroot -e "create database drupal;" | |
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'drupal'@'localhost' IDENTIFIED BY 'drupal';" | |
#Install Drush | |
cd /tmp ; wget https://github.com/drush-ops/drush/releases/download/8.1.18/drush.phar | |
chmod +x drush.phar | |
mv drush.phar /usr/local/bin/drush | |
echo y | drush init | |
#Downloading and configuring drupal via drush | |
cd /var/www/html/ ; drush dl $Version --drupal-project-rename="drupal" | |
cd /var/www/html/drupal ; echo y | drush si standard --account-name=admin --account-pass=$Password --db-url=mysql://drupal:drupal@localhost/drupal | |
chmod 755 /var/www/html/drupal/sites/default/settings.php | |
chmod 755 /var/www/html/drupal/sites/default/files | |
sed -i 's/# RewriteBase/RewriteBase/g' /var/www/html/drupal/.htaccess | |
chown -R www-data /var/www/html/* | |
#Configuring Apache | |
echo "$conf" > /etc/apache2/sites-enabled/000-default.conf | |
a2enmod rewrite | |
a2enmod env | |
a2enmod dir | |
a2enmod mime | |
a2enmod rewrite | |
chown -R www-data /var/www/html/* | |
#Rebuilding drupal cache via drush | |
cd /var/www/html/drupal/ ; drush cr | |
service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment