How To Install PrestaShop on Ubuntu 24.04 LTS
PrestaShop is a powerful and flexible open-source e-commerce platform that empowers businesses to create and manage their online stores effectively. Coupled with the robust and secure environment of Ubuntu 24.04, PrestaShop offers a scalable solution for businesses aiming to establish a strong online presence. This comprehensive guide provides a step-by-step process to install PrestaShop on Ubuntu 24.04, ensuring a smooth and successful setup for your e-commerce venture.
Prerequisites
Before diving into the installation process, ensure you have the following prerequisites in place:
- Server Specifications: A server running Ubuntu 24.04 with at least 2GB of RAM and 30GB of disk space to handle the PrestaShop installation and store operations efficiently.
- Domain Name: A registered domain name pointed to your server’s IP address to make your online store accessible to users.
- User Access: A non-root user with
sudo
privileges to execute administrative tasks securely. - Software Requirements: Installation of the LAMP stack (Linux, Apache, MariaDB, PHP) which forms the foundation for running PrestaShop.
Having these prerequisites ensures that your server environment is ready for PrestaShop installation, providing a stable and secure platform for your e-commerce store.
Step 1: Update and Upgrade the System
Keeping your server up-to-date is crucial for security and performance. Begin by updating the package index and upgrading the installed packages:
sudo apt update && sudo apt upgrade -y
This command refreshes the package lists and upgrades all installed packages to their latest versions, ensuring that your system is secure and compatible with the latest software.
Additionally, configure your firewall to allow necessary ports while securing your server:
sudo ufw default allow outgoing
sudo ufw default deny incoming
sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
sudo ufw status
- Port 22: Allows SSH connections for remote server management.
- Port 80: Enables HTTP traffic for web access.
- Port 443: Allows HTTPS traffic for secure web access.
These firewall rules ensure that only essential services are accessible, enhancing the security of your server.
Step 2: Install Apache Web Server
Apache is a reliable and widely-used web server that will host your PrestaShop store. Install Apache using the following command:
sudo apt install apache2 -y
After installation, enable the .htaccess
file to allow Apache to interpret it for URL rewriting and other configurations:
sudo a2enmod rewrite
sudo systemctl restart apache2
Edit the default Apache configuration to allow .htaccess
overrides:
sudo nano /etc/apache2/sites-available/000-default.conf
Within the block, add:
AllowOverride All
Save the file and restart Apache to apply the changes:
sudo systemctl restart apache2
Apache is now installed and configured to work with PrestaShop, ready to serve your online store.
Step 3: Install and Configure MariaDB Database
MariaDB is a robust database management system that PrestaShop relies on to store product, customer, and order information. Install MariaDB using the following command:
sudo apt install mariadb-server -y
Once installed, secure the MariaDB installation:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, remove test databases, and reload privilege tables. This enhances the security of your database server.
Create a dedicated database and user for PrestaShop:
sudo mysql -u root -p
CREATE DATABASE prestashop;
CREATE USER 'prestauser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON prestashop.* TO 'prestauser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace your_password
with a strong password. This database and user will be used by PrestaShop to manage its data securely.
Step 4: Install PHP and Required Extensions
PrestaShop requires PHP and several extensions to function correctly. Install PHP 8.1 and the necessary extensions with the following command:
sudo apt install php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-zip php8.2-gd php8.2-mysql php8.2-xml php8.2-mbstring php8.2-json php8.2-intl -y
After installation, adjust the PHP configuration to meet PrestaShop’s requirements. Open the php.ini
file:
sudo nano /etc/php/8.2/apache2/php.ini
Modify the following settings:
- memory_limit: Increase to
256M
- upload_max_filesize: Set to
64M
- max_execution_time: Set to
300
Save the file and restart Apache:
sudo systemctl restart apache2
These adjustments ensure that PHP can handle the processing demands of PrestaShop, allowing for efficient operation and management of your online store.
Step 5: Download and Extract PrestaShop
With the server environment prepared, the next step is to download PrestaShop. Navigate to the /tmp
directory and download the latest version:
cd /tmp/
wget https://download.prestashop.com/download/releases/prestashop_1.7.8.8.zip
Extract the downloaded archive:
unzip prestashop_1.7.8.8.zip
Move the extracted files to the Apache root directory:
sudo mv prestashop /var/www/html/
Set the appropriate permissions to allow Apache to access and modify the files:
sudo chown -R www-data:www-data /var/www/html/prestashop
sudo chmod -R 755 /var/www/html/prestashop
This ensures that the web server can interact with the PrestaShop files securely and efficiently.
Step 6: Configure Apache Virtual Host for PrestaShop
To serve your PrestaShop store, configure an Apache virtual host specific to your domain. Create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/prestashop.conf
Add the following configuration, replacing your_domain.com
with your actual domain:
<VirtualHost *:80>
ServerAdmin admin@your_domain.com
DocumentRoot /var/www/html/prestashop
ServerName your_domain.com
<Directory /var/www/html/prestashop>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/prestashop_error.log
CustomLog ${APACHE_LOG_DIR}/prestashop_access.log combined
</VirtualHost>
Enable the new site and disable the default site:
sudo a2ensite prestashop.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
This configuration directs Apache to serve PrestaShop when users access your domain, ensuring that your online store is accessible via the web.
Step 7: Complete PrestaShop Installation via Web Interface
With the server-side setup complete, proceed to install PrestaShop through its web interface:
- Access the Installer: Open your web browser and navigate to
http://your_domain.com
. This will launch the PrestaShop installation wizard. - Select Language: Choose your preferred language for the installation process and click Next.
- License Agreement: Read and accept the PrestaShop license agreement to proceed.
- System Compatibility Check: PrestaShop will verify that your server environment meets all requirements. Ensure all checks pass before continuing.
- Store Information: Enter your store information, including store name, activity, and contact details.
- Database Configuration: Input the database name, user, and password you created earlier. PrestaShop will then set up the necessary database tables.
- Demo Data: Optionally, you can install demo data to populate your store with sample products. This is useful for testing purposes.
- Finalize Installation: Once all steps are completed, PrestaShop will display links to the Back Office (admin panel) and Front Office (storefront).
For security reasons, immediately remove the installation directory:
sudo rm -rf /var/www/html/prestashop/install
This prevents unauthorized access to the installation script, safeguarding your store from potential threats.
Step 8: Secure Your PrestaShop Installation with SSL
Securing your online store with SSL is essential for protecting data and enhancing customer trust. Utilize Let’s Encrypt to obtain a free SSL certificate:
sudo apt install certbot python3-certbot-apache -y
Run Certbot to obtain and install the SSL certificate:
sudo certbot --apache -d your_domain.com
Follow the prompts to complete the SSL installation. After successful completion, your store will be accessible via HTTPS, ensuring secure data transmission.
Verify the HTTPS configuration by accessing https://your_domain.com
in your web browser. The padlock icon indicates a secure connection.
Troubleshooting Common Issues
During the installation process, you might encounter common issues. Here are solutions to some of them:
- Apache Errors: If you experience issues with Apache, check the error logs located at
/var/log/apache2/error.log
. Common problems include syntax errors in configuration files or missing modules. - Database Connection Issues: Ensure that the database credentials entered during installation are correct. Verify that the MariaDB service is running:
sudo systemctl status mariadb
- PHP Compatibility Problems: Confirm that all required PHP extensions are installed and enabled. Revisit the PHP installation step to ensure all necessary extensions are present.
Addressing these issues promptly ensures a smooth installation process and a functional PrestaShop store.
Post-installation Tips
After successfully installing PrestaShop, consider the following tips to optimize and secure your store:
- Admin Panel Access: Access the Back Office by navigating to
http://your_domain.com/admin
. To enhance security, rename the default admin directory to a unique name:
mv /var/www/html/prestashop/admin /var/www/html/prestashop/unique_admin_name
Update the Apache configuration accordingly to reflect the new admin directory name.
- Performance Optimization: Enable caching mechanisms within PrestaShop settings to improve load times. Additionally, consider integrating a Content Delivery Network (CDN) to enhance the delivery speed of your store’s assets globally.
- Regular Backups: Implement a regular backup schedule for your PrestaShop files and database to prevent data loss in case of unforeseen issues.
- Security Enhancements: Install security plugins and regularly update PrestaShop and its extensions to protect against vulnerabilities.
These post-installation measures ensure that your PrestaShop store remains efficient, secure, and ready to provide an excellent shopping experience for your customers.
Congratulations! You have successfully installed PrestaShop. Thanks for using this tutorial to installing PrestaShop e-commerce content management system (CMS) on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the PrestaShop website.