Deprecated: Use a Docker-based solution such as DDEV or Lando instead.

This page provides a summary of the command line instructions for installing Drupal on a typical UNIX/Linux web server. Every step contains a link to more detailed installation instructions where you also can find information about installing Drupal on other systems.

If you have problems, read Troubleshooting common problems.

Read more about system requirements (among which detailed PHP-settings and browser requirements).

For the fast command line based installation use Drush

Download and extract files

Download Drupal from http://drupal.org/project/drupal and extract the download file to a folder on your hard drive. (Replace the 'xx' in drupal-x.x.tar.gz with the actual version you've downloaded.)

 wget https://www.drupal.org/files/projects/drupal-x.x.tar.gz
 tar -zxvf drupal-x.x.tar.gz

Move the files to a directory within your web server's document root or your public HTML directory using the following command, substituting drupal-x.x with the actual version number. (On many *nix computers the path from the server's root will be /var/www/.)

mv drupal-x.x /var/www/

You can install and use Drupal in other languages by downloading translations from http://localize.drupal.org/. Extract the files into your installation profile's translations directory. For instance, if you are using the Standard install profile, move the .po file into the directory: profiles/standard/translations/. Note for Drupal 6: This method is currently not working, please see http://drupal.org/node/882164#comment-3486284 for more information.

Read more about downloading and extracting Drupal (includes instructions for other operating systems).

Create the configuration file and grant permissions

In the sites/default directory, copy the default.settings.php file and rename the copied file to settings.php.

cp sites/default/default.settings.php sites/default/settings.php

Give the web server write privileges (666 or u=rw,g=rw,o=rw) to the configuration file.

chmod a+w sites/default/settings.php

Give the web server write privileges to the sites/default directory.

chmod a+w sites/default

Read more about settings.php and the files directory.

Create the Drupal database

To complete the installation, you must create an empty database and a user with full access to the newly created database for Drupal to use. You can do this by command line, or through phpMyAdmin or another database client.

mysqladmin -u username -p create databasename

Where 'username' is a MySQL user which has the CREATE and GRANT privileges. MySQL will prompt for the 'username' database password. Next you must set the access database rights. Log in to MySQL:

mysql -u username -p

At the MySQL prompt, enter:

  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES
  ON databasename.*
  TO 'username'@'localhost' IDENTIFIED BY 'password';

Where:

'databasename' is the name of your database
'username' is the username of your MySQL account
'localhost' is the server name used to access MySQL
'password' is the password required for that username

If successful, MySQL will reply with:

Query OK, 0 rows affected

Read more about creating the database (including instructions on using a browser-based control panel, phpMyAdmin, command line, MySQL, or PostgreSQL to create your database).

Run the installation script

You are now ready to run the installation script. Point your browser to the base URL of your website (e.g. http://www.example.com, http://www.example.com/drupal or http://localhost/drupal).

The installation wizard will guide you through several screens to set up the database, add the first user account, and provide basic website settings. Follow the wizard to finalize the installation and start working with your Drupal website.

Quick installation with Drush

The fastest way to install a site is by using Drush. You can skip most of the other steps above too. Start with only the base of Drupal, which you can also get with Drush...

For an instant Drupal site, running with an SQLite (default) database, you can use the "drush qd" command. This will download and install stable release of Drupal into a timestamped directory, start the inbuilt php server, and open the site logged in as admin.
Below are a few examples:

drush qd

Fire up dev release of Drupal site with minimal install profile.

drush qd --profile=minimal --cache --core=drupal-8.0.x --yes

Fire up stable release (using the cache) of Drupal site called "testsite", download and enable devel module, start a server on port 8081 and open /admin in firefox.

drush qd testsite devel --server=:8081/admin --browser=firefox --cache --yes

Download and install the "Commerce Kickstart" distribution/install profile, display watchdog messages on the server console.

drush qd commercesite --core=commerce_kickstart --profile=commerce_kickstart --cache --yes --watchdog

Create and install a site from a makefile.

drush qd --makefile=mysite.make

See the drush docs for more details

drush dl drupal --drupal-project-rename=example
cd example
drush site-install standard --db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]' --site-name=Example

It will create the database for you if the db_user above has the privileges to.

By default the UID 1 account is given an "admin" username and a random generated password that gets echoed in terminal during the site installation process. You can bypass this and set your own predefined credentials with flags added to the command:

--account-name=admin --account-pass=[useruser_pass]

In case you don't get any password echoed in terminal (might be the case of an earlier drush version) try using admin as username and password.

The installation profile used can be left out, it defaults to standard, or set to something else. Use drush help si to see more flags available for the site-install command.


Resetting your Drupal build with drush site-install

In some cases, you might want to dump your data and rebuild the site from scratch. One example: if building a site based on Features modules, resetting the site would let you test your Features correctly.

