Launch your Ecommerce Business for Free with Open Source Solutions

1247

By Cédric Geffroy

At present, there are a lot of saas ecommerce software used to launch an ecommerce business. Softwares like Shopify, Volusion or BigCommerce are often seen as the best choice because they are easier to use and quicker to deploy. However, these assumptions are wrong, especially when you need custom development for your ecommerce site or when you want to add some advanced functions that will help your business grow. This is because these softwares do not allow you to customize your website just the way you want it.

By using open source solutions you are sure to have unlimited potential building your ecommerce site just the way you want it. It offers you a cost-effective solution that can be deployed within a short time.

For this tutorial I have made use of the worldwide used solution that offers flexibility with large community of users. Here are the suggested options:

Prestashop 1.6: This is currently the most stable and advanced open source ecommerce solution with a community of more than one million members, one thousand contributors and 250 agencies (just in case you need a little help…). The 1.6 version has been replaced by the completely revamped 1.7 version which includes Symfony framework. However, I still recommend using the 1.6 version as the 1.7 will probably need a few more releases to be as stable and as efficient as the 1.6.

Linux LEMP on 16.04 + MariaDB: On distribution, LEMP (Linux, Nginx, Mysql and PHP) is the best option when combined with MariaDb in place of Mysql. I also recommend using a cloud hosting company like Digital Ocean, because they have a strong community with well written tutorials and available support. They offer a one click LEMP installation, just like other hosting companies.

After installing your one-click LEMP, log in to your server and check if all your services are up to date.

  • apt-get update

  • apt-get upgrade

I also recommend installing this useful extract tool which will be able to “Do the Right eXtraction” (DTRX) for any archive.

  • apt-get install dtrx

Uninstall Mysql (to install MariaDB)

  • apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7

  • mysql-client-core-5.7

  • rm -rf /etc/mysql /var/lib/mysql

  • apt-get autoremove

  • apt-get autoclean

Install MariaDb

  • apt-get update

  • apt-get install mariadb-server

Launch MariaDB configuration

  • mysql_secure_installation

  • Enter current password for root: No current password so press Enter

  • Set root password : Y

  • Remove anonymous users: Y

  • Disallow root login remotely: Y

  • Remove test database and access to it: Y

  • Reload privilege tables now: Y

Install phpMyAdmin – your database administration tool

  • apt-get install phpmyadmin

  • select apache2

  • Configure database for phpmyadmin with dbconfig-common : YES

  • type a new password

  • ln -s /usr/share/phpmyadmin/ /var/www/html/XXXXXXXXX

Replace XXXXXXXXX by a non-obvious name that will allow you to access your phpMyAdmin web page. http://ip_server/XXXXXXXXXX

  • service nginx restart

Modify privileges of phpMyAdmin user

Connect to mysql

  • mysql -u root -p

Type password chosen during mysql installation.

  • GRANT ALL PRIVILEGES ON *.* TO ‘phpmyadmin’@’localhost’ WITH GRANT OPTION;

  • FLUSH PRIVILEGES;

CTRL+C to exit mysql.

Secure phpMyAdmin

We will add password authentication on the phpMyAdmin page to add a layer of security. Execute next command, type a new password and copy the key returned

  • openssl passwd

Create a directory to store this login and password

  • mkdir /etc/nginx/passwd

Create file to store login and key of password with command

  • nano /etc/nginx/passwd/pma_pass

Your file should contain your login and key like that:

  • login:key_returned

(Use something less obvious than “login”)

Save and close by using CTRL+X and typing “Y” + ENTER

Modify your default vhost to access your phpMyAdmin page

  • nano /etc/nginx/sites-available/digitalocean

After:

  • location / { ……….. }

Add:

  • location /XXXXXXXXXX {

auth_basic “Private”;

auth_basic_user_file /etc/nginx/passwd/pma_pass;

}

Replace XXXXXXXXXX by the name used to access your phpMyAdmin page.

Save and close by using CTRL+X and typing “Y” + ENTER

  • service nginx restart

Create a new vhost for your ecommerce website

  • mkdir -p /var/www/example.com/

  • cd /var/www/example.com/

Download PrestaShop (last 1.6 version) and extract

  • wgethttps://download.prestashop.com/download/releases/prestashop_1.6.1.20.zip

  • dtrx prestashop_1.6.1.20.zip

