This guide walks you through installing Zen Cart on a Virtual Private Server (VPS) with either Apache or Nginx as the web server, a MySQL/MariaDB database, and essential security hardening. By the end, you’ll have a functional online store ready for configuration.
What You’ll Need
- A VPS running a Linux distribution (Ubuntu 22.04/24.04, Debian 11/12, or CentOS/Rocky Linux 9) with root or sudo access.
- A domain name pointed to your server’s IP address (optional but recommended for production).
- SSH client (e.g., PuTTY on Windows, Terminal on macOS/Linux).
- Basic familiarity with the command line.
Step-by-Step
- Update the server
Log in via SSH and update the package lists and existing packages:sudo apt update && sudo apt upgrade -y(Debian/Ubuntu) orsudo dnf update -y(RHEL/Rocky). - Install a web server
Choose one:
Apache:sudo apt install apache2 -y
Nginx:sudo apt install nginx -y
Enable the service to start on boot:sudo systemctl enable apache2orsudo systemctl enable nginx. - Install PHP and required extensions
Zen Cart requires PHP 7.4 or newer (8.0+ recommended). Install PHP along with common extensions:sudo apt install php php-cli php-fpm php-mysql php-gd php-curl php-zip php-xml php-mbstring php-intl php-bcmath -y
For Apache, also installlibapache2-mod-php. - Install MySQL/MariaDB
sudo apt install mariadb-server -y
Secure the installation:sudo mysql_secure_installation– set a root password, remove anonymous users, disallow remote root login, and remove test databases. - Create a database and user
Log into MySQL:sudo mysql
Run:CREATE DATABASE zencart;CREATE USER 'zencartuser'@'localhost' IDENTIFIED BY 'StrongPasswordHere';GRANT ALL PRIVILEGES ON zencart.* TO 'zencartuser'@'localhost';FLUSH PRIVILEGES;EXIT; - Download Zen Cart
Navigate to your web root (e.g.,/var/www/htmlfor Apache,/usr/share/nginx/htmlfor Nginx, or better a dedicated directory like/var/www/zencart).
Download the latest release from the official Zen Cart GitHub repository:cd /var/wwwsudo git clone https://github.com/zencart/zencart.git zencart
Or download a stable ZIP from the official site and extract it. - Set permissions
Zen Cart needs write access to certain directories. Set ownership to the web server user (www-data for Apache, nginx for Nginx) and set permissions:sudo chown -R www-data:www-data /var/www/zencartsudo chmod -R 755 /var/www/zencart
Make thecacheandlogsdirectories writable:sudo chmod -R 777 /var/www/zencart/cache /var/www/zencart/logs(temporary, tighten later). - Configure the web server
Apache: Create a virtual host file/etc/apache2/sites-available/zencart.confwith a DocumentRoot pointing to/var/www/zencart. Enable mod_rewrite and the site:sudo a2enmod rewritesudo a2ensite zencartsudo systemctl reload apache2
Nginx: Create a server block in/etc/nginx/sites-available/zencartwith root/var/www/zencart, indexindex.php, and a location block for PHP-FPM (socket or TCP). Enable it and reload Nginx:sudo ln -s /etc/nginx/sites-available/zencart /etc/nginx/sites-enabled/sudo systemctl reload nginx - Run the installer
Open your browser and go tohttp://your-domain.com/zc_install(or the appropriate path). Follow the on-screen steps: accept license, check server requirements, enter database details (host: localhost, user: zencartuser, password: your password, database: zencart), and set admin credentials. Complete the installation. - Secure the installation
After installation, delete thezc_installdirectory:sudo rm -rf /var/www/zencart/zc_install. Also remove or rename thedocsdirectory if present. - Enable HTTPS (SSL/TLS)
Install Certbot:sudo apt install certbot python3-certbot-apache(or-nginx)
Obtain a free certificate:sudo certbot --apacheorsudo certbot --nginx– follow the prompts. This automatically configures HTTPS and auto-renewal. - Additional security hardening
Set strict file permissions:sudo chmod 644 /var/www/zencart/*.phpandsudo chmod 755 /var/www/zencartfor directories. Ensure thecacheandlogsdirectories are not writable by the web server after installation (change to 755). Configure a firewall (UFW) to allow only SSH, HTTP, and HTTPS:sudo ufw allow 22,80,443/tcpthensudo ufw enable.
Common Mistakes
- Using the wrong PHP version – Zen Cart may not work on PHP 8.3+ if extensions are missing.
- Forgetting to enable the
mod_rewritemodule in Apache, causing 404 errors on product pages. - Not setting correct file ownership – the web server user must own the files, not root.
- Leaving the
zc_installdirectory accessible – a serious security risk. - Using a weak database password.
Tips
- Use a dedicated subdomain like
store.yourdomain.comfor easier management. - Set up a regular backup cron job for the database and files.
- Enable OPcache in PHP for better performance.
- Use a strong admin password and change it periodically.
- Keep Zen Cart and PHP updated regularly.
Troubleshooting
Blank page after installation – Check PHP error logs (/var/log/apache2/error.log or /var/log/nginx/error.log). Often a missing PHP extension or a permissions issue.
404 errors on product pages – For Apache, ensure mod_rewrite is enabled and the .htaccess file exists in the Zen Cart root. For Nginx, you need to add a rewrite rule to the server block: location / { try_files $uri $uri/ /index.php?$args; }
Cannot connect to database – Verify the database host is localhost and the user has privileges. Test with mysql -u zencartuser -p.
HTTPS not working – Check that your firewall allows port 443 and that the SSL certificate is valid. Run sudo certbot certificates to see status.
Admin login redirects to HTTP – Update the configure.php files in /includes and /admin/includes to use HTTPS URLs.
Frequently Asked Questions
Can I use SQLite instead of MySQL?
No, Zen Cart requires MySQL or MariaDB. SQLite is not supported.
What PHP version is best for Zen Cart?
PHP 8.0 to 8.2 is recommended. PHP 8.3 may work but test thoroughly.
How do I change the admin directory name?
Rename the admin folder to something unique (e.g., admin_secret) and update the DIR_WS_ADMIN constant in admin/includes/configure.php.
Is it safe to use the default ‘admin’ username?
No, create a unique admin username during installation to reduce brute-force risk.
How do I back up my store?
Use mysqldump for the database and tar for files. Example: mysqldump -u root -p zencart > backup.sql and tar -czf zencart_files.tar.gz /var/www/zencart.
Why is my site slow?
Enable caching in Zen Cart (Admin > Configuration > Cache), enable OPcache, and consider using a CDN for static assets.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Turn Off Backup Encryption in iTunes?
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It