Drupal 7 Install on Fedora 23

Created on: 2015-11-21 19:00:00 -0500

Categories: Web Development


In this tutorial we will quickly go over how to set up Drupal in a dev environment. Since this is only a dev environment used for tinkering with Drupal many security aspects have been overlooked. The first thing we need to do is install the Apache, PHP and MySQL (or MariaDB) onto the server. We will assume that you have installed your OS from scratch. You can use the commands below to do that:

$ sudo yum -y update

Most likely a new kernel will be installed so it would be better to reboot now.

$ sudo reboot

After the restart log back in and continue with the Apache, PHP and MySQL installation.

$ sudo yum -y install httpd php php-mysql php-dom php-gd php-mbstring mariadb mariadb-server wget
$ mkdir ~/drupal
$ cd ~/drupal
$ wget http://ftp.drupal.org/files/projects/drupal-7.41.tar.gz
$ tar xzvf drupal-7.41.tar.gz
$ sudo mv drupal-7.41 /var/www/html/drupal7
$ sudo chown -R user.user /var/www/html/drupal7

Now we need to configure the firewall to allow incoming HTTP requests

$ sudo firewall-cmd --permanent --add-service=http

Now start up Apache

$ sudo systemctl enable httpd.service
$ sudo systemctl start httpd.service

With your web browser enter in the IP address of the virtual server. If you see the default landing page then everything is working.

In order to proceed we need to configure SELinux to allow the web browser access to certain files in Drupal. To do this enter the following commands.

$ cd /var/www/html/drupal7
$ sudo chcon -R -t httpd_sys_content_t .
$ sudo chcon -t httpd_sys_content_rw_t sites/default/
$ cp sites/default/default.settings.php sites/default/settings.php
$ sudo chcon -t httpd_sys_content_rw_t sites/default/settings.php
$ chmod a+w sites/default/settings.php
$ mkdir sites/default/files
$ sudo chgrp apache sites/default/files
$ sudo chcon -t httpd_sys_content_rw_t sites/default/files/

Now we need to set up mariadb.

$ sudo systemctl enable mariadb.service
$ sudo systemctl start mariadb.service
$ mysql -u root

MariaDB [(none)]> create database drupal;
MariaDB [(none)]> grant all on drupal.* to drupal@’localhost’ identified by ‘drupal’;
MariaDB [(none)]> grant all on drupal.* to drupal@’%’ identified by ‘drupal’;
MariaDB [(none)]> exit

Now verify you can log in as user drupal.

$ mysql -u drupal -p

Enter password: drupal
...
MariaDB [(none)]> exit

Install Drupal by going to the url of the server followed by the /drupal7 postfix. I.e. http://192.168.56.101/drupal7

Screen 1: Just use the defaults and click on 'Save and continue'

Screen 2: Just click 'Save and continue'.

Screen 3: Enter 'drupal' for Database name, Database user name and password. Then click on 'Save and continue'.

Screen 4: Just wait for the install to finish.

Screen 5: Put in a fake email address and put 'drupal' for the username and password. Click on 'Save' at the bottom.

Screen 6: Install is now complete.

When you are done remove write rights to setting by using the following command:

$ chmod a-w sites/default/settings.php

You will need to edit /etc/httpd/conf/httpd.conf to enable .htaccess to work. To do that edit httpd.conf and look for <Directory “/var/www/html”> . Inside that directive look for AllowOverride None and change it to AllowOverride All . The Drupal site should work now.