Drupal how to guideThis installation guide provides step-by-step instructions on how to install Drupal 7 on a Fedora Linux system. The guide consists of 6 easy to follow steps to conclude whole installation. If you are just little bit curious about the new Drupal 7 release it is time to see what it is about. Be aware that installation of web applications on Linux systems using SELinux such as Fedora or RedHat is now little bit more complicated since changing permissions with chmod command may not always solve the problem. This guide could also be used by RedHat and CentOS Linux users.

Ubuntu users visit: Drupal 7 Installation guide for Ubuntu

Step 1: Install prerequisites

# yum install php-mbstring php-xml php-gd \
 mysql-server httpd php php-pdo php-mysql

Step 2: Setup Apache

If this Drupal installation is going to be the only website running on your server there is not configuration reuired. An you can proceed with Step 3 where your document root will be a default /var/www/html/ directory. If you wish to add drupal as additional website you need to create VirtualHost. Follow these instructions on how to create a new VirtualHost. This guide will use default /var/www/html directory.

For any changes restart Apache webserver with:

# /etc/init.d/httpd restart

Step 3: Download and decompress Drupal CMS

# cd /var/www/html
# wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz
# tar xzf drupal-7.0.tar.gz
# mv drupal-7.0/* .; rm -fr drupal-7.0 drupal-7.0.tar.gz
# chown -R apache.apache /var/www/html

The important point in this step is to download and decompress drupal tarball within /var/www/http . Fedora uses SELinux ( Security Enhanced Linux ) which means that files decompressed within ~/ will have SELinux context. We will come to that later in Step 4.

Step 4: Setup Drupal

At this point you should have a DocumentRoot directory ready. In this guide we use /var/www/http. At this point we need to ensure that Drupal installation files have a correct SELinux context. If you have completed step 3 as described you are almost ready to proceed with installation. But first we need to create settings file from the default.settings.php file:

# cd /var/www/html/sites/default/
# cp -p default.settings.php settings.php

Almost there ! Drupal wants to have /var/www/html/sites/ and /var/www/html/sites/default/settings.php writable. When dealing with SELinux we need to update context of the /var/www/html/sites/ to read and write:

# chcon -R -t httpd_sys_content_rw_t /var/www/html/sites/

If you have moved or copied Drupal installation files make sure that:

  • all files belong to Apache user
  • you set SELinux context with chcon -R -t httpd_sys_content_t /var/www/html/
  • you have changed SELinux context of /var/www/html/sites/ with the above command


to check a SELinux context use ls command with -Z option.


# ls -Z settings.php
-r--r--r--. apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 settings.php

For files copied from ~/ you may have wrong context as:

# ls -Z default.settings.php
-rw-r--r--. 6226 6226 unconfined_u:object_r:user_home_t:s0 default.settings.php

Step 5: Create mysql database

Let’s create a mysql database “drupal” and user named “user” with password “drupass”. By default mysql root password is empty. Consider changing your password and add -p switch to mysql command below:

# mysql
mysql> create database drupal;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'drupass';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on drupal.* to user@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> quit

Step 6: Proceed with Drupal installation

At this point everything should be ready to proceed with Drupal installation. Open your browser and point your browser to your webserver. After this point the installation is rather self explanatory. In “set up database” part use database details created in step 5.


If you get an error message saying:

include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0 drupal

Check permissions and run:

chcon -R -t httpd_sys_content_t /your/drupal/installation/dir

If you are unsure whether SELinux is causing you problems during Drupal installation turn SELinux OFF with:

# setenforce 0

To turn SELinux on again use:

# setenforce 1

More info about how to disable SElinux.