How to Install osCommerce with Apache on Ubuntu Linux

graphic designer 4562741 640
graphic designer 4562741 640

osCommerce is a free eCommerce software that allows you to set up your own complete and self-hosted online stores to sell your products and services.

This brief tutorial is going to show students and new users an easy way to get osCommerce working on Ubuntu 17.04 | 17.10

osCommerce is PHP based application that also requires web and database servers. The LAMP stack is a requirement for osCommerce. LAMP is an acronym for Linux, Apache2, MySQL, and PHP. Many reputable online stores and brick-and-mortar establishments use this software to run their businesses.

This post covers installing the latest version of osCommerce, which at the time of writing was version

To get started with installing osCommerce, follow the steps below:

Install Apache2

osCommerce requires a webserver to function, and the most popular web server in use today is Apache2. So, go and install Apache2 on Ubuntu by running the commands below:

sudo apt-get install apache2

After installing Apache2, run the commands below to turn off the directory listing.

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

Next, run the commands below to stop, start and enable the Apache2 service to always start up with the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

Install MariaDB

osCommerce also requires a database server to function. And MariaDB database server is a great place to start. To install it, run the commands below.

sudo apt-get install mariadb-server mariadb-client

After installing, the commands below can be used to stop, start and enable the MariaDB service to always start up when the server boots.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure the MariaDB server.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter the password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove the test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Restart MariaDB server

sudo systemctl restart mariadb.service

Install PHP and Related Modules

osCommerce also requires PHP to function. To install PHP and related modules run the commands below

sudo apt-get install php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-mcrypt php-ldap php-zip php-curl

Create osCommerce Database

Once you’ve installed all required packages, create the osCommerce Database below.

Run the commands below to log on to the MariaDB server. When prompted for a password, type the root password you created above.

sudo mysql -u root -p

Then create a database called oscdb


Create a database user called oscuser with a new password

CREATE USER 'oscuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then grant the user full access to the Database.

GRANT ALL ON oscdb.* TO 'oscuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.


Download osCommerce Latest Release

Next, visit the osCommerce site to download the latest version

After downloading, run the commands below to extract the download file into the Apache2 root directory.

sudo mv oscommerce- /var/www/html/oscommerce

Change or modify the directory permission to fit the Apache2 configuration.

sudo chown -R www-data:www-data /var/www/html/oscommerce
sudo chmod -R 755 /var/www/html/oscommerce

Configure Apache2

Finally, configure the Apahce2 site configuration file for osCommerce. This file will control how users access osCommerce content. Run the commands below to create a new configuration file called oscommerce.conf.

sudo nano /etc/apache2/sites-available/oscommerce.conf

Then copy and paste the content below into the file and save it. Replace the highlighted line with your domain name and directory root location.

<VirtualHost *:80>
     DocumentRoot /var/www/html/oscommerce/

     <Directory /var/www/html/oscommerce/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

Save the file and exit.

Enable the osCommerce and Rewrite Module

After configuring the VirtualHost above, please enable it by running the commands below.

sudo a2ensite oscommerce.conf
sudo a2enmod rewrite

Restart Apache2 by running the commands below to load all the settings above.

sudo systemctl restart apache2.service

Then open your browser and browse to the server domain name. Next, you should see the osCommerce setup wizard to complete. Please follow the wizard carefully.


oscommerce ubuntu install

Begin the installation. You will be prompted for the database server info. Type it as shown below.

oscommerce ubuntu install

Next, enter the store name and admin username, and password, and continue

oscommerce ubuntu

Complete the installation.

oscommerce ubuntu setup


Post-Installation steps:

It is recommended to follow the following post-installation steps to secure your osCommerce Online Merchant online store:

First, delete the /var/www/html/oscommerce/catalog/install directory.

Next, rename the Administration Tool directory at /var/www/html/oscommerce/catalog/admin.

Set the permissions on /var/www/html/oscommerce/catalog/includes/configure.php to 644 (or 444 if this file is still writable).

Next, set the permissions on /var/www/html/oscommerce/catalog/admin/includes/configure.php to 644 (or 444 if this file is still writable).

Finally, review the directory permissions on the Administration Tool -> Tools -> Security Directory Permissions page.

The Administration Tool should be further protected using htaccess/htpasswd and can be set up within the Configuration -> Administrators page.

Run the commands below.

sudo rm -rf /var/www/html/oscommerce/catalog/install
sudo chmod 644 /var/www/html/oscommerce/catalog/includes/configure.php
sudo chmod 644 /var/www/html/oscommerce/catalog/admin/includes/configure.php

That’s it!

Posted by

I love computers; maybe way too much. What I learned I try to share at

1 Comment

  1. For step 5, i cannot open the zip file.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: