1.启动tracker、storage、nginx服务:
启动fdfs_trackerd:sudo service fdfs_trackerd start
启动fdfs_storaged :sudo service fdfs_storaged start
启动Nginx:sudo /usr/local/nginx/sbin/nginx
注:此处给出重启服务的指令,需要时输入相关指令。
重启fdfs_trackerd :sudo service fdfs_trackerd restart
重启fdfs_storaged :sudo service fdfs_storaged restart
重启Nginx:sudo /usr/local/nginx/sbin/nginx -s stop (先关闭Nginx)
sudo /usr/local/nginx/sbin/nginx (然后重启Nginx)
2. 执行如下命令测试是否成功
指令:
fdfs_upload_file /etc/fdfs/client.conf 要上传的图片文件
如果返回类似group1/M00/00/00/rBIK6VcaP0aARXXvAAHrUgHEviQ394.jpg的文件id则说明文件上传成功
在浏览器中可以用 127.0.0.1:8888/返回的文件id
访问图片
3.使用python客户端上传测试
- workon dailyfresh
- 进入fdfs_client-py-master.zip所在目录
- pip install fdfs_client-py-master.zip
>>> from fdfs_client.client import Fdfs_client
>>> client = Fdfs_client('/etc/fdfs/client.conf')
>>> ret = client.upload_by_filename('test')
>>> ret
{'Group name':'group1','Status':'Upload successed.', 'Remote file_id':'group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.py','Uploaded size':'6.0KB','Local file name':'test', 'Storage IP':'192.168.243.133'}# 4. 项目上传图片和使用图片流程
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191022231738143.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ZhbnhpbmRvbmcwNjIw,size_16,color_FFFFFF,t_70)