centos7上的h5ai折腾记

过程:
安装php-fpm和nginx,且经验证二者在其他项目可以正常使用。
从debian8拷贝过来_h5ai的nginx配置如下:

     location ~ [^/]\.php(/|$) {
         fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; #反注释
         include /etc/nginx/snippets/fastcgi-php.conf;
     }

由于centos7服务器上没有/etc/nginx/snippets/fastcgi-php.conf这个文件,所以把这行改成了include fastcgi_params;,即:

# _h5ai file server
server {
    listen  12345;
        # server_name _;
    root /home/chudongyu/rtorrent/download;
        index  index.html  index.php  /_h5ai/public/index.php;

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

    location ~ [^/]\.php(/|$) {
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
    }
}

但是_h5ai并不能用,症状:
打开172.19.240.132:12345,只有空白页面,不显示任何东西。检查nginx的日志里面完全正常,没有错误。
在文件夹下建立index.html,发现可以显示,但是建立index.php(<? phpinfo(); ?>)还是一批空白,啥都没有。
折腾良久,最终发现仅仅include fastcgi_params'是不够的,还要添加:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

完整的正确配置如下

# _h5ai file server
server {
    listen  12345;
        # server_name _;
    root /home/chudongyu/rtorrent/download;
        index  index.html  index.php  /_h5ai/public/index.php;

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

    # location ~ [^/]\.php(/|$) {
    #     fastcgi_pass   127.0.0.1:9000;
    #     include        fastcgi_params;
    # }

    location ~ \.php$ {
            root           /home/chudongyu/rtorrent/download;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

参考:https://blog.csdn.net/zsx0728/article/details/81183056

一个视频播放器更好用的_h5ai修改版:
【自用分享】 h5ai HTML5播放器(DPlayer)版
https://www.hostloc.com/thread-438265-1-2.html
直接下载地址: https://www.moerats.com/usr/down/h5ai_dplayer+modified+by+icycat.zip

猜你喜欢

转载自www.cnblogs.com/dylanchu/p/10231256.html