How To Setup Drupal On Ubuntu Server
In this tutorial we will install Drupal 7 on Ubuntu Server. If you would like steps on how to setup Ubuntu server visit one of the following URLs:
Install Ubuntu Server 11.04: ../ubuntu/how-to-install-and-configure-ubuntu-1104-as-a-web-server.html
Install Ubuntu 10.04 LTS Server: http://mixeduperic.com/ubuntu/how-to-install-ubuntu-server-1004-web-server.html
In the following steps we will assume that you are installing this on a fresh install of Ubuntu server with no other web sites running. If you already have other sites adjust the steps to fit your enviroment.
Note: Drupal can some time render weird if you don't have it in the root directory or virtual host setup.
We will be installing the most current version of Druapl (7.8 as of writing this).
If you would like to install a different version grab the .tar file from drupal.org:
You can also use the offical drupal documentation for additional help.
Login to your ubuntu server with a user that has sudo privilages.
Change directories into the web server directory. (Default: /var/www/)
If you issue the ls command you can see the files located in this directory. Note that by default there is a file called index.html. This is the default file when you first install apache. This file can be deleted.
By default apache has a index.html file that is used to test the default web server. We will want to remove this file.
sudo rm index.html
Enter your password
Now if we do the ls command again we should just have a blank folder.
we will now want to download the drupal files from drupal.org. We will use wget to pull these down.
Once it completes we will ls again to confirm that it downloaded
We will now want to untar are drupal download
Note: I am using a * in the command so if a new release is out when you are reading this it should still untar it.
sudo tar -xvf drupal*.tar.gz
Since we have sucessfully untared it we will want to clean up and remove the tar file.
Now lets change directories into the drupal folder
Now we are going to want to copy all the files in the untared drupal folder to the root of the web server /var/www/
sudo cp -R * /var/www/
We will also want to make sure we moved the .htaccess file
sudo cp .htaccess /var/www/
Lets move back a directory so we are in the root of the web server directory.
we will use the ls command once again . This time lets use the -a option to display all files. The reason for this is the .htaccess file is hidden by default. We want to make sure this file os located here.
We will want to do one more clean up. We can now remove the folder we just copied all the files from (drupal-version-number).
sudo rm -r drupal*
We will now need to make 2 directories
sudo mkdir /var/www/sites/default/themes
(This is the directory you can download your themes to)
sudo mkdir /var/www/sites/default/modules
(This is the direcory you can download all your modules to)
We will need to make a few temporaty permission changes to a directrory and file for the install. Once we are done we will change permissions back.
sudo chmod a+w /var/www/sites/default
Last but not least we need to create a settings.php and change permissions to it.
sudo cp /var/www/sites/default/default.settings.php /var/www/sites/default/settings.php
We need to make sure the server has write permissions for the install.
sudo chmod a+w /var/www/sites/default/settings.php
Setting Up the Database:
To keep things simple we will use phpMyAdmin to setup a database and a database user. If you need steps on how to install phpMyAdmin on your Ubuntu system visit the following link:
Click on the Privilages tab
Click on Add A New User link (located just below the list of current users)
Create A name for the user (Example: drupal)
Set host to localhost
Generate and copy the password or create your own. (You should only need this password for the first setup of the drupal site.)
Select the Create database with same name and grant all privileges radio button
Scroll down to the bottom and select Go
You should see a message saying that You have added a new user.
We now have are drupal MySQL database created with a username.
We are getting close to having things up and running. Open up your web browser and type the IP address of you drupal web server .
Select Standard Install and click Save and continue
Select English and click Save and continue
Enter Your database username that you created in phpmyadmin
Since we created the database to be the same as the username I enter it again
Enter the password for your MySQL database
Click on Save and continue
It should take a few minutes to install all the modules.
Create A name for your website. This could be anything you want.
You can add a email address or use a fake one such as No-Reply@YourDomain.com
Create a username that you want to use to login to the site.
Enter the email address of that user. I would recommending using your real email address.
create a password
Set Time Zone
Click Save and continue
Congrats you have a basic drupal site up and running
Click on the visit your new website link to see what it looks like.
Now that we have are site up and running we need to go back to the server and secure two things. We need to change permissions on a folder and a file that holds are database information. We really want to make sure settings.php is secure.
sudo chmod go-w /var/www/sites/default
sudo chmod go-w /var/www/sites/default/settings.php
You should be all set to start enjoying the powers of drupal on your Ubuntu Linux Sever. In later articles we will exploreer configuring drupal and covering some of the basic concepts.
If you enjoyed this post, please share it on your favorite social network by clicking on the “Share / Save” bar below.