微信小程序php服务端nginx配置
微信小程序server端如果选择自己部署的话,可以选择java或者php的,为了省事我选择了php的,腾讯是用CodeIgniter框架做的demo,由于CI框架入口是index.php,扔到服务器上之后需要配置转发,因此踩了不少坑,主要是nginx配置问题,先看官方文档
每个人的服务器配置不一样,我用的是lnmp,如果不奏效的话可以参考一下我下面的配置,稍微有区别的地方就是配置了path_info,直接修改php.ini文件,将cgi.fix_pathinfo设置为1即可
server {
listen 80;
server_name api.11000011.com;
root /home/wwwroot/api.11000011.com;
index index.php;
location / {
root /home/wwwroot/api.11000011.com;
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php($|/) {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
include enable-php.conf;
location ~ /\.ht {
deny all;
}
access_log /home/wwwlogs/api.11000011.com.log;
}
我要评论