How to Install and Set Up PrestaShop on VPS for E-commerce

PrestaShop is an open-source e-commerce platform that provides everything you need to build and manage your online store. Whether you're starting a small business or setting up a large-scale e-commerce website, PrestaShop is a flexible and powerful solution. In this guide, we will walk you through the installation and setup of PrestaShop on a VPS (Virtual Private Server) for your e-commerce needs.


Prerequisites

Before beginning the installation, make sure you have the following:

  1. A VPS running Ubuntu 20.04 or later (Other distributions such as CentOS or Debian can also be used, but this guide assumes Ubuntu).
  2. Root or sudo access to your VPS.
  3. A domain name (optional, but highly recommended).
  4. A web server like Apache or Nginx.
  5. PHP 7.1 or later (PrestaShop requires PHP).
  6. MySQL or MariaDB database (for storing e-commerce data).
  7. Basic knowledge of Linux commands.

Step 1: Update Your VPS

  1. Update System Packages
    • First, update the package list and installed packages to ensure your VPS is up to date:
       
      sudo apt update && sudo apt upgrade -y

Step 2: Install Apache, MySQL, and PHP

PrestaShop requires Apache, MySQL, and PHP to run. Here’s how to install them on your VPS.

Install Apache

  1. Install Apache Web Server

    • Run the following command to install Apache:
       
      sudo apt install apache2 -y
  2. Enable Apache to Start on Boot

    • Ensure Apache starts automatically on boot:
       
      sudo systemctl enable apache2
  3. Verify Apache Installation

    • Open your browser and enter the IP address of your VPS. You should see the Apache default page. Alternatively, you can run:
       
      sudo systemctl status apache2

Install MySQL

  1. Install MySQL Server

    • Install the MySQL server using:
       
      sudo apt install mysql-server -y
  2. Secure MySQL Installation

    • Run the MySQL secure installation script to improve security:

       
      sudo mysql_secure_installation
    • You will be prompted to set the root password and configure security options. Choose the appropriate options to secure your installation.

  3. Check MySQL Status

    • Verify MySQL is running:
       
      sudo systemctl status mysql

Install PHP

PrestaShop requires PHP with several extensions. Here's how to install the required version of PHP.

  1. Install PHP and Required Extensions

    • Run the following command to install PHP and necessary extensions:
       
      sudo apt install php php-cli php-mbstring php-xml php-zip php-curl php-mysqli php-json php-gd libapache2-mod-php -y
  2. Verify PHP Installation

    • Check the PHP version to confirm it’s installed correctly:
       
      php -v

Step 3: Set Up MySQL Database for PrestaShop

  1. Log in to MySQL

    • Log in to the MySQL shell as the root user:
       
      sudo mysql -u root -p
  2. Create a Database for PrestaShop

    • Create a new database for PrestaShop:
      sql
       
      CREATE DATABASE prestashop;
  3. Create a MySQL User

    • Create a new user and grant privileges to the PrestaShop database:

      sql
       
      CREATE USER 'prestashopuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashopuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
    • Replace 'your_password' with a secure password.


Step 4: Download and Install PrestaShop

  1. Navigate to the Web Directory

    • Go to your web server's root directory:
       
      cd /var/www/html
  2. Download PrestaShop

    • Use wget to download the latest version of PrestaShop from the official website:
       
      sudo wget https://download.prestashop.com/download/old/prestashop_1.7.8.0.zip
  3. Extract the PrestaShop Archive

    • Install unzip if not already installed:

       
      sudo apt install unzip -y
    • Extract the downloaded PrestaShop zip file:

       
      sudo unzip prestashop_1.7.8.0.zip
  4. Set Proper Permissions

    • Set proper ownership and permissions for the PrestaShop files:
       
      sudo chown -R www-data:www-data /var/www/html/* sudo chmod -R 755 /var/www/html/*

Step 5: Configure Apache for PrestaShop

  1. Create a New Virtual Host File for PrestaShop

    • Create a new virtual host configuration for Apache:
       
      sudo nano /etc/apache2/sites-available/prestashop.conf
  2. Add the Following Configuration

    • Add the following content, replacing your_domain_or_ip with your actual domain name or VPS IP address:
      apache
       
      <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ServerName your_domain_or_ip <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
  3. Enable the New Site Configuration

    • Enable the new virtual host and mod_rewrite:
       
      sudo a2ensite prestashop.conf sudo a2enmod rewrite
  4. Restart Apache

    • Restart Apache to apply the changes:
       
      sudo systemctl restart apache2

Step 6: Complete the PrestaShop Installation

  1. Access the PrestaShop Installer

    • Open your browser and navigate to http://your_domain_or_ip. You should see the PrestaShop installation page.
  2. Choose Your Language

    • Select the language for your installation and click "Next."
  3. Agree to the License Agreement

    • Read and agree to the PrestaShop license terms.
  4. Enter Your Database Details

    • In the "Database Configuration" step, enter the following:

      • Database Server: localhost
      • Database Name: prestashop
      • Database User: prestashopuser
      • Database Password: The password you set earlier.
    • Click "Next" to proceed.

  5. Configure Your Store

    • Set up the store name, country, and other relevant information. Choose the default theme and create an admin account.
  6. Complete Installation

    • After filling out all necessary details, click "Next" to finish the installation.

Step 7: Secure Your PrestaShop Installation

  1. Remove the Installation Folder

    • Once PrestaShop is installed, you need to delete the install directory to secure your store:
       
      sudo rm -rf /var/www/html/install
  2. Configure File Permissions

    • Ensure the correct file permissions are applied to the PrestaShop directories:
       
      sudo chown -R www-data:www-data /var/www/html/ sudo chmod -R 755 /var/www/html/

Step 8: Access the PrestaShop Admin Panel

  1. Log in to the Admin Panel

    • Once the installation is complete, you can access the PrestaShop admin panel by going to:
      arduino
       
      http://your_domain_or_ip/adminXXXX
    • Replace adminXXXX with the actual admin folder name generated during installation.
  2. Login with Admin Credentials

    • Use the admin username and password you created during the installation to log in.

Conclusion

You have successfully installed and set up PrestaShop on your VPS for e-commerce. Now, you can start customizing your online store, adding products, and configuring payment and shipping methods. With PrestaShop, you have a powerful and scalable platform to grow your online business.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution