Install PrestaShop on Debian Wheezy VPS with PHP-FPM and Nginx


prestashopIn this post we’ll show you how to install PrestaShop on a Debian Wheezy VPS with PHP-FPM and Nginx. PrestaShop is an open-source eCommerce solution, committed to providing the best online shopping experience for both consumers and merchants. PrestaShop comes with many features such as Catalog Management, Product Displays, Site Management, Search Engine Optimization, Multi-store management, Analytics & Reporting and many more.


Install Nginx, MySQL and PHP-FPM

apt-get install nginx php5-fpm php5-cli php5-gd php5-mcrypt php5-mysql mysql-server mysql-client

Create a new database for the shop

CREATE DATABASE presta CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON presta.* TO db_user@localhost IDENTIFIED BY 'db_user_passwd';

Create a root directory for the shop

mkdir -p /var/www/shopdomain.com/{public_html,logs}

Download and extract PrestaShop

cd /var/www/shopdomain.com/public_html
wget http://www.prestashop.com/download/prestashop_1.5.6.1.zip
unzip prestashop_1.5.6.1.zip
mv prestashop/* .
rm prestashop_1.5.6.1.zip
rmdir prestashop/

Run the following command to set the correct ownership

chown -R www-data: /var/www/shopdomain.com/public_html/

Nginx configuration.

Create a new Nginx server block with the following content

# /etc/nginx/sites-available/shopdomain.com
server {
  server_name shopdomain.com;
  listen 80;
  root /var/www/shopdomain.com/public_html;
  access_log /var/www/shopdomain.com/logs/access.log;
  error_log /var/www/shopdomain.com/logs/error.log;

  index index.php;

  rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
  rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$1$2.jpg last;
  rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
  rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last;
  rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$ /img/c/$1.jpg last;
  rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last;
  try_files $uri $uri/ /index.php?$args;

  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ \.php {
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Symlink it and restart the server

ln -s /etc/nginx/sites-available/shopdomain.com /etc/nginx/sites-enabled/shopdomain.com
/etc/init.d/nginx restart

Open your browser and navigate to http://shopdomain.com/install/ and follow the onscreen instructions. After the installation is complete, do not forget to remove the installation directory.

rm -rf var/www/shopdomain.com/public_html/install

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services in which case you can simply ask our expert Linux admins to install this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
How to install and integrate DKIM with OpenDKIM and Postfix on a CentOS 6 VPS
Tutorials
How to install and use WP-CLI on a Linux VPS
Tutorials
How to set-up server-side email filtering with Dovecot Sieve and Roundcube on a CentOS 6 VPS
  • Bob

    BobBob

    Author Reply

    Good explanation, thx! Still works for PS1.6.