Creating an OpenCart shop – Part One: Pre-Requisite Installation

This will be a series of posts covering the installation and basic configuration of an online store using the excellent OpenCart software. This post will cover the basic installation of OpenCart’s core pre-requisites (Listed Below) on a Debian 6 based system. For this example i used OpenCart v1.5.2.1 – But it should broadly cover most other versions of OpenCart/Debian.

  • Web Server (We will use Apache)
  • PHP (at least 5.2)
  • MySQL
  • Curl
  • Fsock
  • GD Image Module
  • OpenCart v1.5.2.1

 

The first thing you’re going to want to do is check that your servers hostname (and fully qualified domain name) are both set correctly. We can do this using the hostname command with the -f switch:

$ hostname -f
shop.ajstanfield.com

Now that we’re happy the basics are in place we can start installing our LAMP stack and other Pre-Requisites. The first thing we are going to do is update our repositories and then install Apache.

$ aptitude update
aptitude install apache2 apache2-doc apache2-utils
# Whilst we're here, We may aswell enable Apaches rewrite capabilities
a2enmod rewrite

Next we’ll install PHP and the apache PHP library. We will also install pear, xcache and suhosin and the PHP MySQL module.

$ aptitude install libapache2-mod-php5 php5 php-pear php5-xcache php5-suhosin php5-mysql

Now it’s time to install curl and the curl php module

$ aptitude install php5-curl curl
# Now we'll need to enable the curl module, If you are not familiar with vim text editor nano is a good alternative.
vim /etc/php5/apache2/php.ini
#Look for the extensions stanza and add:
extension=php_curl.so
#Restart Apache:
/etc/init.d/apache2 restart

The final module we’ll need to install is the GD Image Module which OpenCart will use for dynamically manipulating images.

$ aptitude install php5-gd
#Restart apache:
/etc/init.d/apache2 restart

Now we can move onto installing and configuring the MySQL server.

$ aptitude install mysql-server
# At this point you will be thrown into an ncurses based installer - Simply follow the on-screen instructions and you should be fine!.
# Once the installation is completed we'll need to secure the MySQL installation by running:
mysql_secure_installation
#When prompted for root password, Either enter the one you set during installation - Or leave blank if you didn't set one. You should Always change the root password if you did not set one at installation!
# Answer 'Yes' to all the questions the mysql secure installation script asks.
# The final thing we'll do is log into the MySQL CLI and create a user and database for opencart to use
mysql -u root -p
mysql > CREATE DATABASE opencart;
mysql > GRANT ALL ON opencart.* TO 'youruser'@'localhost' identified by 'yourpass'; #remember to replace youruser and yourpass with your desired username and password!
#Finally we'll just test connecting to the database to confirm everything is working!
mysql -u youruser -p opencart

And there we have it – By now you should have a working LAMP stack with all of OpenCarts required modules installed and ready to go. In the next part we will look at installing the OpenCart packages.