Fedora 25: Install Drupal

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 https to http in firewall-cmd's service argument.
  • MYSQL_PASSWD is password of root user in MySQL and DRUPAL_PASSWD is password of drupal7 user in MySQL.
#!/bin/sh

set -e

[ -z "${MYSQL_PASSWD}" ] && \
  MYSQL_PASSWD=mysql
[ -z "${DRUPAL_PASSWD}" ] && \
  DRUPAL_PASSWD=drupal_passwd

fedora_install_mysql()
{
  sudo dnf install -y mariadb-server php-mysqlnd
  sudo systemctl enable mariadb
  sudo systemctl start mariadb

  cat<<EOF | sudo mysql -u root
create database drupal7 character set utf8 collate utf8_general_ci;
grant all privileges on drupal7.* to drupal7@localhost
   identified by '${DRUPAL_PASSWD}';
exit
EOF
}

fedora_install_drupal()
{
  sudo dnf install -y drupal7

  sudo cp /etc/drupal7/default/default.settings.php \
       /etc/drupal7/default/settings.php
  echo "require_once('dbconfig.php');" | \
    sudo tee -a /etc/drupal7/default/settings.php

  cat <<EOF | sudo tee /etc/drupal7/default/dbconfig.php
<?php
\$dbs['mysql'] = array(
                      'driver' => 'mysql',
                      'database' => 'drupal7',
                      'username' => 'drupal7',
                      'password' => '${DRUPAL_PASSWD}',
                      'host' => 'localhost',
                      'port' => '',
                      'prefix' => ''
);
\$databases['default']['default'] = \$dbs['mysql'];
?>
EOF
}

fedora_install_apache()
{
  sudo dnf install -y mod_ssl

  sudo sed -e 's/Require local/Require all granted/g' \
       -i /etc/httpd/conf.d/drupal7.conf

  sudo firewall-cmd --add-service=https --permanent
  sudo firewall-cmd --reload
  sudo systemctl enable httpd
  sudo systemctl restart httpd
}

fedora_main()
{
  fedora_install_mysql
  fedora_install_drupal
  fedora_install_apache
}

fedora_main

2 Access to Drupal

Access to the following URL and setup Drupal.

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

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

https://<server>/drupal7/