To reset, i.e. delete a site's content and set up a "minimal" build, use the following. You can omit database connection strings if they are already hardcoded in settings.php .

$ drush site-install minimal --site-name=MYSITE
You are about to DROP all tables in your 'MYSITE' database. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a while. Consider using the --notify global option. 
Installation complete.  User name: admin  User password: [shows random password generated]

Comments

wolfrage’s picture

SQLite should be a path on this setup too, and it will require far less work, as D7 builds the SQLite DB it's self.

jsjouw’s picture

After following al the steps my the URL that works on my system = http://localhost/drupal-7.0/
The article states http://localhost/drupal/ wich does not work on my system.
is this an error in the article?

authentictech’s picture

http://localhost/drupal-7.0/ and http://localhost/drupal/ are equally correct; which you use is down to user preference. The discrepancy just reflects how you extracted the Drupal files.

You could have also used http://localhost/mywebsite/ or the web root directory for http://localhost/ or rename the directory to anything you want as long as the URL you point your browser to reflects the same name as the directory the Drupal files are stored in.

wayfarer_boy’s picture

I keep forgetting this flag in the tar command, and I sometimes find it difficult to find the handbook page on drupal.org, so I thought I'd post it here.

I sometimes prefer to extract the tar archive directly to my root directory. A tar zxvf drupal-#.tar.gz command results in a drupal-#/ directory being created inside my root directory:

user:/var/www$ wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz
user:/var/www$ tar zxvf drupal-7.0.tar.gz
user:/var/www$ ls
drupal-7.0  drupal-7.0.tar.gz

By using the --strip-components command, you can extract the drupal-# directory contents directly into your root directory:

user:/var/www$ tar -zxv --strip-components=1 -f drupal-7.0.tar.gz
user:/var/www$ ls
authorize.php      INSTALL.mysql.txt   misc        themes
CHANGELOG.txt      INSTALL.pgsql.txt   modules     update.php
COPYRIGHT.txt      install.php         profiles    UPGRADE.txt
cron.php           INSTALL.sqlite.txt  README.txt  web.config
drupal-7.0.tar.gz  INSTALL.txt         robots.txt  xmlrpc.php
includes           LICENSE.txt         scripts
index.php          MAINTAINERS.txt     sites

Better :)

omarsidd’s picture

It would be nice to have the actual script steps executed for things like install and update so there's room for scripting between using the GUI per-site, or using drush. (yes, I could read through both sets of code to figure it out for myself, but since others clearly have, why not make detailed directions available?)

TechNikh’s picture

If your password contains special characters, you have to encode it. otherwise it throws

parse_url(mysql://*****:#####localhost/^^^^^): Unable to parse URL sitealias.inc:1455

you can use tools like http://www.cafewebmaster.com/online_tools/rawurlencode to encode

Cheers,
TechNikh

In 30 seconds set up Automated Visual testing of your website. Zero coding. https://drupal.org/project/drulenium
Ever dreamed of styling your view, We have a solution for you. https://drupal.org/project/views_stylizer

johnhorner’s picture

When I got to the end of my install, I got a very stern warning from Drupal that settings.php and sites/default need to be set back to safer permissions. But Drupal doesn't link to instructions and neither does this guide, at first glance.

The issue is that you need to reverse:

chmod a+w sites/default/settings.php
chmod a+w sites/default

by doing

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

right?

A second link here to http://drupal.org/node/540242 which is described as instructions on "preparing the configuration file" (really it's about both preparing before and securing it after installation) would be good. The information is there but the link is a bit obscure.

Either that or just add "After successful installation, Drupal will tell you to secure the files. Here's how."

ttibensky’s picture

how to install ‪#‎Drupal‬ on ‪#‎ubuntu‬ using drush on command line, quick simple video http://t.co/7DuHdGukVh

I hope it will help you :-)

Erik de Kamps’s picture

I usually take my google sheet (drush commands) and fill in what I need to.
This will create a full command I just paste into the command line to download and install the latest Drupal version.

timfelix’s picture

I had to remove the single quotes around my database url for the install to work with drush so:

drush site-install standard --db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]' --site-name=Example

changed to:

drush site-install standard --db-url=mysql://[db_user]:[db_pass]@localhost/[db_name] --site-name=Example

antonio_pantano’s picture

There's a project developed by me that aims to ease the Drupal installation process.
The project is hosted on githib https://github.com/ovidius72/drupal-wizard.

ROrt’s picture

There is a very nice web aplication that can configure your server and install drupal out of the box.
go to www.nodalbot.com
there are serveral tutorials on how to install drupal in CentOS 7 using your own cloud server.

kari.kaariainen’s picture

Where specifically? Couldn't find.