0

Here is the situation. I've setup prestashop 1.7.1 on an ubuntu 14.04 VM running Ajenti, so its php-fpm and nginx for me. After looking through a lot of tutorials and some custom configuration i managed to get everything working just fine. However i just installed a new module and when calling the php file that does the work (generates xml) i am served with the file instead of the proccessed result.I checked file permissions and i even tried 777 on all files. I've noted where the problem is, y nginx configuration is:

set $admin_dir /admin_folder;

gzip on;
gzip_vary on;
gzip_proxied any;

gzip_types
 application/atom+xml
 application/javascript
 application/json
 application/ld+json
 application/manifest+json
 application/rss+xml
 application/vnd.geo+json
 application/vnd.ms-fontobject
 application/x-font-ttf
 application/x-web-app-manifest+json
 application/xhtml+xml
 application/xml
 font/opentype
 image/bmp
 image/svg+xml
 image/x-icon
 text/cache-manifest
 text/css
 text/plain
 text/vcard
 text/vnd.rim.location.xloc
 text/vtt
 text/x-component
 text/x-cross-domain-policy;
 # Supposed to be the case but we never know
 # text/html;

gzip_disable "MSIE [1-6]\.(?!.*SV1)";


# Old image system ?
 rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
 rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
 rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
 rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
 rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
 rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$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])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
 rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
 rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
 rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;

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

 location / {
 try_files $uri $uri/ /index.php$is_args$args;
 }

 error_page 404 /index.php?controller=404;

add_header Strict-Transport-Security max-age=31536000;

 location ~ /\. {
 deny all;
 }

 location ~ \.tpl {
 deny all;
 }

location ~ ^/admin_folder/index.php/(.*) { 
 if (!-e $request_filename) {
 rewrite ^/.*$ /admin_folder/index.php last; 
 }
 }

 location ~ /en/index.php {
 rewrite ^/en/index\.php$ /index.php redirect;
 }
 location ~ /el/index.php {
 rewrite ^/el/index\.php$ /index.php redirect;
 }
location ^~ /modules/xmlfeeds/api/xml.php {
#Here is the problem
 return 501;    
}

Any suggestions?

K Sant
  • 1

2 Answers2

0

You need to include your PHP processing location block inside the .xml block for it to be able to execute PHP scripts. Otherwise it simply does the default which is sending the file directly to the client.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
0

It looks like you're not including any method of actually processing the .php file.

You'll need to add something similar to this into that location:

fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;

Please note that I say "similar" as this will change from server to server depending on your configuration. Nginx needs to know where to pass the php request to, and get the content from fastcgi, so you need to tell it how to do that. The above snippet will do that, maybe :)

Reverend Tim
  • 879
  • 8
  • 14
  • I copied the php settings that were applied to the rest but then i got a 502 bad gateway error – K Sant Aug 30 '17 at 10:32
  • you'll need to make sure Nginx can read to PHP. Check your error logs for any issues. Also make sure the "pass" line is correct according to your PHPFPM config so that it's sending it to the right place :) – Reverend Tim Aug 30 '17 at 11:43