首页 > 代码库 > FastDFS+nginx+php的完整应用[转储]
FastDFS+nginx+php的完整应用[转储]
view sourceprint?
1.
[root@varnish ~]
# tar xf libevent-2.0.21-stable.tar.gz
2.
[root@varnish ~]
# cd libevent-2.0.21-stable
3.
[root@varnish libevent-2.0.21-stable]
# ./configure --prefix=/usr/local/libevent
4.
[root@varnish libevent-2.0.21-stable]
# make
5.
[root@varnish libevent-2.0.21-stable]
# make install
6.
[root@varnish libevent-2.0.21-stable]
# echo ‘/usr/local/libevent/include/‘ >> /etc/ld.so.conf
7.
[root@varnish libevent-2.0.21-stable]
# echo ‘/usr/local/libevent/lib/‘ >> /etc/ld.so.conf
8.
[root@varnish libevent-2.0.21-stable]
# ldconfig
view sourceprint?
1.
[root@varnish ~]
# tar xf FastDFS_v4.07.tar.gz
2.
[root@varnish ~]
# cd FastDFS
3.
[root@varnish FastDFS]
# ./make.sh C_INCLUDE_PATH=/usr/local/libevent/include/ LIBRARY_PATH=/usr/local/libevent/lib/
4.
[root@varnish FastDFS]
# ./make.sh install
5.
[root@varnish FastDFS]
# ls /etc/fdfs/
6.
client.conf http.conf mime.types storage.conf tracker.conf
view sourceprint?
1.
[root@varnish ~]
# vim /etc/fdfs/tracker.conf
2.
bind_addr= 改为 bind_addr=192.168.25.204
3.
base_path=/home/yuqing/fastdfs 改为 base_path=/data/fastdfs
4.
http.server_port=8080 改为 http.server_port=80
view sourceprint?
1.
[root@varnish ~]
# mkdir -p /data/fastdfs
2.
启动tracker server
3.
[root@varnish ~]
# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
view sourceprint?
1.
修改storage server的配置文件:
2.
[root@web2 ~]
# vim /etc/fdfs/storage.conf
3.
bind_addr= 改为 bind_addr=192.168.25.207
4.
base_path=/home/yuqing/fastdfs 改为 base_path=/data/fastdfs
5.
store_path0=/home/yuqing/fastdfs 改为 store_path0=/data/fastdfs
6.
tracker_server=192.168.209.121:22122 改为 tracker_server=192.168.25.204:22122
7.
http.server_port=8888 改为 http.server_port=80
view sourceprint?
1.
[root@varnish ~]
# vim /etc/fdfs/client.conf
2.
base_path=/home/yuqing/fastdfs 改为 base_path=/data/fastdfs
3.
tracker_server=192.168.0.197:22122
4.
改为
5.
tracker_server=192.168.25.204:22122
view sourceprint?
1.
[root@web2 ~]
# tar xf fastdfs-nginx-module_v1.15.tar.gz
2.
[root@web2 ~]
# cd fastdfs-nginx-module
view sourceprint?
01.
[root@web2 ~]
# tar xf nginx-1.4.1.tar.gz
02.
[root@web2 ~]
# cd nginx-1.4.1
03.
[root@web2 nginx-1.4.1]
# ./configure \
04.
&
gt
; --prefix=/usr \
05.
&
gt
; --sbin-path=/usr/sbin/nginx \
06.
&
gt
; --conf-path=/etc/nginx/nginx.conf \
07.
&
gt
; --error-log-path=/var/log/nginx/error.log \
08.
&
gt
; --http-log-path=/var/log/nginx/access.log \
09.
&
gt
; --pid-path=/var/run/nginx/nginx.pid \
10.
&
gt
; --lock-path=/var/lock/nginx.lock \
11.
&
gt
; --user=nginx \
12.
&
gt
; --group=nginx \
13.
&
gt
; --with-http_ssl_module \
14.
&
gt
; --with-http_flv_module \
15.
&
gt
; --with-http_stub_status_module \
16.
&
gt
; --with-http_gzip_static_module \
17.
&
gt
; --http-client-body-temp-path=/var/tmp/nginx/client/ \
18.
&
gt
; --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
19.
&
gt
; --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
20.
&
gt
; --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
21.
&
gt
; --http-scgi-temp-path=/var/tmp/nginx/scgi \
22.
&
gt
; --with-pcre \
23.
&
gt
; --add-module=/root/fastdfs-nginx-module/src
24.
[root@web2 nginx-1.4.1]
# make
25.
[root@web2 nginx-1.4.1]
# make install
view sourceprint?
1.
[root@web2 ~]
# cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
2.
[root@web2 ~]
# vim /etc/fdfs/mod_fastdfs.conf
3.
base_path=/tmp 改为 base_path=/data/fastdfs
4.
tracker_server=tracker:22122 改为 tracker_server=192.168.25.204:22122
5.
store_path0=/home/yuqing/fastdfs 改为 store_path0=/data/fastdfs
view sourceprint?
01.
[root@web2 ~]
# vim /etc/nginx/nginx.conf
02.
在server段添加如下内容:
03.
location /group1/M00{
04.
alias
/data/fastdfs/data;
05.
ngx_fastdfs_module;
06.
}
07.
[root@web2 ~]
# /usr/sbin/nginx -t
08.
ngx_http_fastdfs_set pid=28145
09.
nginx: the configuration
file
/etc/nginx/nginx.conf syntax is ok
10.
nginx: configuration
file
/etc/nginx/nginx.conf
test
is successful
11.
[root@web2 ~]
# /usr/sbin/nginx
12.
ngx_http_fastdfs_set pid=28148
view sourceprint?
1.
修改nginx的配置文件
2.
[root@web2 ~]
# vim /etc/nginx/nginx.conf
3.
location /M00{
4.
alias
/data/fastdfs/data;
5.
ngx_fastdfs_module;
6.
}
view sourceprint?
1.
之后重启服务
2.
[root@web2 ~]
# /usr/sbin/nginx -s stop
3.
ngx_http_fastdfs_set pid=28947
4.
[root@web2 ~]
# /usr/sbin/nginx
5.
ngx_http_fastdfs_set pid=28948
view sourceprint?
1.
我们把nginx的配置文件修改回来
2.
location /group1/M00{
3.
alias
/data/fastdfs/data;
4.
ngx_fastdfs_module;
5.
}
view sourceprint?
1.
[root@web2 ~]
# vim /etc/fdfs/mod_fastdfs.conf
2.
url_have_group_name =
false
改为
true
#关于啥意思,配置文件中有解释
view sourceprint?
01.
[root@web1 ~]
# cd /root/FastDFS/php_client
02.
[root@web1 php_client]
# /usr/local/php/bin/phpize
03.
Configuring
for
:
04.
PHP Api Version: 20090626
05.
Zend Module Api No: 20090626
06.
Zend Extension Api No: 220090626
07.
[root@web1 php_client]
# ./configure --with-php-config=/usr/local/php/bin/php-config
08.
[root@web1 php_client]
# make && make install
09.
[root@web1 php_client]
# cat fastdfs_client.ini >> /usr/local/php/etc/p
10.
pear.conf php-fpm.conf php-fpm.conf.default
11.
[root@web1 php_client]
# cat fastdfs_client.ini >> /etc/php.ini
view sourceprint?
1.
[root@web1 php_client]
# /usr/local/php/bin/php -m | grep fastdfs_client
2.
fastdfs_client
#说明模块已加载 www.it165.net
3.
4.
重新加载php
5.
[root@web1 php_client]
# service php-fpm reload
view sourceprint?
1.
tracker_server=192.168.25.204:22122
2.
http.tracker_server_port=80
3.
4.
重新加载php
5.
[root@web1 php_client]
# service php-fpm reload
view sourceprint?
1.
[root@web1 ~]
# echo "php client is here." > /opt/upload.txt
2.
[root@web1 ~]
# vim test.php
3.
&
lt
;?php
4.
var_dump(function_exists(‘fastdfs_storage_upload_by_filename‘));
5.
$ret = fastdfs_storage_upload_by_filename(‘/opt/upload.txt‘);
6.
var_dump($ret);
7.
?&
gt
;
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。