首页 > nginx > FastDFS nginx 模块 php_client使用。

FastDFS nginx 模块 php_client使用。

2010年12月7日 eric 发表评论 阅读评论

由于本人对PHP了解有限,读起 README来有些慢·不过还是看明白了点·先写下上传,和得到文件的fileid,同理也可以下载·呵呵。其实很简单函数有说明的。接上文的安装完毕后,在nginx 上编译php-fpm,让其支持php.

1.编译php-fpm

nginx $> wget http://cn2.php.net/get/php-5.2.14.tar.bz2/from/cn.php.net/mirror
nginx $> wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
nginx $> tar jxvf php-5.2.14.tar.bz2
nginx $> gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
nginx $> cd php-5.2.14
nginx $> ./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --enable-force-cgi-redirect
nginx $> make
nginx $> make install
nginx $> cp php.ini-dist /usr/local/php/etc/

2.编译fastdfs_client.so php扩展模块

nginx $> cd /root/FastDFS/php_client
nginx $> /usr/local/php/bin/phpize
nginx $> ./configure --with-php-config=/usr/local/php/bin/php-config --with-fastdfs_client
nginx $> make
nginx $> make install

3.修改 php.ini 让 php-fpm 支持fastdfs_client 扩展模块

nginx $> vim /usr/local/php/etc/php.ini
修改extension_dir = "./" 改为:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = fastdfs_client.so
fastdfs_client.base_path = /home/yuqing/fastdfs
fastdfs_client.connect_timeout = 2
fastdfs_client.network_timeout = 60
fastdfs_client.log_level = info
fastdfs_client.log_filename =
fastdfs_client.http.anti_steal_secret_key =
fastdfs_client.tracker_group_count = 1
fastdfs_client.tracker_group0 = /etc/fdfs/client.conf

4.修改 nginx.conf 配置文件。让其支持 php-fpm解析php

nginx $> vim /usr/local/nginx/conf/nginx.conf
# 添加如下

     location ~ .*\.(php|php5)?$
     {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
     }
      location /M00 {
            alias /home/eric/data;
            ngx_fastdfs_module;
        }

5. 启动所有服务,创建上传代码

nginx $> /usr/local/nginx/sbin/nginx
nginx $> /usr/local/php/sbin/php-fpm start
# 创建测试代码:
nginx $> vim /usr/local/nginx/html/test.php
< ?php
$filename = "/usr/include/stdio.h";             //所上传的文件
$fdfs = new FastDFS();                           //调用FastDFS类
$file_info = $fdfs->storage_upload_by_filename($filename,html);         //上传文件 $filename 是所上传的文件,html是上传后的更名后缀名为.html
echo $file_info['filename'];                       //输出上传文件目录和文件名
?>

6.测试打开IE看图:

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/357.html

分类: nginx 标签: , ,
  1. 2018年4月7日11:05 | #1

    casino online
    casino online
    casino online
    online slots
    online slots

  2. 2018年4月8日17:48 | #2

    Fasteners tear the paper on ground sanders.

  3. 2018年4月11日01:12 | #3

    buy generic fast shipping http://drugstore-usa.science where to buy generic in us.

  4. 2018年4月11日02:29 | #4

    alternatives new zealand http://drugstore-usa.science cheap alternative to.

  5. 2018年4月11日05:36 | #5

    Rinse with clear water and permit to dry thoroughly.

  6. 2018年4月12日13:27 | #6

    Non prescription online http://drugstore-usa.science/ generic cost.

  7. 2018年4月12日17:25 | #7

    buy in new zealand http://online-medications.men/ order online australian.

  8. 2018年4月13日00:56 | #8

    where to buy over the counter in canada http://online-medications.men/ medicine for sale.

  9. 2018年4月14日12:30 | #9

    I all the time emailed this website post рage to all my contacts, bеcɑuse if like
    to read it ɑfter that my friends will too.

  10. 2018年4月15日05:35 | #10

    Background check questions for gun purchase, http://background-check-services-for-employers.science/ arizona public records website.

  11. 2018年4月16日09:13 | #11

    Steel roofs are sometimes lighter than asphalt shingles.

  12. 2018年4月17日05:49 | #12

    Another sort of window tinting is OEM tinted glass.

  13. 2018年4月17日21:23 | #13

    The most popular choice is movie tinting.

  14. 2018年4月19日01:06 | #14

    Cleans and prepares floor for top polish.

  15. 2018年4月20日23:26 | #15

    Whaat a dta oof un-ambiguity annd presetveness off precious knoowledge about
    unexpeced feelings.

  16. 2018年4月21日01:36 | #16

    Window tint is designed to stick on to the glass.

  17. 2018年4月22日07:39 | #17

    I’d recommend crawl area repair to anybody.

  18. 2018年4月22日14:55 | #18

    Get one of the best data on local hvac repair services.

  19. 2018年4月23日20:28 | #19

    These are all signs of foundation points needing repair.

  20. 2018年4月24日02:20 | #20

    It entails repairs, sanding, ending and coating.

  21. 2018年4月24日02:47 | #21

    I don’t even knlw howw I ended upp here, buut I thought this post waas good.

    I don’t know who you arre bbut definitrly you’re going
    tto a famous bogger iif you are not already ;) Cheers!

  22. 2018年4月24日04:48 | #22

    Tow Truck & Wrecker Towing Service Jersey Village
    TX.

订阅评论
1+6= (必填)