How to Install X-Cart 5 on Ubuntu 18.04 LTS
X-Cart is an extremely flexible open-source eCommerce platform with tons of features and integrations. This guide describes the process of installing X-Cart 5 on an Ubuntu 18.04 LTS Vultr instance, using Nginx as the web server and MySQL 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 Ubuntu version.
lsb_release -ds
# Ubuntu 18.04.4 LTS
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 php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-curl php7.2-mysql php7.2-json php7.2-xml php7.2-phar php7.2-pdo php7.2-gd
Check the version.
php -v
# PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( NTS )
Check installed PHP extensions.
php -m
# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .
Install MySQL
Install MySQL.
sudo apt install -y mysql-server
Check the version.
mysql --version
# mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using EditLine wrapper
Run the mysql_secure_installation
script to improve the security of your MySQL installation.
sudo mysql_secure_installation
Log into MySQL as the root user.
sudo mysql -u root -p
# Enter password:
Create a new MySQL 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.0 (Ubuntu)
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.2-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.