Magento E-Commerce Solution On Debian Etch

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

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

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

MySQL PreparationIn this step we prepare a database for magento.

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.

Magento Database

Next we create a database for magento.

~# mysqladmin -u root -p create magento
%sql_root_password%

Database User
Now we create a new user for the magento database.

~# mysql -u root -p
~# %sql_root_password%

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;

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
ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/magento/
AllowOverride All

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

HTTPS
~# vi /etc/apache2/sites-available/magento_ssl

It should look like this:

NameVirtualHost 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
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

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

Install Magento

Open http://www.example.com within your browser on the workstation – the installation wizard appears. Read the license agreement and accept it if you agree with it. Afterwards click on “Continue”.

Follow these screen shots for more details and setup of MAGENTO
Screen Shots

Content credit: mp3skulls