Part 3 – File Structure
Once you get hang on the administration section of Drupal, the next obstacle could be understanding the file structure of the CMS. In fact, this is the norm for any common CMS available now a day. So let’s take a look at how the file structure of Drupal is made of.
Figure 1 – Drupal Directory Structure
This folder is created by Drupal for user uploaded files such as user thumbnails for profiles. For the purpose of uploading files into this folder it requires write permissions or if not Drupal will warn you that this directory doesn’t have file write permissions and require enabling it in order to function file uploading.
This directory includes PHP include scripts that are required to run core activities of the CMS. In fact scripts that reside within this directory combined with core Drupal modules make the core of Drupal. Further this directory includes database wrappers for most common databases such as MySQL and PostgreSQL.
This directory is the usual place for core and other modules that will be used by Drupal. When you need to install a module (which can be browsed and downloaded freely from http://drupal.org/project/Modules) just extract the folder in to this directory and it should be shown in Drupal->Site Builing->Modules page.
This directory usually consists of various shell scripts that are required for various operations by the Drupal or functions like adding a cron tasks to crontab in a UNIX server.
The main purpose of this directory is to provide facilities to structure Drupal multi sites such as sites using common logins and modules, but with different databases and themes. But the default implementation includes only two directories that are essential for the functionality of Drupal. -
This directory usually holds only one PHP script (unless you are working on a Drupal multi site) with the name of settings.php which is imperative for a Drupal instance. This file is the default main configuration file for a given Drupal instance. Using this configuration file it’s possible to set the base URL, the database associated with and more settings of your Drupal instance.
This directory should be used to house modules that are required for a Drupal multi site meaning unlike installing modules in Modules directory, these common modules can be used by several Drupal sites.
This directory provides facilities to include different themes that can be managed from Drupal backend. Each Drupal theme should be housed in different folders within this directory with all necessary theme scripts, images, CSS and JS files. Once such a theme folder is extracted to this directory it will be shown in Drupal admin themes section and can be selected as the site’s default theme.
In case you are using Apache server, this file can be used to handle the behavior of the server such as URL rewriting.etc using Apache directives.
Used as the entering point to the site and usually the script that’s looked for when you type just the domain (depending on your server configurations) of a site.
This file is used when running cron tasks to manage repetitive actions on the site (with a given time period to repeat) such as indexing a database.
This script is executed at the installation of the Drupal instance.
When a serious database change, module change or conflicts occur, Drupal can be fixed using updating the instance and update.php script is executed in such cases.
Robots.txt is used to manage the behaviour of search engines visiting the site in order to index it. You can define which directories that should be omitted from indexing which can be quite useful when managing search engines.
Even though through this article I have tried to give a gist of the default Drupal directory structure and essential files, remember this is only essentially true for Drupal 5 instances. Even then it could get complicated when coming to multi sites. Though there are no earth shattering differences between currently used Drupal versions, it’s not guaranteed to be the same and could vary a bit from version to version. So as a rule of thumb, there’s no better way than searching and learning your self to widen your horizons when it comes to Drupal (or in most other cases with computers).