Install osCommece on Debian Linux

This tutorial will guide you on installing and configuring the osCommerce platform on Debian to create a free online shopping store.

osCommerce is a free open source, powerful and complex e-commerce online store-management platform written mostly in PHP programming language and often deployed in Linux under Apache/Nginx web servers, PHP, and MySQL/MariaDB database management system, also known as LAMP or LEMP stack.  osCommerce online e-commerce software platform is highly used to create online shops for different businesses and advertise and sell services and merchandise.


  • Debian 9 minimal installation on a bare-metal server machine or on a virtual private server
  • sudo root privileges for a local or remote account or direct access to root account
  • A static IP address configured for one of your system network interfaces cards
  • A domain name, private or public, depending on your deployment, with the proper DNS records configured for web services. If you don’t have a valid or a registered domain name you can perform the installation and access the website via your server IP address
  • If you want to use website registration, mail order confirmations and other features, you should have a running mail server properly configured at your premises with remote access to its IMAP and SMTP services.

Prepare the OS

Before starting to install and configure osCommerce from sources on your own server, first assure the system meets all the software requirements for compiling and installing the application.  On the first step, update your system repositories and software packages by issuing the following command.

apt update
apt upgrade

On the next step, execute the following command to install some necessary utilities that will be used to manage your system from the command line further.

apt install wget bash-completion zip unzip

After the system has been fully updated and the required utilities to manage your server have been installed, setup the name for your system by executing the following command (replace your hostname variable accordingly).

hostnamectl set-hostname oscommerce

Verify the machine hostname and hosts file by issuing the following commands.

cat /etc/hostname
hostname –s
hostname –f

Finally, reboot the Debian server to apply kernel updates and the hostname changes properly.

init 6

osCommerce is a web-based CMS e-commerce platform written in PHP server-side programming language. To execute the PHP file scripts of the application, a web server, such as an Apache HTTP server, and a PHP processing gateway must be installed and made operational in the system.  To install Apache web server and the PHP interpreter alongside all required PHP modules needed by the application to run properly, issue the following command in your server console.

apt install apache2 libapache2-mod-php7.0 php7.0 php7.0-curl php7.0-gd php7.0-opcache

After Apache and PHP has been installed, test if the web server is up and running and listening for network connections on port 80 by issuing the following command with root privileges.

netstat –tlpn

If netstat network utility is not installed by default in your Debian system, execute the following command to install it.

apt install net-tools

By inspecting the netstat command output you can see that apache web server is listening for incoming network connections on port 80. For the same task you can also use the ss command, which is automatically installed by default in Debian 9.

ss- tulpn

In case you have a firewall enabled in your system, such as UFW firewall application, you should add a new rule to allow HTTP traffic to pass through firewall by issuing the following command.

ufw allow WWW


ufw allow 80/tcp

If you’re using iptables raw rules to manage Firewall rules in your Debian server, add the following rule to allow port 80 inbound traffic on the firewall so that visitors can browse the online shop.

apt-get install -y iptables-persistent
iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT
systemctl iptables-persistent save
systemctl iptables-persistent reload

Next, enable and apply the following Apache modules the e-commerce application requires to run properly, by issuing the following command.

a2enmod rewrite
systemctl restart apache2

Finally, test if Apache web server default web page can be displayed in your clients browsers by visiting your Debian machine IP address or your domain name or server FQDN via HTTP protocol, as shown in the following image. If you don’t know your machine IP address, execute ifconfig or ‘ip a’ commands to reveal the IP address of your server.


In order to install and access osCommerce web admin panel backend and the frontend website via HTTPS protocol that will secure the traffic for your clients, issue the following command to enable Apache web server SSL module and SSL site configuration file.

a2enmod ssl
a2ensite default-ssl.conf

Next, open Apache default SSL site configuration file with a text editor and enable URL rewrite rules by adding the following lines of code after DocumentRoot directive, as shown in the following sample:

nano /etc/apache2/sites-enabled/default-ssl.conf

SSL site configuration file excerpt:

<Directory /var/www/html>
  Options +FollowSymlinks
  AllowOverride All
  Require all granted

Also, make the following change to VirtualHost line to look like shown in the below excerpt:

<VirtualHost *:443>

Close the SSL Apache file and open the /etc/apache2/sites-enabled/000-default.conf file for editing and add the same URL rewrite rules as for SSL configuration file. Insert the lines of code after DocumentRoot statement as shown in the following example.

<Directory /var/www/html>
  Options +FollowSymlinks
  AllowOverride All
  Require all granted

Finally, restart Apache daemon to apply all rules configured so far and visit your domain via HTTP protocol. Because you’re using the automatically Self-Signed certificates pairs issued by Apache at installation, an error warning should be displayed in the browser.

systemctl restart apache2


Accept the warning in order to continue and be redirected to Apache default web page, as illustrated in the following image.

