How to Install Drupal 7 on Linux

Few Days ago Drupal 7 was released !
Because of that I decided to make a tutorial about installing and configuring it on a Linux machine
With Apache server installed on it

After Installing Apache server: Click here
You’ll have to be sure if you have php5 and some other things… so install them..

$ sudo apt-get install php5 php5-mysql php5-gd libapache2-mod-php5

after that restart your apache server:

$ sudo /etc/init.d/apache2 restart

Now go ahead and type:

$ sudo gedit /etc/apache2/apache2.conf

and enter this line to the end so that Drupal will function properly with apache and php (save it):

AddType application/x-httpd-php .html

Now to test php nad see all other detalis type:

$ sudo gedit /var/www/testphp.php

and enter this then save :


Restart your server:

$ sudo /etc/init.d/apache2 restart

and go ahead to your browser and test PHP !


OK done with this so now we have to :

Configure Mysql to work with Drupal

First, you’ll need to run MySQL’s install script:

$ sudo mysql_install_db

And then type this command , to secure MySQL. And follow the default prompts to remove the testing database in MySQL:

$ sudo mysql_secure_installation

when that is complete log in to mysql:

mysql -u root -p

Create Database : (I used drupal as the database name)


Create User: (same here, drupaluser as the user name)

$ CREATE USER drupaluser@localhost;

Create Password for your new User:

$ SET PASSWORD FOR drupaluser@localhost= PASSWORD('typepasswordhere');

Note : leave quotation marks !

Now that you’ve got the database name and user, go ahead and :
Grant all permissions to the user :

$ GRANT ALL PRIVILEGES ON drupal.* TO drupaluser@localhost IDENTIFIED BY 'password';

Note: Leave the quotation marks at the password !

Finally lets start with Drupal

Get the latest package here :

Copy the file to /var/www/
and unpack it by typing :

$ sudo tar -xvzf drupal-7.7.tar.gz

then change directory to drupal-7.7

$ cd drupal-7.7

and lets change some permissions :

$ sudo chmod a+w sites/default
$ cd sites/default

create a copy of default.settings.php to settings.php

$ cp default.settings.php settings.php

Change permission:

$ sudo chmod a+w settings.php

Create a directory with the name (files):

$ sudo mkdir files

again change permission

$ sudo chmod a+w files

All done !
Open up browser and go to :
it will open up a Drupal page !
now go ahead and fill up the boxes… Thats it.

Note : After finishing all Drupal installation, change permissions to those files above [“default” folder  | “settings.php” file  |  “files” folder ]  to prevent unwanted users working on them.. you do it with go-w permission:

$ sudo chmod go-w settings.php

As about files directory/folder change its permissions to 757:

$ sudo chmod 757 files

Thank you, hope it helps :)

10 thoughts on “How to Install Drupal 7 on Linux

  1. If you browse from the desktop to this installation can you use the “update from URL” to install modules? If so are there any necessary permissions required on the server?

    1. If you want to update or even install modules via drupal site (web-browser) than of course you’ll need to have ftp access,
      as abut the 1st question it didn’t seem very clear… :)

  2. Just a great post. Been struggling unsuccessfully with other incomplete or incomprehensible instructions. But yours could not be better…

  3. Thank you ALTIN UKSHINI for this wonderful instructions. L have done exactly as u have stipulated but when l try to configure drupal database. This is the error l get. Your help is appreciated

    In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.

    Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘niaje’ (111).

    Is the database server running?
    Does the database exist, and have you entered the correct database name?
    Have you entered the correct username and password?
    Have you entered the correct database hostname?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s