How to Install X-Cart 5 on Fedora 31
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 a Fedora 31 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 Fedora version.
cat /etc/fedora-release
# Fedora release 31 (Thirty One)
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 - johndoe
NOTE: 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 dnf update
Install the needed packages.
sudo dnf install -y socat git wget unzip
Disable SELinux and Firewall.
sudo setenforce 0 ; sudo systemctl stop firewalld ; sudo systemctl disable firewalld
Install PHP
Install PHP, as well as the necessary PHP extensions.
sudo dnf install -y php-cli php-fpm php-common php-mbstring php-curl php-mysqlnd php-json php-xml php-phar php-pdo php-gd
Check the version.
php --version
# PHP 7.3.15 (cli) (built: Feb 18 2020 09:25:23) ( NTS )
Start and enable PHP-FPM.
sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service
Install MariaDB
Install MariaDB.
sudo dnf install -y mariadb-server
Check the version.
mysql --version
# mysql Ver 15.1 Distrib 10.3.21-MariaDB, for Linux (x86_64) using readline 5.1
Start and enable MariaDB.
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
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 dnf install -y nginx
Check the version.
nginx -v
# nginx version: nginx/1.16.1
Start and enable Nginx.
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
Configure Nginx for use with the X-Cart.
sudo vim /etc/nginx/conf.d/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:/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 -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 nginx
.
sudo chown -R nginx:nginx /var/www/xcart
Run 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 = nginx
Navigate to example.com/install.php
in your web browser and follow the instructions to finish the installation.