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 Rcs 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 CentOS version.
cat /etc/centos-release
# CentOS Linux release 8.1.1911 (Core)Create a new non-root user account with sudo access and switch to it.
useradd -c "John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoeNOTE: Replace johndoe with your username.
Set up the timezone.
timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'Ensure that your system is up to date.
sudo yum updateInstall the needed packages.
sudo yum install -y socat gitDisable SELinux and Firewall.
sudo setenforce 0 ; sudo systemctl stop firewalld ; sudo systemctl disable firewalldInstall PHP
Install PHP, as well as the necessary PHP extensions.
sudo yum install -y php php-cli php-fpm php-common php-mbstring php-curl php-mysqlnd php-json php-xml php-phar php-pdo php-gdCheck the version.
php -v
# PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )Check installed PHP extensions.
php -m
# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .Start and enable PHP-FPM.
sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.serviceInstall MariaDB
Install MariaDB.
sudo yum install -y mariadb-serverCheck the version.
mysql --version
# mysql Ver 15.1 Distrib 10.3.17-MariaDB, for Linux (x86_64) using readline 5.1Start and enable MariaDB.
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.serviceRun the mysql_secure_installation script to improve the security of your MariaDB installation.
sudo mysql_secure_installationLog 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 yum install -y nginxCheck the version.
nginx -v
# nginx version: nginx/1.14.1Start and enable Nginx.
sudo systemctl start nginx.service
sudo systemctl enable nginx.serviceConfigure Nginx for use with the X-Cart.
sudo vim /etc/nginx/conf.d/xcart.confAnd 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-fpm/www.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}Test the configuration.
sudo nginx -tReload Nginx.
sudo systemctl reload nginx.serviceInstall 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.tgzChange ownership of the /var/www/xcart directory to nginx.
sudo chown -R nginx:nginx /var/www/xcartRun sudo vim /etc/php-fpm.d/www.conf and set the user and group to nginx. Initially, they will be set to apache.
sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginxCreate /var/lib/php/session/ directory and change ownership to nginx.
sudo mkdir -p /var/lib/php/session && sudo chown -R nginx:nginx /var/lib/php/sessionRestart the PHP-FPM service.
sudo systemctl restart php-fpm.serviceNavigate to example.com/install.php in your web browser and follow the instructions to finish the installation.