Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

How to Install PrestaShop with Apache on Ubuntu 24.04

How to Install PrestaShop with Apache on Ubuntu 24.04

Setting up an online store with PrestaShop on an Ubuntu 24.04 server using Apache provides a flexible and powerful platform for e-commerce. This guide walks you through the entire installation process, ensuring your store is ready to launch. Before starting, ensure you have a server running Ubuntu 24.04 with root or sudo privileges, a domain name pointed to your server, and basic familiarity with command-line operations. You will also need a stable internet connection to download necessary packages and files.

What You’ll Need

  • Ubuntu 24.04 server with root or sudo access
  • Domain name pointed to your server’s IP address
  • Basic knowledge of Linux command line
  • SSH client (like PuTTY or terminal)
  • Optional: SSL certificate for HTTPS (recommended for security)

Step-by-Step

  1. Update Your System
    • Login to your server via SSH:
      ssh user@your_server_ip
    • Update package lists and upgrade existing packages:
      sudo apt update && sudo apt upgrade -y
  2. Install Apache, MySQL, and PHP (LAMP stack)
    • Install Apache:
      sudo apt install apache2 -y
    • Install MySQL Server:
      sudo apt install mysql-server -y
    • Install PHP and required modules:
      sudo apt install php libapache2-mod-php php-mysql php-xml php-gd php-curl php-mbstring php-zip php-intl -y
  3. Secure MySQL
    • Run the security script:
      sudo mysql_secure_installation
  4. Create a Database for PrestaShop
    • Login to MySQL:
      sudo mysql -u root -p
    • Create database and user:
      CREATE DATABASE prestashop_db;
      CREATE USER 'prestashop_user'@'localhost' IDENTIFIED BY 'your_password';
      GRANT ALL PRIVILEGES ON prestashop_db.* TO 'prestashop_user'@'localhost';
      FLUSH PRIVILEGES;
      EXIT;
  5. Download and Extract PrestaShop
    • Navigate to web root:
      cd /var/www/html
    • Download the latest PrestaShop package:
      wget https://www.prestashop.com/download/old/prestashop_1.7.8.8.zip
    • Install unzip if needed:
      sudo apt install unzip -y
    • Unzip the package:
      sudo unzip prestashop_1.7.8.8.zip -d prestashop
    • Set ownership:
      sudo chown -R www-data:www-data /var/www/html/prestashop
  6. Configure Apache Virtual Host
    • Create a new config file:
      sudo nano /etc/apache2/sites-available/prestashop.conf
    • Add the following configuration, replacing ‘yourdomain.com’ with your actual domain:
      <VirtualHost *:80>
          ServerName yourdomain.com
          ServerAlias www.yourdomain.com
          DocumentRoot /var/www/html/prestashop
          <Directory /var/www/html/prestashop>
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
          </Directory>
          ErrorLog ${APACHE_LOG_DIR}/prestashop_error.log
          CustomLog ${APACHE_LOG_DIR}/prestashop_access.log combined
      </VirtualHost>
    • Enable the site and rewrite module:
      sudo a2ensite prestashop.conf
      sudo a2enmod rewrite
      sudo systemctl reload apache2
  7. Complete PrestaShop Installation via Web Browser
    • Open your browser and navigate to http://yourdomain.com
    • Follow the on-screen instructions to select language, configure store details, and connect to the database.
    • Ensure you delete the /install folder after setup to secure your site:
      sudo rm -rf /var/www/html/prestashop/install
  8. Optional: Enable HTTPS with SSL
    • Install Certbot:
      sudo apt install certbot python3-certbot-apache -y
    • Obtain and install SSL certificate:
      sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

Common Mistakes

  • Not updating the server before starting the installation process, leading to package conflicts.
  • Using incorrect database credentials during setup, causing connection errors.
  • Failing to set proper permissions on the PrestaShop files and folders, resulting in access issues.
  • Forgetting to restart or reload Apache after configuration changes, which prevents new settings from taking effect.
  • Leaving the /install directory after setup, which exposes your installation to security risks.

Tips

  • Always back up your database and files before major changes.
  • Use strong, unique passwords for database and admin accounts.
  • Set up a firewall and only open necessary ports (80, 443).
  • Configure automatic SSL renewal with Certbot to keep your site secure.
  • Regularly update PrestaShop and server packages to patch security vulnerabilities.

Troubleshooting

If your PrestaShop installation does not load or shows errors:

  • Check Apache logs: Review error logs at /var/log/apache2/error.log for clues.
  • Verify database connection: Confirm your database credentials are correct in the configuration files.
  • Ensure permissions are correct: Files should be owned by www-data, and directories should have 755 permissions.
  • Clear cache: Delete cache files in /var/www/html/prestashop/app/cache/ or use the admin panel.
  • Check PHP settings: Ensure PHP modules are enabled and compatible with PrestaShop requirements.

Frequently Asked Questions

1. Can I install PrestaShop without a domain name?

Yes, you can access it via your server’s IP address, but using a domain name is recommended for branding and SSL setup.

2. How do I secure my PrestaShop store?

Use HTTPS with an SSL certificate, keep the software updated, and implement firewall rules to restrict access.

3. What are the server requirements for PrestaShop?

PrestaShop requires PHP 7.2 or higher, MySQL 5.7 or higher, and at least 256MB of PHP memory limit.

4. How do I upgrade PrestaShop later?

Use the built-in upgrade tool or manually replace core files, but always back up before upgrading.

5. Can I run PrestaShop on a shared hosting environment?

Yes, many shared hosts support PrestaShop, but ensure they meet the server requirements and allow custom PHP modules.

6. How do I add SSL to my existing PrestaShop installation?

Obtain an SSL certificate via Certbot or your hosting provider, then configure Apache to redirect HTTP traffic to HTTPS.

Following these steps carefully will help you set up a robust, secure, and functional PrestaShop store on Ubuntu 24.04 with Apache, ready to serve your customers effectively.

Related

How to Install PrestaShop with Apache on Ubuntu 24.04
Scroll to top