Jump to content

Prestashop 1.7 Nginx


Matthieu Malttt

Recommended Posts

Hi everyone,

 

We are trying to make a perfect nginx / php7-fpm configuration for Prestashop 1.7 so we opened a Github repository about this.

 

You can find it (and maybe improve it) here : https://github.com/MattLoyeD/Prestashop-Nginx

 

Todo :

- Improve Symfony Framework compatibility on Product Edit Pages.

 

Feel free to comment or correct anything :)

 

Matt from Malttt

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...
  • 4 weeks later...

the code on the github page is the server configuration

 

you can find this file in etc/nginx/sites-available/your_file OR etc/nginx/sites-enabled/your_file

 

replace your file by the name of your file, by default th file is name default. But if you have multiple site on your server you have problably one file per site.

 

Hope this help.

sorry for my bad english.

Link to comment
Share on other sites

  • 1 year later...

hello,

with nginx 1.10 and prestashop 1.7.4.0 this rules does not fully work! its missed something, like the cms-section. i found these on the web, but it does also not work! i get a redirect-error:

 

  rewrite "^/([0-9]+)\-(\P{M}\p{M}*)+\.html(.*)$" /index.php?controller=product&id_product=$1$3 last;
  rewrite "^/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=category&id_category=$1$3 last;
  rewrite "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /index.php?controller=product&id_product=$2$4 last;
  rewrite "^/([0-9]+)__([a-zA-Z0-9-]*)(.*)$" /index.php?controller=supplier&id_supplier=$1$3 last;
  rewrite "^/([0-9]+)_([a-zA-Z0-9-]*)(.*)$" /index.php?controller=manufacturer&id_manufacturer=$1$3 last;
  rewrite "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms=$1$3 last;
  rewrite "^/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms_category=$1$3 last;
  rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

Link to comment
Share on other sites

  • 5 months later...

With PS 1.7.5.0, some new back-office Symfony controllers are added : sell, improve and configure, so my new symfony controllers rule into nginx config is:

Quote

    # Symfony controllers
    location ~ /(sell|improve|configure|international|_profiler|product|feature|attribute|supplier|combination|specific-price)/(.*)$ {
      try_files $uri $uri/ /index.php?q=$uri&$args $admin_dir/index.php$is_args$args;
    }

 

Link to comment
Share on other sites

  • 2 months later...
On 5/25/2017 at 3:45 PM, zaar said:

the code on the github page is the server configuration

 

you can find this file in etc/nginx/sites-available/your_file OR etc/nginx/sites-enabled/your_file

 

replace your file by the name of your file, by default th file is name default. But if you have multiple site on your server you have problably one file per site.

 

Hope this help.

sorry for my bad english.

I've got the same problem with ver.17.4 - /index.php/module/manage?_token=G1bj6CImCkM .... Module section doesnt open

PHP ver 7.2 , FPM application server by nginx

What should I do if I don't have such path  for etc ? 😞 how to replace .conf file? 

path.png

Link to comment
Share on other sites

Hello,

On 1/21/2019 at 2:37 PM, Klemart3D said:

With PS 1.7.5.0, some new back-office Symfony controllers are added : sell, improve and configure, so my new symfony controllers rule into nginx config is:

# Symfony controllers
    location ~ /(sell|improve|configure|international|_profiler|product|feature|attribute|supplier|combination|specific-price)/(.*)$ {
      try_files $uri $uri/ /index.php?q=$uri&$args $admin_dir/index.php$is_args$args;
    }

With the Klemart3D solution It's work for me. But i have a problem on the page "stock" in "catalog", the page is grey and i have a bug with javascript :

Does anyone have the same problem?

Thank you!

Capture.JPG

Link to comment
Share on other sites

  • 4 months later...

hi, i want to convert jpg to webp.... how can i do with nginx? on htaccess rules are:

 

# WebPGenerator Module - Do not edit
RewriteRule . - [E=REWRITEBASE:/]

# Apache 2.2
<IfModule !mod_authz_core.c>
    <Files ~ "(?i)^.*\.(webp)$">
        Allow from all
    </Files>
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
    <Files ~ "(?i)^.*\.(webp)$">
        Require all granted
        allow from all
    </Files>
</IfModule>


<IfModule mod_setenvif.c>
SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp]
</IfModule>

<IfModule mod_headers.c>
Header append Vary Accept env=REQUEST_image
</IfModule>

<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
#Domain: www.mondopresepiprova.it

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.webp [L]
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.webp [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.webp [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.webp [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.webp [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.webp [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.webp [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/c/$1$2$3.webp [L]

RewriteCond %{HTTP_HOST} ^www.mondopresepiprova.it$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.webp$ %{ENV:REWRITEBASE}img/c/$1$2.webp [L]
# WebPGenerator Module - Do not edit

 

but on nginx i tried everything but no conversione..

i tried this:

 

location ~* ^/.+\.(png|jpg)$ {
    add_header Vary Accept;
    try_files $uri$webp_suffix $uri =404;
}

rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$1$2$3.webp last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$1$2$3$4.webp last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$1$2$3$4$5.webp last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.webp last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.webp last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.webp last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.webp last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.webp$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.webp last;
rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.webp$ /img/c/$1$2$3.webp last;
rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.webp$ /img/c/$1$2.webp last;

 

what i have to do now?

 

 

 

Link to comment
Share on other sites

  • 9 months later...
On 3/21/2019 at 10:23 PM, kibiribi said:

I've got the same problem with ver.17.4 - /index.php/module/manage?_token=G1bj6CImCkM .... Module section doesnt open

PHP ver 7.2 , FPM application server by nginx

What should I do if I don't have such path  for etc ? 😞 how to replace .conf file? 

path.png

I have the same issue.  Did you find a solution?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...