Magento E-Commerce Solution On Debian Etch

Want to support HowtoForge? Become a subscriber!
 
Submitted by o.meyer (Contact Author) (Forums) on Thu, 2008-01-10 17:53. :: Debian | PHP

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:

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 webmaster@example.com
    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 webmaster@example.com
    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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Daniel (not registered) on Sun, 2011-03-06 14:47.
Really cool! Works for my Debian Lenny. I spent 8 hours to find solution and finally got the answer.
Submitted by Anonymous (not registered) on Tue, 2011-10-11 23:48.

HowToForge N.1!

 

Submitted by kethywright (registered user) on Wed, 2009-07-22 06:41.

Nice Blog, 

E commerce development can boost your sales on internet.

Submitted by gazmcghee (not registered) on Wed, 2009-01-28 01:11.
NameVirtualHost is not required when you have VirtualHost and ServerName.
Submitted by TechDivision (not registered) on Sun, 2008-10-12 13:53.
Thank you for your installation-tutorial. Really great work, that saved us a lot of time. Magento works perfect now.
Submitted by mattia (not registered) on Thu, 2008-09-18 15:25.

Hey
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....