---
layout: post
title: How to install Magento on Ubuntu
author: David T. Sadler
description: By the end of this guide you will have installed Magento locally on Ubuntu.
categories: ["Magento","Ubuntu"]
robots: follow, noodp, noydir, noarchive
comments: true
google_plus: true
twitter_share: true
facebook_like: true
published: false
licensed: true
---
By the end of this guide you will have installed Magento, and some sample data, locally on Ubuntu. This will allow you to get to grips with the software before installing it onto a production server. In addition to Magento I will take you through installing Apache, PHP and MySQL. I'm going to assume that you are using Ubuntu 12.04 (Precise Pangolin) and that you wish to install version 1.7.0.0 of Magento. You're results may vary if you are using different versions.
As this is quite a long post I have broken it down into various sections. Feel free to ignore those parts that are not relevent for you.
* [Getting started.](#start)
* [Installing and configuring the Apache HTTP server.](#apache)
* [Installing the PHP scripting language.](#php)
* [Installing the MySQL database server.](#mysql)
* [Creating the directory from which Magento will be served from.](#directory)
* [Configuring the Apache Virtual Host.](#vhost)
* [Installing Magento.](#magento)
Getting started.
If you have never heard of Magento the following from the website will explain.
Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magento’s intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give merchants the power to create sites that are tailored to their unique business needs. Designed to be completely scalable and backed by Varien's support network, Magento offers companies the ultimate eCommerce solution.
Magento is available in two editions, Community and Enterprise. The Enterpise edition is the company's commercial version of the software and is meant for large-scale eCommerce users. The Community edition on the other hand is available as a free download under the open source OSL 3.0 license and is the version that you will be installing.
This post will walk you through every thing you need to get a local copy of Magento running on Ubuntu. It is not meant as a guide to installing a fully working eCommerce store located on a production server.
To begin, open up a terminal and enter the command below.
{% highlight bash %}
sudo apt-get update
{% endhighlight %}
This will ensure that the computer's database of software packages is updated to contain the latest versions. While this command is not strictly necessary, I tend to issue it before installing any software so that the most up to date versions of the packages are used.
Installing and configuring the Apache HTTP server.
Apache is easily installed by entering the following command.
{% highlight bash %}
sudo apt-get install apache2 -y
{% endhighlight %}
During the install you may notice the following warning:
{% highlight console %}
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
{% endhighlight %}
This comes from Apache itself and means that it was unable to determine its own name. The Apache server needs to know its own name under certain situations. For example, when creating redirection URLs.
To stop this warning we can create an Apache config file to store the name. On a production server you would set this as either a hostname or a FQDN, but for local development we can get away with using 'localhost'.
{% highlight bash %}
sudo bash -c "cat >> /etc/apache2/conf.d/servername.conf <Installing the PHP scripting language.
As can be seen from the list of system requirements, Magento needs PHP version 5.2.13 or later with the following extensions.
* PDO_MySQL
* simplexml
* mcrypt
* hash
* GD
* DOM
* iconv
* curl
* SOAP
We will therefore install PHP with the following command.
{% highlight bash %}
sudo apt-get install php5 php5-curl php5-gd php5-mcrypt php5-mysql -y
{% endhighlight %}
Installing the MySQL database server.
The command below will install MySQL. Note that the install process will ask you to create and confirm a password for the root user. Remember the password that you enter as it will be needed later.
{% highlight bash %}
sudo apt-get install mysql-server -y
{% endhighlight %}
Creating the directory from which Magento will be served from.
Before we get into the business of creating the directory I need to point out a few things. The process below is heavly infulenced by how I setup websites when developing locally. The actual whys and wherefores of how I do this is are too long to go into detail in this post but can be summarised as such.
* Each site is served from its own directory named after the site's domain name. E.g, `my-example-site.com`
* Group ownership of these directories, and their contents, is set as `www-data`. The same group that the Apache process runs under.
* The directories are located in a `public_html` directory that has been created in my home directory.
Many of the commands that follow use absoulte paths when refering to directories located in my home directory. Since the username on my computer is `dev` you will need to replace any occurrences of this with your own username. Feel free to also change the location of any of the directories. Just remember that you must use the correct location when configuring the virtual host later on.
Configuring the Apache Virtual Host.
Installing Magento.