Automated Scripted Install for Drupal on CentOS7/RHEL7 Linux

To get an instance of Drupal running on a fresh and minimal install of CentOS7/RHEL7 is the goal. Here is an automated scripted install for Drupal on CentOS7/RHEL7 Linux. It is not all inclusive. It doesn’t take into accounts a MariaDB password or MariaDB hardening. Just a quick script to get things running rather quickly, preferably on a development environment. This script into account the changes to the services unique to the CentOS7 vs. CentOS6.

# Description: This script will download, configure and install Drupal for CentOS/RHEL 7.x Linux.

# Install Pre-requisites
yum -y install mariadb-server httpd php php-mysql php-mbstring php-gd php-xml php-pear

# Clean URLS pre-requisite
sed -i "/^<Directory \"\/var\/www\/html\">/,/^<\/Directory>/{s/AllowOverride None/AllowOverride All/g}" /etc/httpd/conf/httpd.conf

# Start Services
systemctl enable mariadb.service && systemctl start mariadb.service
systemctl enable httpd.service && systemctl start httpd.service

# MySQL Consider changing values from drupaldb, drupaluser, and password
echo "CREATE DATABASE drupaldb CHARACTER SET utf8 COLLATE utf8_general_ci;;" | mysql
echo "CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'password';" | mysql
echo "GRANT ALL PRIVILEGES ON drupaldb.* TO 'drupaluser'@'localhost';" | mysql
echo "FLUSH PRIVILEGES;" | mysql

# Download and install Drupal
cd /var/www/html
curl -O
tar --strip-components=1 -zxvf drupal-7.39.tar.gz
/bin/rm drupal-7.39.tar.gz

# Drupal Configuration
cd /var/www/html/sites/default/
cp default.settings.php settings.php
#chmod 666 settings.php
#chmod 777 $(pwd)

# Drupal Permissions and Context
chown -R apache:apache /var/www/html
chcon -R -t httpd_sys_rw_content_t /var/www/html/sites/

# Ready for the world. Open firewall ports
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

# Install Drush
pear channel-discover
pear install drush/drush