Article

Table of Contents
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

How to Install X-Cart 5 on Debian 10

Last Updated: Wed, Mar 4, 2020
Business Debian MySQL and MariaDB PHP Server Apps Web Servers

X-Cart is an extremely flexible open-source eCommerce platform with tons of features and integrations. X-Cart source code is hosted on Github. This guide describes the process of installing X-Cart 5 on a Debian 10 (buster) Vultr instance, using Nginx as the web server and MariaDB as the database server.

Requirements

  • PHP version 7.2 or higher
  • PHP extensions: pdo, phar, mysql, mbstring, curl
  • MySQL version 5.7.7 or higher or MariaDB equivalent
  • Nginx

Before you begin

Check the Debian version.

lsb_release -ds
# Debian GNU/Linux 10 (buster)

Create a new non-root user account with sudo access and switch to it.

adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

sudo dpkg-reconfigure tzdata

Ensure that your system is up to date.

sudo apt update && sudo apt upgrade -y

Install the needed packages.

sudo apt install -y zip unzip curl wget git

Install PHP

Install PHP, as well as the necessary PHP extensions.

sudo apt install -y php php-cli php-fpm php-common php-mbstring php-curl php-mysql php-json php-xml php-phar php-pdo php-gd

Check the version.

php -v
# PHP 7.3.14-1~deb10u1 (cli) (built: Feb 16 2020 15:07:23) ( NTS )

Check installed PHP extensions.

php -m

# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .

Install MariaDB

Install MariaDB.

sudo apt install -y mariadb-server

Check the version.

mysql --version
# mysql  Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Run the mysql_secure_installation script to improve the security of your MariaDB installation.

sudo mysql_secure_installation

Log into MariaDB as the root user.

sudo mysql -u root -p
# Enter password:

Create a new MariaDB database and user and remember the credentials.

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

Install Nginx

Install Nginx.

sudo apt install -y nginx

Check the version.

sudo nginx -v
# nginx version: nginx/1.14.2

Configure Nginx for use with the X-Cart.

sudo vim /etc/nginx/sites-available/xcart.conf

And populate the file with the below config.

server {
  listen 80;
  listen [::]:80;
  root /var/www/xcart;
  index index.php index.html index.htm;
  server_name example.com;
  location @handler {
    index cart.php;
    rewrite ^/sitemap.xml(\?.+)?$ /cart.php?target=sitemap;
    rewrite ^/(.*)$ /cart.php?url=$1 last;
  }
  location / {
    try_files $uri $uri/ @handler;
  }
  location ~ \.php$ {
    try_files     $uri @handler;
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    include fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Activate the new xcart.conf configuration by linking the file to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/xcart.conf /etc/nginx/sites-enabled

Test the configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install X-Cart

Navigate to the /var/www directory.

cd /var/www/

Download the most recent release of X-Cart to your local workstation from https://www.x-cart.com/download.html.

Upload the X-Cart package to your server using SFTP. See our SFTP instructions here. Place the file in your /var/www/ directory. In this example, the filename is x-cart-5.4.0.10-en.tgz, yours may be different.

Extract the X-Cart package.

sudo tar -xzpf x-cart-5.4.0.10-en.tgz
sudo rm x-cart-5.4.0.10-en.tgz

Change ownership of the /var/www/xcart directory to www-data.

sudo chown -R www-data:www-data /var/www/xcart

Navigate to example.com/install.php in your web browser and follow the instructions to finish the installation.

Want to contribute?

You could earn up to $300 by adding new articles