Before installation
Installing Drupal requires that you have a web server and a database server first.
For 'local' and 'online' Linux based servers using Apache and MySQL, the software that is needed to run Drupal is known as an "AMP stack", though Microsoft based servers and databases also come in a set known as a stack.
AMP stack
- Apache (or another web server)
- MySQL (or another database server)
- PHP
To install Drupal on your own computer for a local development environment, see the article, Local server setup.
Before making your website publicly available on the Internet, you probably will want to build and test it in an offline development environment. When it is working to your satisfaction in the development environment, you can then upload it to a Web host for serving online.
Step 1: Download and extract Drupal
You can download and extract Drupal in five different ways:
To install a Drupal site in a language other than English, check if your language is supported at localize.drupal.org.
You can also add additional languages after the installation.
So, follow one of the methods below for downloading, and then...
Before continuing to the next page ...
The base URL for your Drupal installation is set in your web server's configuration file. You need to know this URL before proceeding to the next steps of the installation.
If you are installing Drupal on your local machine, the base URL may be http://localhost
.
If you're installing Drupal to a web server, your base URL may be a specific domain name, such as http://example.com
.
Drush
Drush is a command line tool to maintain and administer Drupal sites. It offers the most convenient way of downloading Drupal by using a single command: pm-download
(or its alias dl
):
drush dl drupal-7
This command will download the recommended version into the current folder. Check drush help dl
to see additional options such as how to download a specific version.
To download the development version of Drupal 7:
drush dl drupal-7.x
From the command line
Downloading
Log into your server on using ssh and navigate to the directory from which you will be serving your Drupal site.
On many *nix computers the path from the server's root will be /var/www/html, so cd /var/www/html
. On a shared server, or a server that hosts multiple domains, the path will be different (try cd ~/www
or cd ~/public_html
). If you are unsure of the directory, ask your hosting provider for assistance.
Download Drupal from the command line, for example using wget or curl.
The commands are, respectively:
wget https://ftp.drupal.org/files/projects/drupal-7.x.tar.gz
or
curl -O https://ftp.drupal.org/files/projects/drupal-7.x.tar.gz
Note: The curl command option is the upper case letter "O" and not the numeral that stands for zero.
Replace https://ftp.drupal.org/files/projects/drupal-7.x.tar.gz
with the link for the version you want to install.
The links to the recommended versions are available on Drupal Core project page, where you can copy them from the Download column.
All other versions are available on the Releases for Drupal core page.
Extracting files
Type the following command and replace "7.x" with your downloaded version's number:
tar -xvzf drupal-7.x.tar.gz
Then remove the compressed version of the file by using the following command:
rm drupal-7.x.tar.gz
Moving to its intended location
Now you need to move the contents of the drupal-7.x directory one level "up" into the web server's document root or your public HTML directory:
mv drupal-7.x/* drupal-7.x/.htaccess ./
For Drupal 7, also add:mv drupal-7.x/.gitignore ./
Alternative, you can extract the the tar archive directly into the correct directory by typing:tar --strip-components=1 -xvzf drupal-7.x.tar.gz
The files from the directory you downloaded and decompressed have now been moved up a level into your web directory, and you can delete the (now empty) drupal-7.x directory:
rmdir drupal-7.x
Using FTP
You can download Drupal using your favorite FTP-tool.
- Download a Drupal tar.gz or zip file to your local computer from https://www.drupal.org/project/drupal by clicking on the link for the version you want to install.
- When you download the file, your browser will ask you what to do with it. Choose "Extract" and extract it to your local computer. Or, save the file and extract it using your computer's software (7-zip for example) that deals with archive files. The exact steps to do this differ by software, but you should end up with a folder/directory called something like "drupal-7.32" on your local computer.
- Use FTP to transfer the entire contents of this folder, including hidden files like .htaccess, to your hosting account's HTML document root. Details of how to do this depend on your FTP software.
Using Git
The Drupal project page has great version control instructions, which starts with setting up repository for the first time by cloning Drupal.
If you do not have composer installed follow their documentation.
Step 2: Create the database
Before running the installation script, you must create an empty database and database user (a user name assigned the rights to use the Drupal database).
This page provides direction for creating your Drupal database using one of the following methods:
- Web browser-based control panel (such as "CPanel" or "Plesk")
- phpMyAdmin
- Creating the database directly (advanced users)
Selection of characters in MySQL/MariaDB database name
- If you use capital letters in the database name, they will be converted to lower case.
- Allowed characters are a..z, 0..9, and "_" (underscore).
Create a database and user via a browser-based control panel
Most web hosting accounts provide a Web-based control panel to help you administer your site. These tools include easy-to-use features for creating a new database, and for creating a "user" with rights to the database. To create a database using a browser-based control panel consult the documentation or ask your web host service provider.
When you create the user for your database, you may see a page where you can specify the privileges that user will have for various operations on the database. In most web control panels' "database wizard", if you simply check "All" privileges for the user you create (and then uncheck "Grant" if it is listed as a privilege) your user will be set up correctly.
Take note of the username, password, database name and hostname (for example, are you installing in http://example.com
, or in http://drupal.example.com
, or http://example.com/blog
etc.) as you create the database. You will enter these items into fields in your browser when running the install script
Note that in many cases when creating databases and users via a web-based interface, the username you use to log into your control panel is added as a prefix to the database name and possibly to the database username as well. For example, if you log into your site's control panel as "webadmin" and create a database named "drupal7db" and a user for that database named "d7user", when running the Install script (see next page) the database and user may need to be typed in as "webadmin_drupal7db" and "webadmin_d7user". (This is because many hosting accounts are on shared servers, and on one server each database and user name must be unique across all accounts on the server.)
If you used the procedure in this section to create your database and user using a web-based interface, continue to the Step 3: Create the settings.php file page of the Installation Guide.
Create a database and user using phpMyAdmin
The most secure method to use when creating a database with phpMyAdmin is to create a user that has all privileges to the new database, but no privileges to the other databases. This is more secure than using a general username and password for all of your sites on the same server, as it limits access to your databases if someone gets hold of your database logins.
Note: This procedure assumes that you have root access to phpMyAdmin, and that you're using phpMyAdmin 3.5.x.
- Sign in to phpMyAdmin as the root user.
- Click Users, and then click Add user.
Note: You can use the root user credential as well.. - In the User name field, enter the username that you want to use.
- In the Host field, select Local, which is a more secure setting, unless you'll be accessing the database with this user from another server.
- Enter or generate a password for the user.
- In the Database for User section, select Create database with same name and grant all privileges.
- Make sure you select COLLATION
utf8_general_ci
orutf8_unicode_ci
- Click Go to create the user.
phpMyAdmin creates the new database with the same name as the user account. If you want to have a different name for the database and the user:
- Click Databases, and then click the link for the database that you want to rename.
- Click Operations.
- In the Rename database to section, enter the new database name.
- Click Go in the Rename database to section.
Take note of the username, password, database name and hostname (for example, are you installing in http://example.com
, or in http://drupal.example.com
, or http://example.com/blog
) as you create the database. You will enter these items into fields in your browser when running the install script.
In many cases, when creating databases and users using a web interface, the username that you use to sign in to your control panel is added as a prefix to the database name, and possibly to the database username as well. For example, if you sign into your site's control panel as "webadmin" and create a database named "drupal7db" and a user for that database named "d7user", when running the Install script the database and user may need to be typed in as "webadmin_drupal7db" and "webadmin_d7user". (This is because many hosting accounts are on shared servers, and on one server each database and username must be unique across all accounts on the server.)
If you used the procedure in this section to create your database and user using phpMyAdmin, continue to the Step 3: Create the settings.php file page of the Installation Guide.
Create a database from the command line
If you do not use a Web control panel or are experienced with and prefer to use MySQL, MariaDB or PostgreSQL commands, you can use the information in the following sections.
Additional information about privileges, and instructions to create a database using the command line are available in the INSTALL.mysql.txt file for MySQL/MariaDB and in the INSTALL.pgsql.txt file for PostgreSQL.
Create a database using MySQL/MariaDB commands
Note: The database should be created with UTF-8 (Unicode) encoding, for example utf8_general_ci.
For information on installing and configuring MySQL see http://dev.mysql.com/doc/refman/5.7/en/index.html
For information on installing and configuring MariaDB, see https://mariadb.com/kb/en/
In the following examples, 'username' is an example MySQL/MariaDB user who will have the CREATE and GRANT privileges and 'databasename' is the name of the new database Use the appropriate names for your system.
- Create a new database for your site (change the
username
anddatabasename
):mysql -u username -p -e "CREATE DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci";
MySQL/MariaDB prompts for the 'username' database password, and creates the initial database files.
- Log in and set the access database rights:
mysql -u username -p
MySQL/MariaDB prompts for the 'username' database password.
- At the MySQL/MariaDB prompt, create the user and set the permissions using the following command:
CREATE USER username@localhost IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';
In this case:
- databasename is the name of your database
- 'username' is the username of your MySQL or MariaDB user account
- 'localhost' is the host where Drupal is installed
- 'password' is the password required for that username
Be sure to use backticks (
`
) around the database name if you used a MySQL or MariaDB escape character (_ or %) in your database name.For example, because the underscore character is a wildcard, drupal_test_account.* should be `drupal\_test\_account`.* for security. Otherwise the underscores would match any character and could accidentally give access to other similarly named databases.
Note 1: Unless the database user/host combination for your Drupal installation has all of the privileges listed above (except possibly CREATE TEMPORARY TABLES, which is currently only used by Drupal core automated tests and some contributed modules), you will not be able to install or run Drupal.
Note 2: If you need to restore a dump created with Drush, you will need to add
LOCK TABLES
privilege, unless it won't work.For further information on the GRANT statement see http://dev.mysql.com/doc/refman/5.0/en/grant.html
- If successful, MySQL/MariaDB will reply with:
Query OK, 0 rows affected
- Now exit the MYSQL/MariaDB prompt by typing:
exit
The server will answer by sayingBy
Create a database using PostgreSQL
The database must be created with UTF-8 (Unicode) encoding.
- Create a database user
This step is only necessary if you don't already have a user setup (e.g. by your host) or you want to create new user for use with Drupal only. The following command creates a new user named 'username' (you should substitute this with the desired username), and prompts for a password for that user:createuser --pwprompt --encrypted --no-adduser --no-createdb username
If everything works correctly, you'll see a
CREATE USER
notice. - Create the database
This step is only necessary if you don't already have a database setup (e.g. by your host) or you want to create new database for use with Drupal only. The following command creates a new database named "databasename" (you should substitute this with the desired database name), which is owned by previously created "username":
createdb --encoding=UNICODE --owner=username databasename
If everything works correctly, you'll see a
CREATE DATABASE
notice.
Step 3: Create settings.php and the files directory
sites/default
When you first extract Drupal, it doesn't come with a settings.php file, instead it comes with default.settings.php. When you first install Drupal, it will attempt to copy and rename default.settings.php to settings.php for you. There are some rare instances where you will need to do this manually which are covered in detail further down on this page.
Finally, the purpose of having default.[config-file].php is so you can easily update Drupal, without overwriting the entire configuration that runs your site. Yes, there was a time when that happened...
Automatic settings.php Overview
By default, Drupal will attempt to create and populate the settings.php file automatically when you use install.php to setup the site. The script also changes the permission on the file to secure it once it is finished and then creates a sites/default/files directory for housing all of your non-core files. Unfortunately, some types of shared/local hosting are configured so PHP and Apache run as the same user. This might result in the install script failing to execute the creation and population of the settings.php file, along with setting permissions and creating the files directory. If you get errors referring to the Settings file during installation, you will have to manually create the settings.php file and do a few more tasks before you can run install.php. Once it is created with write permissions, the installation script will automatically populate the proper information for your site config. Afterwards, you will have to re-secure the settings.php file.
At this point, jump to the next page step: Step 4: Run the installation script. If you run into problems with the installation due to the Settings, come back here and follow the Manual steps outlined below.
Manual settings.php Overview
Drupal comes with a sample settings.php configuration file located at: sites/default/default.settings.php
Before you run the installation script (install.php), you need to copy default.settings.php file as a new file called settings.php
and change its permissions to be writeable. After the installation, you will need to restrict the permissions again.
Manual settings.php Detailed Instructions
Step 1 - Navigation & Creation
Navigate to sites/default
of your root Drupal install.
Copy the default.settings.php
file and save the new file as settings.php
in the same directory (see note below about renaming). If you have shell access (command line) run the following command from the directory that contains your Drupal installation files:
cp sites/default/default.settings.php sites/default/settings.php
Note: Do not simply rename the file. The Drupal installer needs both files.
If you only have FTP access, you will have to download the file to your computer, rename it, then upload it. Some hosting providers have a file manager on the dashboard where the file can be copied and renamed.
Step 2 - Check the Permissions Are Writeable
By default, the sites/default directory and the settings.php file should be writeable. You can check that the permissions of sites/default and settings.php are writeable by issuing the following commands:
ls -l sites/
Permission on sites/default should be 755 [drwxr-xr-x]:
ls -l sites/default/settings.php
Permission on settings.php should be 644 [-rw-r--r--]:
If they are anything but writeable, you can issue the following commands:
chmod 644 sites/default/settings.php
Note: If you are in the same group as the web user, then changing the permissions to 664
will be sufficient.
Several FTP tools like Filezilla, Transmit, and Fetch etc. allow you to change file permissions, using a 'file attribute' or 'get info' command. In this case the file permission should be set to 644. If your FTP client has checkboxes for setting permissions, check both the Read and Write boxes for "Owner", "Group", and "Others" (but leave the Execute boxes unchecked). For some situations, you may need a permission of 664. Some hosting providers allow a similar operation through the dashboard file manager.
Step 3 - Try the Install
At this point, give the install a go. See if you can get through the installation by running http://[yoursite]/install.php. If you are successful, the first page you will want to visit is Reports -> Status report (admin/reports/status)
On the reports page, look for a line that says: File system. If it says anything other than "Writeable", you will need to follow Step 4 below.
Next, look for a line that says: Configuration file. If it says anything other than "Protected", then you will need to re-secure the configuration files as described in Step 5 below.
Step 4 - Create the Files Directory
The installation should have created the sites/default/files directory for you, but in the off chance it didn't, you will need to create it manually and set the right permissions on it.
mkdir sites/default/files
Note:On most linux systems, a newly created directory is already setup with the 755 permission. In case it isn't, you can issue the command:
chmod 755 sites/default/files
This sets the files directory to 755 [drwxr-xr-x].
Depending on how your apache configuration is setup, you might have to instead run:
chmod 777 sites/default/files
This sets the files directory to 777 [drwxrwxrwx]. It is less secure than 755, but there's nothing you can do about it if that's how your server is setup.
Step 5 - Post Install Permission Check
After the installation script has run, Drupal tries to set the permissions automatically to:
555 (read-execute) [dr-xr-xr-x] for the sites/default folder.
and
444 (read-only) [-r--r--r--] for the settings.php
If not, you will need to manually set them:
chmod 555 sites/default
chmod 444 sites/default/settings.php
These permissions are correct, and should not be changed, because changing these opens up a security risk.
OS specific instructions
Fedora Linux settings.php notes
If you have clean Fedora (or RHEL, CentOS, Scientific Linux) you have SELinux enabled by default after clean installation. There are few more steps to be done to be able to finish Drupal installation on SELinux enabled site to gain more security by SELinux.
If you don't want to use SELinux you may simply disable it, but this is not recommended as SELinux is able to block some exploits. Also you may turn SELinux into permissive mode to go through creating the settings.php
file (because even if you have set the permissions for writing to settings.php
, the install script will think you don't because SELinux is active and is blocking writing to settings.php
file).
To go through installation, do this (as root):
- Enable allow_httpd_anon_write boolean:
setsebool allow_httpd_anon_write=1
- Change type of default directory and settings.php to public_content_rw_t (whole command is in one line):
chcon -t public_content_rw_t sites/default sites/default/settings.php sites/default/files
After the installation finishes, revert previous settings to benefit from SELinux:
- Disable allow_httpd_anon_write boolean:
setsebool allow_httpd_anon_write=0
- Reset security context:
chcon -R -t httpd_sys_content_t sites/default
Windows (IIS) settings.php notes
On a Windows computer using Internet Information Server (IIS), complete the following steps:
- Right-click
sites\default\settings.php
. - Grant Write permissions to IUSR_MachineName (IIS6) or IUSR (IIS7).
Note: On Windows Server 2008, you can also do this from the command line by running the following command from your sites\default
directory:
icacls settings.php /grant IUSR:W
The installer will change the file back to Read Only after installation, but you should verify this after installation.
Step 4: Run the installation script
To run the Drupal install script, point your browser to the base URL of your website.
The base URL means the document root (directory) where you placed your Drupal files (and is defined in your web server configuration file). If you have installed Drupal on a web host this will likely be a domain name such as http://www.example.com
. If you installed Drupal in a subfolder, you should point your browser to the subfolder (for example, http://example.com/subfolder
). If you installed Drupal on your desktop machine, the URL might be http://localhost/drupal
.
If the installation process does not simply appear by entering the base URL of your site, add the file name install.php
to the end of your site's URL (for example, http://www.example.com/install.php
).
Installation process
After you run install.php
, you'll be guided through several pages:
- Choose which profile to use for the installation (standard or minimal or your chosen distribution).
Most people should select the "standard" option. The standard option comes with default content types already enabled, such as Article and Page, and with appropriate publishing options already set. (Of course you can later edit these default content types and their settings, or add additional ones.) The standard profile also has a useful collection of modules pre-enabled for you.
The "minimal" option is targeted toward more experienced Drupal site creators who wish to set up their own content types with associated publishing options. The minimal profile has only three modules enabled: Block, Database logging, and Update status.
More info about built-in installation profiles.
Choose the 'name of your distribution', if you have downloaded a distribution and not a normal drupal at step one.
- If you want to install using a language other than the default English, click the Learn how to install Drupal in other languages link.
- If your installation directory is not yet configured properly, you'll be informed on this page. You can correct the settings individually and either refresh the browser screen or click 'Try again' to see whether there are any errors left.
Reported errors can include:
- Missing directories and/or incorrect permissions
The installer will attempt to automatically set up a number of directories, but this may fail due to permission settings. In this case you will find the missing directories listed.sites/default/files
sites/default/private
sites/default/private/files
These directories should be set to the following permissions:
chmod o+w sites/default/files
OR
chmod 777 sites/default/files
- Missing
settings.php
or incorrect permissions
Ifsettings.php
is missing or not accessible, follow the instructions in Step 3: Create the settings.php file. Note that you will need both thedefault.settings.php
andsettings.php
files.
- Missing directories and/or incorrect permissions
- Enter the database name, the username, and the password for the database that you created in Step 2: Create the database. This username and password information allows Drupal to access your database so the install script can create tables. Note that this is not the username and password for administering Drupal; these will be created in the next step.
The Advanced options allow you to change the database host ('localhost' is usually used in this entry:
wamp/bin/apache/Apache2.2.11/bin/php.ini
as an example of the location on a Windows computer running WAMP). You can also change the port and the table prefix. You only need to change the port if you are using a non-standard port number. The table prefix is useful if you are installing multiple instances of Drupal tables that share the same database.Click Save and continue at the bottom of the page.
- A progress bar will appear and display notes from the installer regarding the progress of the installation. If no errors are encountered, the next page will automatically load in your browser.
- After the installer completes, input the information for the first user account (which will be automatically assigned full administration permissions) and provide basic website settings.
- In the Site name field enter the name you wish to use for the site. You can also edit it later through the administration interface.
- In the Site e-mail address field, enter the e-mail address that will be used by Drupal when it sends out notifications such as registration information.
- In the Site maintenance account field, enter the Username, E-mail address, and password for the main administration account.
Note that as of Drupal 7 there is a distinction between the main administration account that you set up on this page, and the "Administrator" site administrator user role that you will see when you visit the "Roles" and "Permissions" pages in the administration interface. The account you set up in the Site maintenance account section during installation is a super-user who has overall control over every aspect of the management and configuration of the site. (For those of you familiar with the account from earlier versions of Drupal, this will be
http://www.example.com/user/1
.) - In the Server settings field, select your Default country and Default time zone.
- In the Update notifications field, leave both check boxes selected if you want your Drupal server to alert you when updates are required. Often updates relate to security issues and are important to perform. However, if you have restricted Internet connectivity (for example, if you are behind a corporate firewall) you may want to leave these settings unselected and then test them later.
Click "Save and continue". On success you will see the Drupal installation complete screen. If there are any error messages, review and correct them now.
Secure your site
After the installation is complete, you will want to change the permissions on the settings.php
file back so that it is protected:
chmod u=rw,o=r,a=r sites/default/settings.php
OR
chmod 644 sites/default/settings.php
If you make manual changes to the settings.php
file later, be sure to protect it again after making your modifications.
Important: Failing to remove write permissions to the settings.php
file is a security risk.
Although the default location for the settings.php
file is at sites/default/settings.php
, it may be in another location if you use the multisite setup.