How To Install PrestaShop on Rocky Linux 9
PrestaShop is a highly popular open-source e-commerce solution for creating online stores with ease. Featuring a robust set of built-in modules, a user-friendly interface, and a wide range of customization options, it stands out as an excellent choice for businesses of any size. In this guide, you’ll learn how to install and configure PrestaShop on Rocky Linux 9, ensuring a smooth and secure foundation for your e-commerce platform.
When setting up a new e-commerce store, stability, speed, and compatibility become key factors in choosing an operating system. With Rocky Linux 9—a Linux distribution derived from the source code of Red Hat Enterprise Linux—you can enjoy enterprise-grade stability combined with regular security updates. This ensures maximum uptime, reliability, and support for the tools crucial in hosting a successful online business.
Below is a detailed, step-by-step walkthrough on installing PrestaShop, starting with essential system requirements all the way to performance optimization. Whether you’re an experienced Linux administrator or a newcomer, following these instructions will help you deploy a secure and efficient PrestaShop store on your Rocky Linux 9 server.
System Requirements
Before proceeding with the installation steps, it’s essential to confirm that your server meets both hardware and software prerequisites required by PrestaShop. Adequate resources and compatible software stacks prevent potential bottlenecks and runtime errors.
Hardware Requirements
- Memory (RAM): At minimum, 1.5GB of RAM is required to install and run PrestaShop. However, for a smooth user experience, especially in production environments with higher traffic, consider 2GB or more.
- Storage: You should have at least 5GB of free disk space for the core software and future updates. If you plan on hosting extensive product images or large media files, allocate additional space accordingly.
- Processor: A modern multi-core processor (Intel or AMD) ensures quick response times. While a single core can technically run PrestaShop, expect faster performance with dual-core or more.
Software Prerequisites
- Operating System: Rocky Linux 9 (64-bit) is recommended for enterprise-level stability and security.
- Web Server: Apache 2.4+ is the most common choice. Nginx can also be used, but this guide will focus on Apache.
- Database: PrestaShop supports both MariaDB and MySQL. Versions should be at least MariaDB 10.2+ or MySQL 5.7+.
- PHP: PHP version 8.1 or higher is recommended for optimal performance and security. You will also need common PHP extensions such as pdo, mysqli, gd, curl, zip, intl, and mbstring.
Ensuring these requirements are met lays a firm groundwork for a stable PrestaShop experience. Skimping on resources could hinder performance, so always allocate sufficient RAM and CPU cycles. By checking feasibility in advance, you’ll avoid unexpected complications during installation and operation.
Preparation Steps
Before you start downloading and configuring PrestaShop, there are a few essential steps for preparing your Rocky Linux 9 system. Proper preparation maximizes efficiency and reduces the risk of incomplete dependencies or version mismatches.
System Updates
The first step is to ensure your operating system is fully up to date. Outdated software can introduce security risks and cause installation conflicts. Run the following commands:
sudo dnf update -y
sudo dnf upgrade -y
Once the update is complete, reboot if necessary:
sudo reboot
This ensures that your server has the latest security patches and bug fixes before proceeding.
Repository Configuration
Rocky Linux 9 comes with the default dnf repositories. However, to install specific PHP extensions or packages, you might need extra repositories like the Remi repository or EPEL (Extra Packages for Enterprise Linux).
sudo dnf install epel-release -y
sudo dnf install dnf-plugins-core -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Enable the required Remi repository for PHP 8.1:
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.2 -y
With these preparations complete, you should have access to the necessary packages for your LAMP stack and PrestaShop.
Optional Firewall Configuration
Before moving on to the actual LAMP stack installation, consider configuring your firewall. Confirm that ports 80 (HTTP) and 443 (HTTPS) are open to allow web traffic:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
With your system updated and configured, it’s time to proceed with setting up the LAMP stack, which forms the backbone of most PrestaShop deployments.
LAMP Stack Installation
A core requirement for PrestaShop is a functioning LAMP (Linux, Apache, MySQL/MariaDB, and PHP) stack. Rocky Linux 9 includes many of the necessary components, but you’ll need to install and configure them properly.
Apache Web Server
To install the Apache web server, use:
sudo dnf install httpd -y
Enable and start the Apache service:
sudo systemctl enable httpd
sudo systemctl start httpd
Verify that Apache is running correctly:
systemctl status httpd
You should see an active (running) status in the output. If everything looks good, you can move on to the next step.
MariaDB/MySQL Installation
Next, install the database server. PrestaShop supports both MariaDB and MySQL, but MariaDB is often preferred due to its open-source nature and compatibility. Install MariaDB:
sudo dnf install mariadb-server -y
Enable and start the MariaDB service:
sudo systemctl enable mariadb
sudo systemctl start mariadb
Run the security script to set a root password and remove vulnerabilities:
sudo mysql_secure_installation
Follow the on-screen prompts to configure the root password and other recommended security settings.
Installing PHP 8.1 and Extensions
With the Remi repository enabled, installing PHP 8.1 is straightforward:
sudo dnf install php php-cli php-common php-opcache \
php-mysqlnd php-gd php-mbstring php-zip php-xml \
php-curl php-intl -y
This command fetches all essential extensions required by PrestaShop. Once installed, verify your PHP version:
php -v
You should see PHP 8.2 in the output. At this point, your LAMP stack is set up. Next, you can create a dedicated database for PrestaShop and configure Apache for serving the PrestaShop application.
PrestaShop Installation Process
With the LAMP stack in place, you can now install and configure PrestaShop. The first step is to prepare a database and user, followed by configuring an Apache virtual host to serve your PrestaShop site.
Database Configuration
Login to MariaDB/MySQL:
sudo mysql -u root -p
Create a new database for PrestaShop, for example named prestashopdb
:
CREATE DATABASE prestashopdb;
Next, create a database user and grant privileges. Replace dbuser
and password
with your preferred username and a strong password:
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON prestashopdb.* TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
This ensures that PrestaShop will have the required permissions to manage its data.
Web Server Configuration
For a clean setup, create a Virtual Host for your PrestaShop site. Assume you want to host it at /var/www/html/prestashop
. Create and edit the configuration file:
sudo nano /etc/httpd/conf.d/prestashop.conf
Insert the following content (modify ServerName and ServerAlias as applicable):
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/html/prestashop
<Directory /var/www/html/prestashop>
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/prestashop_error.log
CustomLog /var/log/httpd/prestashop_access.log combined
</VirtualHost>
Save and close the file (Ctrl + O, then Ctrl + X if you are using nano). Once done, test your Apache configuration:
sudo apachectl configtest
If the syntax is OK, reload Apache:
sudo systemctl restart httpd
SSL Certificate (Optional but Recommended)
To secure customer data and build trust, install an SSL certificate. Consider using a free Let’s Encrypt certificate:
sudo dnf install certbot python3-certbot-apache -y
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
Certbot will guide you through the process. Enforce HTTPS for improved security.
Directory Permissions
Ensure that the Apache user (apache or www-data, depending on your setup) has permission to read and write to the /var/www/html/prestashop
folder:
sudo chown -R apache:apache /var/www/html/prestashop
sudo chmod -R 755 /var/www/html/prestashop
Having corrected permissions prepares the environment for successfully running the PrestaShop installation scripts.
PrestaShop Setup
With the virtual host and database ready, it’s time to complete the PrestaShop setup. In this section, you’ll download the latest available PrestaShop files, upload them to your server, set configurations, and proceed with the installation wizard.
Downloading PrestaShop
Visit the official PrestaShop website to find the latest stable release. Copy the download link for the .zip file. On your Rocky Linux 9 server, navigate to the web directory:
cd /var/www/html
sudo wget https://download.prestashop.com/prestashop_1.7.8.X.zip -O prestashop.zip
(Replace 1.7.8.X with the latest version number.)
Once downloaded, unzip the contents:
sudo dnf install unzip -y
sudo unzip prestashop.zip -d prestashop
The zip command extracts the files into the /var/www/html/prestashop
directory. Update ownership and permissions again if needed:
sudo chown -R apache:apache /var/www/html/prestashop
sudo chmod -R 755 /var/www/html/prestashop
Launching the Installation Wizard
Open your browser and visit http://yourdomain.com
(or the server IP address) if you haven’t configured DNS. You should see PrestaShop’s graphical installation wizard:
- Language Selection: Pick your preferred language and click “Next.”
- License Agreement: Review the license and click “I agree.”
- System Compatibility Check: The installer verifies your server environment meets the requirements. Resolve any missing PHP extensions or permissions issues if flagged.
- Store Information: Enter store name, default country, and configure the primary language. Create an admin account with a robust password.
- Database Configuration: Provide the newly created database name, user, and password. Keep the default localhost as the database host unless using a remote DB server.
After clicking “Next” at each stage, PrestaShop begins the automated installation. This process can take a few minutes, depending on your server’s capacity.
Finalizing Setup
Once installation completes, you’ll be prompted to remove the /install folder for security:
sudo rm -rf /var/www/html/prestashop/install
You should also rename the admin folder to something less obvious (e.g., admin_secure) to help protect against brute-force login attempts. Now, your PrestaShop storefront is set up and ready for configuration.
Post-Installation Steps
Even though your online store is technically operational, there are crucial steps to ensure security, functionality, and a smooth customer experience.
Security Measures
- Remove the Install Folder: As mentioned, removing the /install folder avoids unauthorized re-installation.
- Update Admin Folder Name: Using a custom name for the admin directory reduces the likelihood of malicious script scans.
- Regular Backups: Schedule periodic backups of both your database and web files. Tools like rsnapshot or duplicity can automate this task.
Firewall and SELinux
You’ve likely configured basic firewall rules, but advanced usage may require more fine-tuned SELinux settings. If SELinux is enforcing, verify that httpd has the correct permissions to access the PrestaShop files. You can check or adjust with:
sudo setsebool -P httpd_can_network_connect 1
By fine-tuning these security measures, you reinforce the stability and reliability of your e-commerce site.
6.3 SEO-Friendly URL Configuration
Within your PrestaShop back office, navigate to Shop Parameters > SEO & URLs and enable user-friendly URLs. This improves search engine rankings and enhances user experience, helping you target more customers and drive traffic.
Performance Optimization
E-commerce platforms benefit significantly from performance optimizations. Improve loading times and handle more concurrent visitors conveniently by considering these adjustments:
- PHP Configuration: Increase memory_limit and max_execution_time in your php.ini to support bulk operations.
- Enable PrestaShop Caching: Through the PrestaShop back office, enable performance modules like Smarty cache.
- OPcache and PHP-FPM: Use OPcache for caching PHP scripts, and configure PHP-FPM for better performance under heavy loads.
With these optimizations in place, your store will be quicker and more responsive, leading to a better overall user experience.
Troubleshooting Tips & Additional Resources
Common Issues and Resolutions
- Blank Pages or 500 Errors: Often triggered by incorrect file permissions or missing PHP extensions. Double-check error logs in
/var/log/httpd/prestashop_error.log
to identify the cause. - Database Connection Failures: Confirm that the DB user credentials are correct and that the MariaDB server is running. If PrestaShop can’t connect, review your App parameters and firewall settings.
- HTTPS Issues: Ensure your SSL certificates are valid and the mod_ssl Apache module is loaded. Make sure you renew Let’s Encrypt certificates before they expire.
- Slow Performance: Profiling the site with tools like
htop
ortop
can showcase potential bottlenecks. Consider upgrading server resources or fine-tuning PHP configurations if usage is high.
Congratulations! You have successfully installed PrestaShop. Thanks for using this tutorial for installing the PrestaShop on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official PrestaShop website.