Skip to content

How to install magento on ubuntu




There are a number of blog posts available online which attempt to explain how to install magento on ubuntu for  development. However, having spent the best part of an evening following a vast majority of the sites going through this exercise, I found they were all either incomplete, out of date or just completely inaccurate.

This article will attempt to fill the void and aim to provide a complete guide on how to successfully and completely install magento on a ubuntu desktop in order to carry out some magento development.

to install magento on ubuntu you will need to configure your desktop to make use of the LAMP stack, which primaritly means Linux, Apache, MySQL and PHP, therefore you will need install Apache mySQL and PHP onto your local machine.

I have previously written a blog post about configuring your ubuntu desktop for LAMP server development ,  Install and Configure a LAMP Server on Ubuntu Desktop or alternatively you can install each component separately as detailed below. Making using of the TaskSel is my preferred approach to quickly configure my desktop. However, I have provided below  a step by step guide to setting up your workstation.

To follow along using the tutorial you will need to open a terminal window and enter these following commands

1. Install apache server

sudo apt-get install apache2

Start your apache web server

sudo service apache2 start

Open you Apache configuration file using gedit your default text file editor

sudo gedit /etc/apache2/sites-available/000-default.conf

N.B. I assume you are installing magento onto a vanilla machine and you have not previously configured it as something else.




I usually delete all the contents of the configuration file and just have it as below. I find all the other comments etc too confusing.

<VirtualHost *:80>
	
        ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html/magento
	ServerName localhost
	
	<Directory /var/www/magento>
			Options Indexes FollowSymLinks MultiViews
			AllowOverride All
			Order allow,deny
			allow from all
	</Directory>

	
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save and exit the file. Restart your apache server

sudo service apache2 start

2. Install mySQL

sudo apt-get install mysql-server mysql-client

You'll be prompted for a root password, enter one that you would like to use and remember it.

Start up your mySQL server

sudo service mysql start

Create a database and user for magento

mysql -u root -p

Create a User with name of Magento and a Password of magento

CREATE DATABASE magento;
INSERT INTO mysql.user (User,Host,Password) VALUES('magento','localhost',PASSWORD('magento'));
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON magento.* TO magento@localhost;
FLUSH PRIVILEGES;
exit

3. Install PHP

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-gd php5-mysql php5-tidy php5-xmlrpc php5-curl php5-common php5-cli php5-ldap

install the php xml parser

sudo apt-get install php-xml-parserr

Increase the memory limit for PHP by altering the PHP configuration file

sudo gedit /etc/php5/apache2/php.ini

Change memory limit from

memory_limit = 128M

to

memory_limit = 512M

Save the file and close

You will need to enable the mcrypt. Mcrypt is an encryption alogrithm library that uses several modern algorithms such as AES.  Magento makes use of mcrypt so you will need to enable it.

cd /etc/php5/mods-available
sudo ln -s ../conf.d/mcrypt.so
sudo php5enmod mcrypt
sudo service apache2 restart

You will also need to enable curl

sudo apt-get install php5-curl
sudo service apache2 start

 

4. Download and install magento
Download magento to your temporary folder

cd /tmp/ && wget http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz

extract the downloaded files and move them to the working folder

 tar -xzvf magento-1.9.0.1.tar.gz

sudo mv /tmp/magento /var/www/html/magento/

set up some permissions

chown www-data:www-data -R /var/www/html/magento/
cd /var/www/html/magento
chmod -R o+w app/etc/
chmod -R o+w var/
chmod -R o+w media/

Restart apache web server again

sudo service apache2 start





5. Install Magento
We can now actually install magento, this should now be relatively straight forward.
Open your browser and navigate o localhost, and the following screen should be displayed.
Magento installation wizard

Agree to the terms and conditions. In the following screen just enter the details that we created
host = localhost User: magento password magento

Magento Create Admin account screen

Gary Woodfine
Latest posts by Gary Woodfine (see all)