Magento E-Commerce Solution On Debian Etch

Version 1.0
Author: Oliver Meyer <o [dot] meyer [at] projektfarm [dot] de>
Last edited 12/18/2007

This document describes how to set up Magento on Debian Etch. The resulting system provides a professional open-source e-commerce solution with a many features. Please note, that Magento is currently in a preview release and not recommended for use in production environments. But at least it's worth to glance at it.

This howto is a practical guide without any warranty - it doesn't cover the theoretical backgrounds. There are many ways to set up such a system - this is the way I chose.


1 Preparation

Set up a standard Debian Etch system and update it. I used the following configuration for the attached virtual machine:



2 Needed Packages

First we install some needed packages to prepare the system for magento.

apt-get install apache2 apache2-prefork-dev mysql-server-5.0 php5 php5-dev php5-mysql php5-mcrypt php5-mhash php5-curl php-pear re2c make


3 APC Cache

It's recommended to use APC as a bytecode cache (other bytecode caches are currently not supported). Install it via:

pecl install apc

Select "yes" when you're asked if you want to use apxs to set compile flags. Afterwards we have to add APC to the php.ini - before you should make a backup.

cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.orig

vi /etc/php5/apache2/php.ini

Add the following line:

Now you have to restart apache.

/etc/init.d/apache2 restart


4 MySQL Preparation

In this step we prepare a database for magento.


4.1 Root Password

First we have to assign a password to the SQL root user.

mysqladmin -u root password %sql_root_password%

Note: I used the password howtoforge in the attached vm.


4.2 Magento Database

Next we create a database for magento.

mysqladmin -u root -p create magento


4.3 Database User

Now we create a new user for the magento database.

mysql -u root -p

GRANT CREATE, ALTER, INDEX, DROP, CREATE TEMPORARY TABLES, SELECT, INSERT, UPDATE, DELETE ON magento.* TO 'magento_admin'@'localhost' IDENTIFIED BY '%magento_admin_password%';
GRANT CREATE, ALTER, INDEX, DROP, CREATE TEMPORARY TABLES, SELECT, INSERT, UPDATE, DELETE ON magento.* TO 'magento_admin'@'localhost.localdomain' IDENTIFIED BY '%magento_admin_password%';

Note: I used the password secret in the attached vm.



5 Get Magento

Time to download and unpack magento. Additionally we have to change the rights.

cd /var/www/
tar xvfz magento-0.6.14100.tar.gz
rm -f magento-0.6.14100.tar.gz
chown -R root:root magento/
chown root:www-data magento/var/.htaccess
chown -R root:www-data magento/app/etc/
chown -R root:www-data magento/var/
chown -R root:www-data magento/media/


6 SSL Certificate

We create a SSL certificate for the SSL-vhost. Please note that this self signed certificate is only for testing purposes.

mkdir /etc/apache2/ssl/
cd /etc/apache2/ssl/
openssl req -new > server.cert.csr
openssl rsa -in privkey.pem -out server.cert.key
openssl x509 -in server.cert.csr -out server.cert.crt -req -signkey server.cert.key -days 365


7 Magento VHosts

We'll create two vhosts - one for http-connections and one for https-connections.


7.1 HTTP

vi /etc/apache2/sites-available/magento

It should look like this:


    ServerAdmin [email protected]
    DocumentRoot /var/www/magento/
    <Directory /var/www/magento/>
        AllowOverride All
    ErrorLog /var/log/apache2/magento_error.log
    CustomLog /var/log/apache2/magento_access.log combined
    LogLevel warn



vi /etc/apache2/sites-available/magento_ssl

It should look like this:



    ServerAdmin [email protected]
    DocumentRoot /var/www/magento/

    SSLEngine on
    SSLCertificateKeyFile ssl/server.cert.key
    SSLCertificateFile ssl/server.cert.crt
    SSLProtocol all

    <Directory /var/www/magento/>
        AllowOverride All
        SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128

    ErrorLog /var/log/apache2/magento_error.log
    CustomLog /var/log/apache2/magento_access.log combined
    LogLevel warn


Add the HTTPS listen port to the apache configuration.

vi /etc/apache2/ports.conf

Add the following line:

Listen 443


7.3 Modules & Sites

After that we enable the new sites, ...

a2ensite magento
a2ensite magento_ssl

... the rewrite module ...

a2enmod rewrite

... and the ssl module.

a2enmod ssl

Now we have to restart apache.

/etc/init.d/apache2 restart

Share this page:

6 Comment(s)

Add comment


From: mattia at: 2008-09-18 14:25:33


Just to mention you forgot to add GD to the installation list....

apt-get install php5-gd

 I spent 2 days to figure it out after moving a mgento installation on a server I used this great guide to setup, maybe this post will help someone....

From: TechDivision at: 2008-10-12 12:53:33

Thank you for your installation-tutorial. Really great work, that saved us a lot of time. Magento works perfect now.

From: gazmcghee at: 2009-01-28 00:11:23

NameVirtualHost is not required when you have VirtualHost and ServerName.

From: at: 2009-07-22 05:41:49

Nice Blog, 

E commerce development can boost your sales on internet.

From: Daniel at: 2011-03-06 13:47:12

Really cool! Works for my Debian Lenny. I spent 8 hours to find solution and finally got the answer.

From: Anonymous at: 2011-10-11 22:48:55

HowToForge N.1!