这是情况。 我已经在运行Ajenti的ubuntu 14.04虚拟机上安装了prestashop 1.7.1,所以我的php-fpm和nginx。 看了很多教程和一些自定义configuration后,我设法让一切正常工作。 然而,我只是安装了一个新的模块,当调用的PHP文件,工作(生成XML)我服务的文件,而不是proccessed结果。我检查了文件的权限,我什至尝试所有文件777。 我已经注意到问题出在哪,yginx的configuration是:
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; }
有什么build议么?
您需要将您的PHP处理location块包含在.xml块中,以便能够执行PHP脚本。 否则,它只是将默认的文件直接发送到客户端。
它看起来像你没有包括任何实际处理.php文件的方法。
您需要在该位置添加类似于此的内容:
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params;
请注意,我说“类似”,因为这将从服务器到服务器,取决于您的configuration。 Nginx需要知道在哪里通过php请求,并从fastcgi获取内容,所以你需要告诉它如何做到这一点。 上面的代码片段可以做到这一点,也许:)