微信小程序php服务端nginx配置


微信小程序php服务端nginx配置

微信小程序server端如果选择自己部署的话,可以选择java或者php的,为了省事我选择了php的,腾讯是用CodeIgniter框架做的demo,由于CI框架入口是index.php,扔到服务器上之后需要配置转发,因此踩了不少坑,主要是nginx配置问题,先看官方文档

nginx官方文档点这里

每个人的服务器配置不一样,我用的是lnmp,如果不奏效的话可以参考一下我下面的配置,稍微有区别的地方就是配置了path_info,直接修改php.ini文件,将cgi.fix_pathinfo设置为1即可

  1. server {
  2. listen 80;
  3. server_name api.11000011.com;
  4. root /home/wwwroot/api.11000011.com;
  5. index index.php;
  6. location / {
  7. root /home/wwwroot/api.11000011.com;
  8. index index.php;
  9. if (!-e $request_filename) {
  10. rewrite ^/(.*)$ /index.php/$1 last;
  11. break;
  12. }
  13. }
  14. location ~ \.php($|/) {
  15. fastcgi_pass unix:/tmp/php-cgi.sock;
  16. fastcgi_index index.php;
  17. fastcgi_split_path_info ^(.+\.php)(.*)$;
  18. fastcgi_param PATH_INFO $fastcgi_path_info;
  19. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  20. include fastcgi_params;
  21. }
  22. include enable-php.conf;
  23. location ~ /\.ht {
  24. deny all;
  25. }
  26. access_log /home/wwwlogs/api.11000011.com.log;
  27. }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.11000011.com/?id=25

« 上一篇 下一篇 »

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

主机推荐

  • 搬瓦工