How to install X-Cart ecommerce platform on Debian 10
How to install X-Cart ecommerce platform on Debian 10
X-Cart is a very flexible open source e-commerce platform with a lot of features and integration. X-Cart source code is hosted on Github. This guide describes the process of installing X-Cart 5 on Debian 10 using Nginx as a web server and MariaDB as a database server.
Claim
- PHP 7.2 or higher
- PHP extension:
pdo
,phar
,mysql
,mbstring
,curl
- MySQL 5.7.7 or higher or equivalent MariaDB
- Nginx
Initial steps
Check your Debian version:
lsb_release -ds
Set the time zone:
sudo dpkg-reconfigure tzdata
Update your operating system package (software). This is an important first step because it ensures that you have the latest updates and security fixes for the operating system’s default packages:
sudo apt update && sudo apt upgrade -y
Install some basic packages that are required for basic management of the Debian operating system:
sudo apt install -y curl wget vim git unzip socat bash-completion
Step 1-install PHP and PHP extensions
Install PHP and 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
To display PHP compiled in the module, you can run:
php -mctypecurlexiffileinfo. . .. . .
Check PHP version:
php --version# PHP 7.3.17-0debian0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )# Copyright (c) 1997-2018 The PHP Group# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies# with Zend OPcache v7.2.17-0debian0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
The PHP-FPM service starts automatically on Debian 10 systems and is enabled upon restart, so there is no need to manually start and enable it. We can move on to the next step, which is database installation and setup.
Step 2-install MariaDB and create database
Install MySQL:
sudo apt install -y mariadb-server
Check version:
mysql --version# mysql Ver 14.14 Distrib 5.7.27, for Linux (x86_64) using EditLine wrapper
Run by mysql_secure_installation
Script to increase the security of your MariaDB installation:
sudo mysql_secure_installation
Log in to 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;
Step 3-Install acme.sh client and obtain Let’s Encrypt certificate (optional)
You do not need to use HTTPS to protect your website, but it is a good habit to protect your website traffic. In order to obtain a TLS certificate from Let’s Encrypt, we will use the acme.sh client. Acme.sh is a pure UNIX Shell software for obtaining TLS certificates from Let’s Encrypt with zero dependencies.
Download and install acme.sh:
sudo su - rootgit clone https://github.com/Neilpang/acme.sh.gitcd acme.sh ./acme.sh --install --accountemail [email protected]source ~/.bashrccd ~
Check the acme.sh version:
acme.sh --version# v2.8.6
Get RSA with ECC / ECDSA Your domain / hostname certificate:
# RSA 2048acme.sh --issue --standalone -d example.com --keylength 2048# ECDSAacme.sh --issue --standalone -d example.com --keylength ec-256
If you want to test with a fake certificate, you can add --staging
Mark the above command.
After running the above command, your certificate and key will be located at:
- For RSA:
/home/username/example.com
table of Contents. - For ECC / ECDSA:
/home/username/example.com_ecc
table of Contents.
To list the certificates you issued, you can run:
acme.sh --list
Create a directory to store your certificates. We will use /etc/letsencrypt
table of Contents.
mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc
Install / copy the certificate into the / etc / letsencrypt directory.
# RSAacme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"# ECC/ECDSAacme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
All certificates will be automatically renewed every 60 days.
After obtaining the certificate, log out as root and return to the normal sudo user:
exit
Step 4-install and configure Nginx
Install Nginx:
sudo apt install -y nginx
Check Nginx version:
sudo nginx -v# nginx version: nginx/1.14.0
Configure Nginx for X-Cart by running the following command:
sudo vim /etc/nginx/sites-available/xcart.conf
And populate the file with the following configuration.
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 new xcart.conf
By linking the file to sites-enabled
table of Contents:
sudo ln -s /etc/nginx/sites-available/xcart.conf /etc/nginx/sites-enabled
Test configuration:
sudo nginx -t
Reload Nginx:
sudo systemctl reload nginx
Step 5-install X-Cart
Navigate to /var/www
table of Contents:
cd /var/www/
Download the latest version of X-Cart from https://www.x-cart.com/download.html And unzip it to your document root:
After downloading, change /var/www/xcart
Directory to www-data:
sudo chown -R www-data:www-data /var/www/xcart
Navigation example.com/install.php
In your web browser, then follow the instructions to complete the installation.
Step 6-complete the setup
Accept the license agreement and click next.
Create an administrator account.
The installation wizard will check if your server meets the system requirements for X-Cart 5
Configure database settings:
Set directory + step 6. Build cache. All tasks in these steps are fully automated, so you just have to wait and let X-Cart 5 do the work
At this point, the installation process is complete. You can use the provided link to access the Customer Front End and Management areas of the store.