fastdfs添加php扩展

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Linux_newbie_rookie/article/details/79061886


不知道怎么安装fastdfs的可以参考http://blog.csdn.net/linux_newbie_rookie/article/details/78974824

在安装完fastdfs文件系统之后,

1. 切换到fastdfs的源码解压目录:
/run/fast/fastdfs-5.05/php_client
1) 先初始化: /usr/bin/phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

2) 编译文件  ./configure --with-php-config=/usr/bin/php-config
...
Build complete.
Don`t forget to run 'make test'.

3) 安装
make && make install
Installing shared extensions:     /usr/lib/php5/20100525/

2. 在php的配置文件添加fastdfs_client.ini信息
 cat /run/fast/fastdfs-5/php_client/fastdfs_client.ini >> /etc/php.ini

3. 重新启动nginx以及php-fpm,fdfs_trackerd 和 fdfs_storaged

可以使用php -m 进行查看fastdfs_client 扩展是否安装上

4. 测试:
cp /run/fast/fastdfs-5/php_client/fastdfs_test.php /run/fast/storaged/

然后在浏览器输入:http://192.168.1.192:8888/fastdfs_test.php
出现:5.05 fastdfs_tracker_make_all_connections result: 1 array(1) { ["group1"]=> array(12) { ["total_space"]=> int(919) ["free_space"]=> int(786) ["trunk_free_space"]=> int(0) 
["server_count"]=> int(1) ["active_count"]=> int(1) ["storage_port"]=> int(23000) ["storage_http_port"]=> int(8888) ["store_path_count"]=> int(1) 
及正常。

遇到的坑,在配置php扩展之后,一直访问不了php界面。
虽然在一台机器启动两个nginx,但是都可以使用同一个php-fpm,只需要在nginx的配置文件指定php的9000端口即可。
建议源码安装之后的nginx配置文件一般不要修改,直接自己创建一个目录存放所有的.conf 的文件(前提需要在nginx.conf文件里面添加一个include)。
如: include /run/fast/nginx/conf/vhost/*;

下面是自己当时的一个配置文件
cat fastdfs.conf
server
      {
              listen  8888;
              client_header_buffer_size 16k;
              large_client_header_buffers 4 32k;
              client_max_body_size 300m;
              client_body_buffer_size 128k;

         location /group1/M00 {                                                                                                                       
               root /run/fast/storag;                                                                                                                 
               ngx_fastdfs_module;                                                                                                                    
         } 

         location / {
             root               /run/fast/storage;
             index               index.php;

             proxy_connect_timeout 3000;
             proxy_send_timeout 3000;
#            proxy_set_header Connection "";
             proxy_read_timeout 3000;
             proxy_buffer_size 4k;
             proxy_buffers 4 32k;
             proxy_busy_buffers_size 64k;
             if (!-e $request_filename) {
               rewrite ^/index.php(.*)$ /index.php?s=$1 last;
               rewrite ^(.*)$ /index.php?s=$1 last;
               break;}

                }

              location ~ \.php$ {
                        root           /run/fast/storage;
                        fastcgi_pass   127.0.0.1:9000;
                        fastcgi_index  spp.php;
                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                        include        fastcgi_params;
                               }

      }

猜你喜欢

转载自blog.csdn.net/Linux_newbie_rookie/article/details/79061886