In case the UFW firewall application blocks incoming network connections to HTTPS port, you should add a new rule to allow HTTPS traffic to pass through firewall by issuing the following command.

ufw allow ‘WWW Full’


ufw allow 443/tcp

If iptables is the default firewall application installed to protect your Debian system at network level, add the following rule to allow port 443 inbound traffic in the firewall so that visitors can browse your domain name.

iptables -I INPUT -p tcp --destination-port 443 -j ACCEPT
systemctl iptables-persistent save
systemctl iptables-persistent reload

On the next step, we need to make some further changes to PHP default configuration file in order to assure that the following PHP variables are enabled and the PHP timezone setting is correctly configured and matches your system’s geographical location.

Open the /etc/php/7.0/apache2/php.ini file for editing and assure that the following lines are setup as shown. Also, initially, make a backup of PHP configuration file.

cp /etc/php/7.0/apache2/php.ini{,.backup}
nano /etc/php/7.0/apache2/php.ini

Search, edit and change the following variables in the php.ini configuration file:

file_uploads = On
memory_limit = 128 M
upload_max_file_size = 64M
session.auto_start = 0
session.use_trans_sid = 0
date.timezone = Europe/London

Increase upload_max_file_size variable as suitable to support large file attachments and replace the variable accordingly to your physical time by consulting the list of time zones provided by PHP docs at the following link

If you want to increase the load speed of your website pages via OPCache plugin available for PHP7, append the following OPCache settings at the bottom of the PHP interpreter configuration file, as detailed below:


Close the php.ini configuration file and check if the verify the end of PHP configuration file to check if the variables had been correctly added by issuing the following command.

tail /etc/php/7.0/apache2/php.ini

After you’ve made all changes explained above, restart apache daemon to apply the new changes by issuing the following command.

systemctl restart apache2

Finally, create a PHP info file by executing the following command and check if the PHP time zone has been correctly configured by visiting the PHP info script file from a browser at the following URL, as illustrated in the following image.

Scroll down to date setting to check php time zone configuration.

echo '<?php phpinfo(); ?>'| tee /var/www/html/info.php


osCommerce web application stores different configurations, such as users, sessions, contacts, products, catalogs, and others, in an RDBMS database.  In this guide, we’ll configure the osCommerce shopping cart to use MariaDB database as the backend. Issue the following command to install the MariaDB database and the PHP module needed to access the MySQL database.

apt install mariadb-server php7.0-mysql mariadb-client

After you’ve installed MariaDB, verify if the daemon is running and listens for connections on localhost, port 3306, by running the netstat command.

netstat –tlpn | grep mysql

Then, log in to MySQL console and secure MariaDB root account by issuing the following commands.

mysql -h localhost
use mysql;
update user set plugin='' where user='root';
flush privileges;

On the next step, secure MariaDB by executing the script mysql_secure_installation provided by the installation packages from Debian stretch repositories. While running the script will ask a series of questions designed to secure MariaDB database, such as: to change MySQL root password, to remove anonymous users, to disable remote root logins and delete the test database.

Execute the script by issuing the below command and assure you type yes to all questions asked in order to fully secure MySQL daemon. Use the following script output excerpt as a guide.

sudo mysql_secure_installation



In order to log into MariaDB to secure it, we’ll need the current

password for the root user.  If you’ve just installed MariaDB, and

you haven’t set the root password yet, the password will be blank,

so you should just press enter here.


Enter current password for root (enter for none):

OK, successfully used password, moving on…


Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.


You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

… Success!


By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.


Remove anonymous users? [Y/n] y

… Success!


Normally, root should only be allowed to connect from ‘localhost’.  This

ensures that someone cannot guess at the root password from the network.


Disallow root login remotely? [Y/n] y

… Success!


By default, MariaDB comes with a database named ‘test’ that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.


Remove test database and access to it? [Y/n] y

– Dropping test database…

… Success!

– Removing privileges on test database…

… Success!


Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.


Reload privilege tables now? [Y/n] y

… Success!

Cleaning up…

All done!  If you’ve completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

In order to test MariaDB security, try login to the database from console with no root password. The access to the database should be denied if no password is provided for the root account. If the password is supplied, the login process should be granted to MySQL console.

mysql -h localhost -u root
mysql -h localhost -u root –p

Next, log in to the MariaDB database console, create a database for osCommerce application and a user with a password that will be used to manage the application database, by issuing the following commands (replace the database name, user and password accordingly).

mysql –u root -p
create database oscommerce;
grant all privileges on oscommerce.* to 'commerce_user' identified by 'password1234';
flush privileges;

In order to apply all changes made so far, restart MySQL and Apache daemons and verify if daemons are running by issuing the following commands.

systemctl restart mysql apache2
systemctl status mysql apache2

Install osCommerce 

