OpenCart 1.4: Beginner's Guide

By Murat Yilmaz
    Advance your knowledge in tech with a Packt subscription

  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Installing OpenCart

About this book

OpenCart is a popular open source shopping cart solution and provides elegantly written tools to establish a fully functional online store from scratch in a very short time with intuitive screens. It can be a difficult task for beginners to go beyond the basics and apply all the features, which they will require for their businesses.

This practical book gives you hands-on experience on using and managing OpenCart, helping you start feature-rich, professional online stores easily. It also teaches you how to organize your online store effectively in terms of products, payments, shipping, orders, and customer relations.

OpenCart 1.4 Beginner's Guide will teach you how to build a store that can take control of all the online shopping needs. You will be able to run multiple shops in a single installation. You will learn how to set up products and correctly organize in categories. You will correctly integrate a payment gateway and shipping method after reading the comparisons and applying the examples. You will learn how to define taxes and apply them according to the geolocation of a customer. This book also teaches you how to manage orders and customers. You can impress your customers and increase the availability of the website to more people with the help of this practical guide. Additionally, the book also teaches you how to use design templates and apply SEO (search engine optimization) to make the store more visible for search engine queries.

Publication date:
August 2010
Publisher
Packt
Pages
240
ISBN
9781849513029

 

Chapter 1. Installing OpenCart

Since OpenCart is a considerably new online shopping cart solution, many web hosting service providers do not have one-click installation for OpenCart yet. So, we will need to install OpenCart ourselves.

Installation of OpenCart is an easy task and follows a standard procedure like PHP and MySQL-based open source software. On the other hand, there are some important key points we should be careful at.

In this chapter we shall:

  • Learn the system requirements needed to install OpenCart

  • Learn to download and upload OpenCart files to a web server

  • Learn to set file and folder permissions

  • Learn to create a MySQL database and user

  • Learn to complete installation with the OpenCart wizard

This chapter is suggested for reading even if you are a tech-savvy computer user, as you can eliminate the possible problems while installing OpenCart.

 

System requirements


By the time of the writing of this book, the latest OpenCart release is 1.4.7 and the system requirements are valid for this version. Previous versions can need the same or fewer requirements.

Tip

We would suggest installing v1.4.7 and reading the book carefully. If there are new releases of OpenCart after the publication of this book, you can at any time download it from the OpenCart website and see the differences easily because you will already have a strong foundation in OpenCart after completing the book.

We must download and install OpenCart on our own or on a shared web hosting solution. OpenCart system can run on an Apache or Windows server. Currently, OpenCart supports only MySQL database. Overall, OpenCart was designed to work flawlessly on an ideal LAMP solution (Linux, Apache, MySql, and PHP), but it is also possible to run using a Windows server, MySQL, and PHP.

Tip

If you aim to run OpenCart on Windows, you can use WAMP Server. It is available for download at http://www.wampserver.com/en/.

The following screenshot shows the minimum system requirements for OpenCart for installation and running without problems.

You should contact your hosting provider if you are not sure whether these settings are set or not.

Note

If you want to take advantage of SEO URLs, your hosting should allow using mod_rewrite extension for Apache and permission to change .htaccess file

We will talk about SEO in OpenCart in Chapter 4, Configuring Store Settings.

 

Installing OpenCart


Be sure that your web hosting solution meets the previous requirements before starting installation steps. The easiest way of determining this is to send a requirement list to web server technical support. We will complete installing OpenCart using the following sections:

  • Downloading OpenCart from http://opencart.com

  • Uploading OpenCart files to a web host

  • Creating MySQL database and a user for OpenCart

  • Using OpenCart installation wizard

  • Deleting installation files after completion

  • Browsing to online storefront

  • Making first login to OpenCart administration interface

Now, let's start to explore each section in detail.

 

Downloading OpenCart


Downloading the latest version of OpenCart is an easy and straightforward task. Let's see how we achieve downloading.

 

Time for action – downloading OpenCart


