How to Install PrestaShop on Ubuntu 18.04 Bionic Beaver

Install PrestaShop on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure PrestaShop on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

PrestaShop is free open-source shopping cart software that you can use to run an e-commerce website. With its beautiful themes and wide support from developers, PrestaShop offers a great platform for selling products on the internet. The mission of PrestaShop is to help people build successful online stores. It is estimated that more than a million users rely on this platform as their only e-commerce software.

Install PrestaShop on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install LAMP Stack.

PrestaShop is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set Ubuntu up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Ubuntu to serve PHP before you continue.

Step 3. Install PrestaShop on Ubuntu 18.04.

Before downloading the PrestaShop archive, first create a directory that will hold the Joomla files and navigate to it:

sudo mkdir -p /var/www/example.com
cd /var/www/example.com

Now you can download the latest version of the PrestaShop package (1.7.5.2) from its official website.

wget https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip
unzip prestashop_1.7.5.2.zip

Set the directory permissions accordingly:

sudo chown www-data: /var/www/example.com
sudo chmod -R 755 /var/www/example.com

Step 4. Creating a MariaDB database for PrestaShop.

PrestaShop uses the MariaDB database to store all its data like posts, pages, users, plugins, and themes settings. Log in to your MariaDB server with the following command and enter your MariaDB root password:

mysql -u root -p

Once you’re in the MariaDB console, create a new database:

MariaDB > create user 'mypres'@'localhost' identified by 'password';
MariaDB > grant all on myprestashop.* to 'mypres'@'localhost';
MariaDB > flush privileges;
MariaDB > exit;

Step 4. Configuring Apache for PrestaShop.

Create a new virtual host configuration file for your PrestaShop website, named your-domain.com.conf:

nano /etc/apache2/sites-available/your_domain.com.conf

And add the following content to the file:

<VirtualHost *:80>    
      ServerAdmin [email protected]
      DocumentRoot /var/www/example.com
      ServerName your-domain.com
      ServerAlias www.your-domain.com

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      <Directory /var/www/example.com/>
         Options FollowSymlinks
         AllowOverride All
         Require all granted
 </Directory>
</VirtualHost>

To enable the virtual host we have just created, run the following command:

ln -s /etc/apache2/sites-available/your-domain.com.conf /etc/apache2/sites-enabled/your-domain.com.conf

For the new configuration to take effect, restart the Apache service by typing:

sudo a2ensite your_domain.com.conf 
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 5. Completing the PrestaShop Installation.

You can now finalize your PrestaShop website installation by typing the public IP address associated with your Ubuntu 18.04 server on a browser. You will get a screen similar to the one below:

http://your_domain.com/

That’s all you need to do to install PrestaShop on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.