How to Install LiteCart on Ubuntu 26.04 LTS with Apache and MariaDB
Install LiteCart 2.7 on Ubuntu 26.04 LTS with Apache, MariaDB and PHP, run the web installer and lock the shop down afterwards.
LiteCart is a free, open source shopping cart written in PHP. This guide installs LiteCart 2.7 on Ubuntu 26.04 LTS with Apache, MariaDB and PHP, and finishes with a working storefront and admin panel on your own domain. The same commands work on Ubuntu 24.04 LTS; only the PHP and MariaDB versions the distribution installs differ (PHP 8.3 and MariaDB 10.11 instead of PHP 8.5 and MariaDB 11.8).
LiteCart's installer lists PHP 5.6 to 8.6, Apache 2 (or LiteSpeed) and MySQL 5.7+ or MariaDB 10.8+ as its requirements, so the stock packages of both Ubuntu releases are suitable.
Requirements
- A server running Ubuntu 26.04 LTS or 24.04 LTS.
- A user with
sudorights (the examples usedeploy). - A domain name such as
example.comwith an A record pointing to the server.
Update the package index and installed packages:
sudo apt update
sudo apt upgrade -yInstall Apache, MariaDB and PHP
Install the web server, the database and the PHP extensions the LiteCart installer checks for (dom, gd, intl, mbstring, mysqli, simplexml, zip; apcu is optional but speeds up caching):
sudo apt install -y apache2 mariadb-server libapache2-mod-php \
php-mysql php-gd php-intl php-mbstring php-xml php-zip php-apcu unzipLiteCart uses mod_rewrite for its URLs and mod_headers for cache headers. Enable both:
sudo a2enmod rewrite headersCreate the database
Run the hardening script and accept its suggestions (remove anonymous users, remove the test database, disallow remote root login):
sudo mariadb-secure-installationOpen the MariaDB shell:
sudo mariadbCreate a database and a dedicated user. Replace the password with your own:
CREATE DATABASE litecart CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'litecart'@'localhost' IDENTIFIED BY 'change-this-password';
GRANT ALL PRIVILEGES ON litecart.* TO 'litecart'@'localhost';
EXIT;Download LiteCart
Releases are published on litecart.net and tagged in the project's GitHub repository. At the time of writing the current release is 2.7.2; check the download page and adjust the version number if a newer one exists.
cd /tmp
wget https://github.com/litecart/litecart/archive/refs/tags/2.7.2.zip
unzip 2.7.2.zipOnly the contents of the archive's public_html directory belong in the web root. Copy them to a directory for the site and hand ownership to the web server user, because the installer writes its configuration file, .htaccess, and the cache, data and image directories:
sudo mkdir -p /var/www/litecart
sudo cp -a /tmp/litecart-2.7.2/public_html/. /var/www/litecart/
sudo chown -R www-data:www-data /var/www/litecartConfigure Apache
Create /etc/apache2/sites-available/litecart.conf:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/litecart
<Directory /var/www/litecart>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/litecart_error.log
CustomLog ${APACHE_LOG_DIR}/litecart_access.log combined
</VirtualHost>AllowOverride All is required: the installer generates an .htaccess file with the rewrite rules and with rules that block direct access to configuration files.
Enable the site, disable the default one, test the configuration and restart Apache:
sudo a2ensite litecart.conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl restart apache2If UFW is active, allow web traffic:
sudo ufw allow "Apache Full"A shop handles customer data and logins, so add a TLS certificate before you run the installer. With Let's Encrypt:
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d example.comRun the installer
Browse to https://example.com/install/. The page first shows the system requirements and write-permission checks; everything should be marked OK. Then fill in the form:
- Database: hostname
localhost, databaselitecart, userlitecartand its password. Leave the collation atutf8mb4_general_ciand keep the table prefix unless you share the database. - Store information: store name, store email, country and time zone.
- Backend: the name of the admin folder and the administrator user name and password. Choosing a folder name other than
adminkeeps automated login attempts away from the default URL. - Accept the terms and click Install Now.
The same installer can be run from the shell; php /var/www/litecart/install/install.php --help lists its options.
Secure the installation
When the installer reports success, delete the install directory. Leaving it in place lets anyone start an upgrade or reinstall:
sudo rm -rf /var/www/litecart/installThe configuration file contains the database password. Make it read-only for the web server:
sudo chmod 440 /var/www/litecart/includes/config.inc.phpLog in to the backend at https://example.com/admin/ (or the folder name you chose) and open the storefront at https://example.com/ to confirm both work.
Maintenance
- Backups: dump the database with
sudo mariadb-dump litecart > litecart.sqland copy/var/www/litecart, which holds product images, add-ons and the configuration. - Upgrades: back up first, copy the new release's
public_htmlfiles over the existing ones, then open/install/upgrade.phpin the browser and delete theinstalldirectory again when it finishes. - Add-ons: LiteCart applies modifications through its vMod system and stores them in the
vmodsdirectory, which must stay writable bywww-data.
Frequently asked questions
Can LiteCart run on Nginx?
The installer names Apache 2 and LiteSpeed as supported servers, and LiteCart relies on the .htaccess file it generates for both URL rewriting and for blocking access to internal files. On Nginx you would have to reproduce those rules by hand, so Apache is the safer choice.
The requirements page warns about my PHP version. Is that a problem?
The installer compares your PHP build with the patch releases that fixed known PHP vulnerabilities and shows a warning for older builds. Ubuntu backports security fixes without changing the version number, so keep the system updated with sudo apt upgrade; the warning does not block the installation.
Product pages return 404 but the home page works. Why?
URL rewriting is not active. Check that mod_rewrite is enabled, that the virtual host has AllowOverride All, and that /var/www/litecart/.htaccess exists. Restart Apache after changing any of these.