Installing OpenCart

Let’s get our OpenCart package from the Web. We can find it on their website: http://www.opencart.com/index.php?route=download/download.

Note: We will download the latest version. For this book, we will be using OpenCart version 1.4.8.

How to do it…   

We have downloaded our OpenCart package. Now, we will extract it and copy the downloaded folder of the OpenCart package into the htdocs folder of Xampp and rename the folder to our project name. Let’s, name it ‘shop’. We need to ensure read and write permissions for the following files and folders:

image/

image/cache/

cache/

download/

config.php

admin/config.php

1. Database creation

We need to create a database for our OpenCart project. We will go to our phpMyAdmin using the URL: http://localhost/phpmyadmin. We are going to create our database. Let’s call our database open_book with collation utf8_general_ci. This collation will improve database searching. Write the database name here for future reference:

Database Name________________ _.

We will create a new user for our database with limited user privileges. This will increase database security. For this, go to privileges->add_a_new_user. Write down the following information that we set in the new user window, here, for future use:

User Name____________________ _.

Host Name____________________ _.

Password____________________ _.

2. Setting up virtual host

We are going to set up virtual host for our shop. First, let’s see how to set it up in the Linux environment. We will create a vhost file under/etc/sites-available/.

Then, type the following command in the terminal:

a2ensite project_name

Here, project_name will be our folder name under the document root folder. Now, we will write an extra following line in the hosts file under /etc/ folder.

Now, restart Apache by typing the following command in the terminal:

/etc/init.d/apache2 reload

Access your browser and type the project URL, we will see our site.

The setup of the virtual host is different in the Windows environment than Linux. From Apache 2.2 onwards, we have a different vhost file to create the virtual host under the xampp/apache/conf/extra folder named httpd-vhosts.conf. Open the file; following is the code block that we need to write for each of our projects:

<VirtualHost *:80>

ServerAdmin webmaster@shop.com

DocumentRoot D:\xampp\htdocs\shop

ServerName local.shop.com

ErrorLog E:\error\local.shop.com-error_log

CustomLog E:\error\local.shop.com-access_log common

</VirtualHost>

3. OpenCart configuration settings

We have set up our virtual host. Now, type the project URL: http://localhost/shop on the browser.

⯈     Step-01: First, we will see the licence agreement option of OpenCart. Read the licence and mark the agree option of the licence agreement and then click on the continue button.

⯈     Step-02: This shows the necessary pre-installation configuration setup of our server. There is a green tick mark, which is OK, and there is a red mark that needs to be corrected. It also shows the writable options. If everything is in the correct state, click on the continue button.

⯈     Step-03: This shows the configuration options that we need to set for our project.

They are database configuration settings:

Let’s discuss the fields:

  • Database Host: Previously, we wrote down our database host name for future We will enter our database host name here.
  • Database User: This will be our database We also stored this previously.
  • Database Password: We will enter our database
  • Database name: This is our database

Let’s discuss the administration fields here:

  • Username: This will be our administration We will write it down here for future reference.

Admin Username_________________________ _.

  • Password: This will be our password for admin We will store it here for future reference.

Password___________________________ _.

 

4. Running the site

We have everything configured; the stage is set for viewing our OpenCart project default site.

Open your favourite browser, then type our project URL: http://local.shop.com/

Our default site will appear like the following:

5. Post install configuration

If for any reason we need to modify the settings that were entered during the installation, there are two configuration files that can be modified. Settings applied to the catalog area:

<install dir>/config.php

Settings applied to the administration area: <install dir>/admin/config.php

We have set up our OpenCart project ‘shop’. Now, let’s discuss the tools that we are going to use throughout this book.

Source: Hasan Tahsin (2011), OpenCart 1.4 Template Design Cookbook, Packt Publishing.

Leave a Reply

Your email address will not be published. Required fields are marked *