# Prestashop

Apache : patrick:86

```bash
sudo apt install php php-common php-cli php-fpm php-opcache php-gd php-mysql php-curl php-intl php-xsl php-mbstring php-zip php-bcmath php-soap -y
sudo mkdir -p /var/www/shop && cd /var/www/shop
```

```bash
wget https://github.com/PrestaShop/PrestaShop/releases/download/8.1.6/prestashop_8.1.6.zip
unzip ...
```

```bash
mysql -u root -p (transatlantique)
```

```sql
CREATE DATABASE prestashop COLLATE utf8mb4_general_ci;
CREATE USER "prestashopuser"@"hostname" IDENTIFIED BY "somepassword";
GRANT ALL PRIVILEGES ON prestashop.* TO "prestashopuser"@"hostname";
FLUSH PRIVILEGES;
EXIT;
```

<table id="bkmrk-database-user-passwo"><tbody><tr><th colspan="1" rowspan="1">database</th><th colspan="1" rowspan="1">user</th><th colspan="1" rowspan="1">password</th><th colspan="1" rowspan="1">host</th><th colspan="1" rowspan="1">prefix</th></tr><tr><td colspan="1" rowspan="1">prestashop</td><td colspan="1" rowspan="1">root</td><td colspan="1" rowspan="1">transatlantique</td><td colspan="1" rowspan="1">localhost</td><td colspan="1" rowspan="1">ps\_</td></tr></tbody></table>

```bash
sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/8.2/fpm/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/8.2/fpm/php.ini
sudo sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/8.2/fpm/php.ini
sudo sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/8.2/fpm/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = Europe/Paris" /etc/php/8.2/fpm/php.ini
sudo sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php/8.2/fpm/php.ini
```

```bash
sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/8.2/apache2/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/8.2/apache2/php.ini
sudo sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/8.2/apache2/php.ini
sudo sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/8.2/apache2/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = Europe/Paris" /etc/php/8.2/apache2/php.ini
sudo sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php/8.2/apache2/php.ini
```

```bash
sudo systemctl restart apache2.service
```

[https://devdocs.prestashop-project.org](https://devdocs.prestashop-project.org)

---

##### <span style="color: rgb(224, 62, 45);">**(!) In order to handle SEO url, include rewrite rules in [delmar.bzh.conf](https://bookstack.delmar.bzh/books/selfhosted/page/lamp "L.A.M.P")**</span>

## VirtualHost

```
.
├── apache
|	└── shop (86)
└── mariadb
```

`/etc/apache2/sites-available/delmar.bzh.conf`

```nginx
<VirtualHost *:86>
        ServerName shop.delmar.bzh

        ServerAdmin admin@delmar.bzh  
        DocumentRoot /var/www/shop

        <Directory /var/www/shop> 
                Options Indexes FollowSymLinks
                AllowOverride None 
                Order allow,deny 
                allow from all 

                RewriteEngine on
                #Domain: shop.delmar.bzh
                RewriteRule . - [E=REWRITEBASE:/]
                RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
                RewriteRule ^upload/.+$ %{ENV:REWRITEBASE}index.php [QSA,L]
                # Images
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$1$3 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$1$4 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$1$5 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$1$6 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$1$7 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$7/$1$8 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$7/$8/$1$9 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^c/([\d]+)(\-[\.*\w-]*)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/c/$1$2$3 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^c/([a-zA-Z_-]+)(-[\d]+)?/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/c/$1$2$3 [L]
                # AlphaImageLoader for IE and fancybox
                RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ %{ENV:REWRITEBASE}js/jquery/plugins/fancybox/images/$1.$2 [L]
                # Dispatcher
                RewriteCond %{REQUEST_FILENAME} -s [OR]
                RewriteCond %{REQUEST_FILENAME} -l [OR]
                RewriteCond %{REQUEST_FILENAME} -d
                RewriteRule ^.*$ - [NC,L]
                RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```