In this section, we are going to download OpenCart archive file.

  1. We browse to the http://www.opencart.com/index.php?route=download/download link. This page will list the latest OpenCart version. The download page is similar to the following screenshot.

    Note

    We can see the full list of OpenCart versions on: http://code.google.com/p/opencart/.

  2. Let's click on the link and choose the Save File option to save it in the computer:

What just happened?

We have downloaded the OpenCart files as a ZIP archive file on our computer. Now we are ready to upload the files to the web host.

 

Uploading OpenCart files


There are two common methods for uploading files to a web host:

  • Using cPanel File Manager Utility

  • Using an FTP Client

We will learn both the methods with examples.

Tip

The first method is suggested because we can upload the installation files faster to the host.

We suggest installing OpenCart on a directory, such as http://yourwebsite.com/store

By doing this, we will able to close the shop temporarily if we need to later, without affecting the root domain at http://yourwebsite.com.

Let's start with the suggested cPanel method.

 

Time for action – uploading OpenCart using cPanel File Manager


This is the first method of uploading OpenCart files to a web host. Many modern web hosting solutions include a control panel called cPanel, and we can use the cPanel File Manager utility to directly upload a ZIP file to web host and decompress the files there easily.

In this example, we will install OpenCart on the store directory.

Note

You can generally reach cPanel on http://yourwebsite.com/cpanel with the username and password which the hosting provider emailed to you upon registration.

  1. Let's open File Manager utility at cPanel.

  2. It will choose the Web Root as default. We will continue with the Go button.

  3. Let's click on the Upload link.

  4. Let's choose OpenCart ZIP file using the Browse button on the next screen. After the upload completes, we return back to the main cPanel File Manager screen.

  5. We will right-click on the file and select Extract.

  6. It will open a pop-up window. Just press the Extract File(s) button to decompress the ZIP file into the root web folder.

    All files were extracted into a folder named opencart_v1.7.

    Tip

    The default folder name depends on our OpenCart version.

  7. We will need to browse into this folder first. We see a folder called upload under it. We will need to rename it as store at first.

    Right-click on it and choose Rename from the menu.

  8. Rename the directory as store, as in the following screenshot:

  9. We will need to move the renamed store directory to the root. Let's right-click on the store directory and choose Move from the menu.

  10. Change the destination directory as /public_html/ and click on Move File(s) button.

What just happened?

OpenCart files are now on the web host in a subdirectory. Our online store will be reachable at http://yourwebsite.com/store after completion of all the remaining installation steps.

Tip

If you have completed uploading OpenCart files to a subdirectory using cPanel File Manager tool already, skip the following action and continue reading Setting File Permissions.

 

Time for action – uploading OpenCart using an FTP Client


This is the second method of uploading files to a webserver.

Note

If you have already used the first method (Uploading Files using cPanel) please skip this action and continue with Setting File Permissions.

In this section, we will learn how to decompress the OpenCart files in a local folder and upload to the root of web server using an FTP Client.

  1. Right-click on the previously downloaded OpenCart file on your computer and click Extract Here option.

    As a result, we will have a folder named opencart_v1.7 with the structured folders and files inside.

    Note

    Please note that folder name can be different depending on the OpenCart version we downloaded.

  2. We will create a directory named as store on the root of the website using the ftp Make Directory command.

  3. Upload all the files and the subfolders in opencart_v1.7/upload folder to the web host in the/store folder. We use a free FTP client software called CoreFTP, which can be downloaded at http://www.coreftp.com/. Choose all the files and folders in the directory from the left panel and drag and drop into the right panel where the web root folder exists. In most cases, it is /www folder. So, our destination is /www/store.

    The following screenshot shows the process before dragging and droping the files:

    And the screenshot after uploading the files to the folder named as store is as follows:

    Notice that it is a time consuming process since there are many files in OpenCart system. Let's wait until all the files are uploaded to the web server.

What just happened?

We have uploaded all OpenCart files and subfolders to the store directory on the website using an ftp client.

So, our online store will be reachable at http://yourwebsite.com/store after completion of all installation steps.

Pop quiz – Uploading OpenCart Files

Suppose that we have a very slow internet connection and want to install OpenCart on a web host without any possible interruptions on file transfer. Which upload method is more effective in terms of speed and reliability?

  1. Using an FTP Client program.

  2. Using cPanel File Transfer Utility.

 

Time for action – setting file permissions


OpenCart system uses its several directories dynamically to create, change, and delete the files when needed. Because of this, we have to be sure that the correct file permissions are applied on these files and folders.

Now, let's see how we will set the permissions using cPanel File Manager:

  1. We should be sure that the following directories and config files are writeable, meaning that their permissions are set to at least 755. We can check this by using cPanel file manager.

    • /store/image

    • /store/image/cache

    • /store/image/data

    • /store/system/cache

    • /store/system/logs

    • /store/download

    • /store/config.php

    • /store/admin/config.php

    Note

    Some hosting systems require 777 permissions for OpenCart to work properly. If the installation screens which we will soon learn give such unwritable errors, then we should set permissions to 777 and try going through with the installation screen again.

    The following screenshot shows that all these directories are set to 755 properly, but config.php file is not set to 755:

  2. So, let's open cPanel file manager and right-click on config.php file. Let's select Change Permissions:

  3. Set Permission level to 755. Click the Change Permissions button.

  4. We must repeat this process for all the folders listed below including the subfolders and files inside one by one if not set correctly to 755:

    • /store/image

    • /store/image/cache

    • /store/image/data

    • /store/system/cache

    • /store/system/logs

    • /store/download

    • /store/config.php

    • /store/admin/config.php

What just happened?

We have set the needed file and folder permissions to 755. It was needed for OpenCart to install and operate correctly. Depending on our hosting provider's linux settings, we might need 777 as well.

Note

Curious readers can learn more about server security on this http://www.unix.com/unix-dummies-questions-answers/33137-chmod-777-security-risks.html link.

 

Time for action – creating a MySQL database and user


This step is needed for OpenCart to connect and store all the data in a MySQL database. We will learn how to create a new database and user for this database. We will later use this information in OpenCart Installation wizard.

We will use MySQL Databases link on cPanel. Even though there can be slight differences on different cPanel versions, the main idea and the process is the same.

  1. Click on MySQL Databases link on cPanel:

  2. Enter a name for the database. Here, we named the database as opencart. Then, click on the Create Database button.

    If we are on a share hosting, a prefix will be added automatically to the name we provided. This is generally the username which we use to log in to the cPanel. So, your database name will follow the template of cPanelLogin_databasename.

    Take a note of the database name including the prefix.

  3. Now, let's create a user and assign this user to our newly created database. We go back from database creation result page and jump to MySQL Users section.

    Choose a username and password. Repeat the password on the last text box and be sure that the password is not very easy to guess for security preferably a mixture of letters and numbers.) We have chosen dbuser as the username. Click on the Create User button after filling all the required textboxes.

    Please note that a prefix will be added to the user as well. Take a note of the username.

  4. We need to add user to the database as the last step. Choose the newly created user and database for OpenCart, and then click the Add button.

  5. In this step, we are going to assign privileges for the user in the database. Select the All Privileges option, and then press the Make Changes button to give all the privileges to the user.

    Tip

    Providing all MySQL privileges to a user can be dangerous on a production site. Optionally, you can remove unnecessary permissions such as create, drop, and alter tables after installation is complete. Also note that some plugins which we can later install can require create, and alter permissions.

    Depending on our knowledge and experience on MySQL permissions, we are free to choose an advanced or simplified privileges management.

    The following screenshot shows the result page after clicking the Make Changes button:

What just happened?

We have seen how to prepare a database for OpenCart. The steps include:

  1. Choosing a name for the database.

  2. Choosing a username and providing a secure password.

  3. Adding user to the database.

  4. Adding privileges to user for the database.

Now we are ready to continue our installation by using OpenCart Installation Wizard.

 

Time for action – using OpenCart Installation Wizard


  1. Let's browse the domain name where we put OpenCart files. In our example, it is http://yourwebsite.com/store. You should use your own OpenCart path. We will be redirected to a License screen automatically. Click Continue to start.

  2. OpenCart will control several installation requirements, including PHP settings and extensions.

  3. Then, the permissions of several files and directories are checked. If there are no errors, all we have to do is click the Continue button.

    Tip

    If the system check finds any serious error, it will stop the installation temporarily and will not let us go further until we solve the problem. If it is the case, please check the requirements list section and file permission settings again carefully. If there is a need to make changes on the PHP settings and extension, please contact your hosting provider.

  4. In this step, we will supply the database connection information to OpenCart system. First, we should provide the previously created MySQL user and password for User and Password fields. Then, fill the MySQL database name in the Database Name field.

    Finally, we should choose a Username, Password, and Email to be used to log in and manage the OpenCart system.

    Let's ignore the Database Prefix option.

    Tip

    If we are allowed to create only one MySQL database for all applications being installed on hosting, it is a good idea to use Database Prefix option. It would put the shortened text in front of table names which will help us in differentiating tables in each application. oc would be a good prefix example. So, the tables would look like oc_tablename.

    "After filling in all the required fields, click on the Continue button.

  5. Even though the following screen has informed us that we have finished, we actually have not!

    For security purposes, we must delete the installation directory. Then, we should check the online storefront and administration screens to be sure that everything is working in the default settings.

  6. Let's open cPanel file manager again and browse to /store folder. Let's find install folder. We will right-click on it and choose Delete from the menu.

    Tip

    We could also use an Ftp client to delete, store, or install folder.

  7. The next step is to confirm the deletion of the install folder. Let's click on the Delete File(s) button.

  8. Let's browse to http://yourwebsite.com/store, the online shop storefront. We can see a pre-populated sample store that is similar to the following screenshot:

    Let's browse to the OpenCart administration screen at http://yourwebsite.com/store/admin and log in by using our admin username and password.

    We will see an administration screen similar to the following screenshot:

    Congratulations! Our OpenCart installation is now complete.

What just happened?

We have completed the installation using OpenCart wizard. The steps included the approval of license agreement, system checks (php settings, file permissions), providing database connection information, and deleting the install folder after completion of install. Finally, there are checking the storefront and administration screens.

We have now a sample running OpenCart system.

Have a go hero – Adding another OpenCart instance

Now, it is time for testing your skills on installing another instance of OpenCart at thehttp://yourwebsite.com/teststore folder. Later, will only be able to use this instance for testing purposes before applying some new things on the original store which we have together completed installing. Try to do the steps on your own without looking at the chapter sections at first. If difficulties occur, re-read the required chapter sections.

 

Summary


As you see, OpenCart installation is very straightforward. The most important thing is to be sure that your hosting environment runs on an Apache server with (Linux or Windows) and PHP 5.0+ and MySQL is supported. If we want to SEO-enable our system, let's be sure that mod_rewrite extension for Apache and permission to change .htaccess file is allowed.

In this chapter, we learned how to install OpenCart on a web server.

Specifically, we covered:

  • Requirements

  • Downloading and uploading files

  • Setting permissions

  • Creating MySQL database and user

  • Using Installation Wizard

  • Deleting install directory after the completion of installation

  • Checking storefront and administration screens

We are ready to explore OpenCart categories and products and their options on the next chapter.

About the Author

  • Murat Yilmaz

    Murat Yilmaz is a software developer and an online entrepreneur who lives in Antalya, Turkey. He has over 10 years of experience in different IT fields, including development of web-driven solutions, large databases, and OLAP systems. He has worked in several multinational companies in Istanbul and Moscow as a consultant. He currently runs his own blog and an e-commerce and online advertising network. He holds a bachelor's degree in Computer Science from Marmara University at Istanbul. He spends his free time playing progressive rock songs, online chess, and reading scientific books.

    He has also authored two other books, OpenCart 1.4: Beginner's Guide and OpenX Ad Server: Beginner's Guide.

    Browse publications by this author
Book Title
Access this book and the full library for FREE
Access now