Remove zip archive and move prestashop main directory

  • rm prestashop_1.6.1.20.zip

  • mv /var/www/example.com/prestashop_1.6.1.20/prestashop/ /var/www/example.com/html

  • rm -r prestashop_1.6.1.20/

Modify group/user of directory

  • chown -R www-data:www-data /var/www/example.com/html

Make sure directories are set to 755 and files to 644

  • find. -type d -print0 | xargs -0 chmod 0755

  • find. -type f -print0 | xargs -0 chmod 0644

Now, we have to create the NGINX vhost for our Prestashop 1.6. You can use this example which has been modified to work on an https PrestaShop website. It might need some tuning depending on your needs.

See attached file

Create your vhost file and paste the vhost example (don’t forget to replace example.com by your domain)

  • nano /etc/nginx/sites-available/example.com

Activate the vhost

  • ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

  • service nginx restart

Tune the PHP configuration

Open the php.ini file and change parameters to match those values

  • nano /etc/php/7.0/fpm/php.ini

  • memory_limit = 256M

  • post_max_size=32M;

  • max_input_vars=10000

max_input_vars is probably commented, remove the “;” at the beginning of the line.

You can use CTRL+W to search in the file.  

Save and close by using CTRL+X and typing “Y” + ENTER

Reload the configuration:

  • service php7.0-fpm reload

Install Postfix

Next, we would love to send emails from our shop, therefore we need to install a mail solution used as a send only tool like Postfix.

  • apt-get install mailutils

  • Choose: Internet Site

  • Type domain: example.com

Next, tune the Postfix configuration:

  • Sudo nano /etc/postfix/main.cf

  • Modify this line:

inet_interfaces = all

  • To this:

inet_interfaces = loopback-only

  • Modify this line:

mydestination = $myhostname, example.com, localhost.com, , localhost

  • To this:

mydestination = $myhostname, localhost.$mydomain, $mydomain

Save and close by using CTRL+X and typing “Y” + ENTER

Restart Postfix

  • systemctl restart postfix

Create a database for your PrestaShop

Access your phpMyAdmin interface with this url http://ip_server/XXXXXXXXXX

XXXXXXXXXX is what you chose previously.

You will be prompted with a popup login form, type your login and password chosen for the extra security layer step earlier. On the phpMyAdmin login page type “phpmyadmin” as login and the password chosen during phpMyAdmin installation process.

To add a new database and its user:

  • Click “New” on the left hand side menu.

  • Type and select in dropdown menu.

  • Click

  • On page loaded click on

  • Click on “Add user account”

  • Username: choose username for your database

  • Host name: localhost

  • Password: choose your password

  • Check the checkbox “Grant all privileges on database “XXXXXX”.”

  • Click OK on bottom of page

  • On next page click OK on bottom of page.

Install Prestashop

Go to your website URL: http://www.example.com

  • Choose language and click Next

  • Accept License Agreements and click Next

  • Fill out form and click Next

  • On Database configuration page:

  • Database server address: localhost

  • Database name: the name you picked

  • Database login: username you picked

  • Database password:password you picked

  • Tables prefix: leave “_ps”

  • Click on “Test your database connection now!”

  • Click on Next

Congrats, “Your installation is finished!”

Click on the back office button on this page and bookmark the URL

Remove the install folder with command:

  • rm -r /var/www/example.com/html/install

Now you should be able to access your store with the url: http://www.example.com

Install the SSL certificate

  • apt-get update

  • apt-get install software-properties-common

  • add-apt-repository ppa:certbot/certbot

  • apt-get update

  • apt-get install python-certbot-nginx

  • certbot –nginx

  • Type your email

  • Agree terms: A

  • Share email or not (it’s up to you)

  • Which names would you like to activate HTTPS for?

Hit enter for both with and without www

  • Redirect HTTP traffic to HTTPS website

Select: 2

Use this command to automatically renew your certificates:

  • certbot renew –dry-run

Configure your PrestaShop to work with https.

  • Login to your PrestaShop backoffice

  • Preferences > General

  • Enable SSL: YES

  • Click Save at the bottom of page

After reloading

  • Enable SSL on all pages: YES

  • Click Save at the bottom of page

BOOM, you can now access your store through HTTPS.

References

This article was written based on my years of experience and other tutorials, articles I found on the web in the last few years of my constant research. Notable among this sites are

Many StackOverflow or AskUbuntu answers: