Magento E-Commerce Solution On Debian Etch

Version 1.0
Author: Oliver Meyer <o [dot] meyer [at] projektfarm [dot] de>

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:

Hostname: server1.example.com
IP: 192.168.0.100
Subnetmask: 255.255.255.0
Gateway: 192.168.0.2
Pri.DNS: 192.168.0.2

 

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:

extension=apc.so

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
%sql_root_password%

 

4.3 Database User

Now we create a new user for the magento database.

mysql -u root -p
%sql_root_password%
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%';
FLUSH PRIVILEGES;

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

quit;

 

5 Get Magento

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

cd /var/www/
wget http://www.magentocommerce.com/downloads/assets/0.6.14100/light/magento-0.6.14100.tar.gz
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:

NameVirtualHost 192.168.0.100:80

<VirtualHost 192.168.0.100:80>
    ServerName www.example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/magento/
    
    <Directory /var/www/magento/>
        AllowOverride All
    </Directory>
    
    ErrorLog /var/log/apache2/magento_error.log
    CustomLog /var/log/apache2/magento_access.log combined
    LogLevel warn
    
</VirtualHost>

 

7.2 HTTPS

vi /etc/apache2/sites-available/magento_ssl

It should look like this:

NameVirtualHost 192.168.0.100:443

<VirtualHost 192.168.0.100:443>

    ServerName www.example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/magento/

    SSLEngine on
    SSLCertificateKeyFile ssl/server.cert.key
    SSLCertificateFile ssl/server.cert.crt
    SSLProtocol all
    SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

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

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

</VirtualHost>

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)