After all system requirements are met for your e-commerce online shop installation, visit osCommerce official github page at and download the latest zip package compressed archive in your system by issuing the following command.


After the zip archive download finishes, extract osCommerce zip archive file named to your current working directory and list the extracted files by issuing the following commands. Plus, remove the default index.html file installed by Apache web server to webroot path and also delete the info.php file created earlier.

rm /var/www/html/index.html
rm /var/www/html/info.php

The installation files for osCommerce are located in your current working directory in oscommerce2- directory. Issue ls command to list oscommerce2- directory files. Copy all the content of the osCommerce catalog directory to your web server document root path by issuing the following command. Also, make sure you copy the hidden file .htaccess to webroot path.

cp -rf oscommerce2-* /var/www/html/
cp oscommerce2- /var/www/html/

Next, execute the following commands in order to grant Apache runtime user with full write permissions to the web root path. Use ls command to list permissions for application’s installed files located in the /var/www/html/ directory.

chown -R www-data:www-data /var/www/html/
ls –al /var/www/html/

Next, proceed osCommerce online shop installation process by opening a browser and navigate your server’s IP address or domain name or server FQDN via HTTPS protocol. On the first installation screen osCommerce installer will display a welcome messages and a series of PHP server capabilities tests will be performed against your system in order to determine if all requirements for installing the shopping application are met. If all server capabilities from the left plane are checked you’re good to go with the installation process. Hit on Start button to start the installation process, as illustrated in the following example.


In the next installation screen, supply MySQL database server address, the username and the password needed to access osCommerce database, and the database name created for osCommerce installation. After you write all required database information, hit on Continue button to move to the next installation screen. Use the following screenshot as a guide to configure this step.

After the database structure has been imported, add the web address that will be used for visiting your online store and the webroot directory where osCommerce files are located. Make sure to add your store WWW Address prefixed with HTTPS protocol in order to securely access the store frontend and backend and leave the webserver root directory to point to /var/www/html/ directory. To complete this step hit on the Continue button, as illustrated in the following image.

In the next installation screen, add the name of your store that will be presented to the public visitors, the name of the store owner and an email address of the store owner that will be made public to visitors. Next, add a store administrator account and a strong password for the admin account. For security reasons, make sure you change the name of the administration directory name to a secret random string. Also, make sure you write down the admin directory name because you will later need this string to navigate to store backend admin panel. Finally, select your time zone settings and hit the Continue button to finish the installation procedure.

After the installation process completes, the installer will display two links that can be used to access osCommerce backend Administration Tool panel, that will be used to manage your online shop, and Online Store frontend link, which is the URL that will be displayed to your clients.

In order to visit your online store frontend, click on the Online Store link and the frontend of your e-commerce application will be displayed in your browser as illustrated in the below screenshot. You can also visit the store frontend by navigating to your server IP address or domain name via the HTTPS protocol.


Before logging in to your store backed admin panel, first, return to server console and issue the following commands to delete the installation directory and secure osCommerce shopping system configuration files.

rm -rf /var/www/html/install/
chown root:root /var/www/html/includes/configure.php
chown root:root /var/www/html/adminaw45fs/includes/configure.php

To manage your osCommerce online store, click on the Administrator Tool link in order to access the store admin backend. Use the credentials configured during the installation process in order to log in to the osCommerce backend panel, as shown in the following screenshot.

You can also visit the osCommerce admin dashboard panel by navigating to your server IP address or domain name via HTTPS protocol to admin directory URL. Use the secret string configured for administration directory name when you’ve installed the application in order to access the admin panel, as shown in the following screenshot sample.


After logging in to osCommerce backed admin panel, a notification will appear in your screen and will inform you that you should find the extended security check under Tools -> Security Checks link.

Finally, to force visitors to browse osCommerce frontend website and to securely access the backend interface via HTTPS protocol in order to encrypt the traffic between the server and client browsers, return to your server’s terminal and edit the .htaccess file located in your website document root path, by issuing the below command.

nano /var/www/html/.htaccess

Then, edit the .htaccess file and at the bottom of the file you can change the native PHP server settings with the below configurations. Modify the PHP settings to match your own server resources and configurations.

.htaccess file excerpt:

# Modify PHP settings

php_value session.use_trans_sid 0
php_value register_globals 1

Finally, add the below rules in .htaccess file in order to automatically redirect domain traffic to HTTPS.

# Redirect to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

That’s all! You have successfully installed and configured osCommerce e-commerce application in Debian 9.2. However, because Apache HTTP server uses Self-Signed certificates to encrypt the traffic between the server and visitor’s browsers, a warning message will always be generated and displayed in their browsers. This warning is bad for your online shop business. In this case you should buy a certificate issued by a trusted Certificate Authority or get a free certificate pair from Let’s Encrypt CA.

For other custom configurations regarding osCommerce application, visit the documentation page at the following address:

Categorized as Linux