KaliLinux 2017.1: Install Drupal for CMS

This article will describe installing Drupal which is a content management system.

1 Install Drupal

  • This article uses default SSL/TLS certicication file for https. Please change your SSL/TLS certification file.
  • If you use http instead of https, change 443 to 80 and delete SSLXXX directive in /etc/apache2/sites-available/drupal.conf.
  • DRUPAL_PASSWD is password of drupal7 user in MySQL.
#!/bin/sh

set -e

[ -z "${DRUPAL_PASSWD}" ] && \
  DRUPAL_PASSWD=drupal

mysql_install()
{
  sudo apt install -y mariadb-server
  sudo systemctl enable mariadb
  sudo systemctl restart mariadb
}

drupal_install()
{
  cat <<EOF | sudo debconf-set-selections
drupal7 drupal7/dbconfig-install boolean true
drupal7 drupal7/database-type select mysql
drupal7 drupal7/mysql/app-pass password ${DRUPAL_PASSWD}
drupal7 drupal7/app-password-confirm password ${DRUPAL_PASSWD}
EOF
  sudo apt install -y drupal7
}

apache_install()
{
  sudo apt install -y apache2 libapache2-mod-php php-mbstring

  sudo mv /etc/apache2/conf-available/drupal7.conf \
       /etc/apache2/conf-available/drupal7.conf.orig
  cat <<EOF | sudo tee /etc/apache2/conf-available/drupal7.conf
<VirtualHost _default_:443>
  SSLEngine on
  SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

$(sed -e 's/^/  /g' /etc/apache2/conf-available/drupal7.conf.orig)
</VirtualHost>
EOF

  sudo a2enmod php7.0
  sudo a2enmod ssl
  sudo a2enconf drupal7
  sudo systemctl enable apache2
  sudo systemctl restart apache2
}

drupal_main()
{
  mysql_install
  drupal_install
  apache_install
}

drupal_main

2 Access to Drupal

Access to the following URL and setup Drupal. Accept this page's certification to browser.

https://<server>/drupal7/install.php

0001_DrupalInstall.png

After setup, access to the following URL and Drupal is displayed.

https://<server>/drupal7/

0002_Drupal.png