FTP的搭建过程,以及遇到的坑
在之前的博客中,我有说到,我最喜欢用Yum在线安装的方式安装软件,简单省事儿。现在看来,也不尽然,关键是,无法快速找到我要的文件,整个whereis 也很累。所以,现在觉得,还是乖乖的整个压缩包,自行安装比较和我心意。
首先,要用到的压缩包列表:
安装步骤概况:
1,安装运行环境包libevent工具包
2,安装libfastcommon工具包
3,安装Tracker服务
4,安装storage服务
5,安装Nginx提供HTTP服务
5.1,需要重新编译Nginx,所以需要处理fastdfs-nginx-module插件(简单)
详细安装步骤:
友情提示:最好是把需要的压缩包聚集到一个目录下,然后解压的时候,在一个自己知道的地方,没什么别的意思或者深意,只是为了自己方便找一些文件,然后操作文件的时候快一点。(你要是写半天的cp或者rm,结果发现写不出目录,就呵 呵影响心情了)
1,安装运行环境包libevent工具包
这一步是极其简单粗暴的,一行命令:yum -y install libevent
2,安装libfastcommon工具包
1, 解压缩: tar -zxvf 压缩包所在位置
2, ./make.sh
3, ./make.sh install
4, 把/usr/lib64/libfastcommon.so文件向/usr/lib/下复制一份
备注:编译安装的时候,注意一下当前所在文件的位置。 不跟我这个猴子派来的DB学习,当前,我可是在根目录下执行./make.sh,还傻傻闹不懂,为毛不成功
3,安装Tracker服务
2、./make.sh
3、./make.sh install
安装后在/usr/bin/目录下有以fdfs开头的文件都是编译出来的。
配置文件都放到/etc/fdfs文件夹
4、把/root/FastDFS/conf目录下的所有的配置文件都复制到/etc/fdfs下。
5、配置tracker服务。修改/root/FastDFS/conf/tracker.conf文件。
重启使用命令:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
4,安装storage服务
/usr/bin/fdfs_storaged/etc/fdfs/storage.confrestart
5,安装Nginx提供HTTP服务
./configure \
--prefix=/var /nginx \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/nginx/client\
--http-proxy-temp-path=/var/nginx/proxy\
--http-fastcgi-temp-path=/var/nginx/fastcgi\
--http-uwsgi-temp-path=/var/nginx/uwsgi\
--http-scgi-temp-path=/var/nginx/scgi\
--add-module=/usr/local/fastdfs-nginx-module/src
附录:最开始的config配置
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
4、make
5、makeinstall
6、把/root/fastdfs-nginx-module/src/mod_fastdfs.conf文件复制到/etc/fdfs目录下。编辑四个地方:1,base_path=/tmp(日志存放路径) 2,tracker_server=IP:22122(tracker服务器地址) 3,url_have_group_name=true 4,store_path0=/home/fastdfs/storage
(图片保存路径,注意和storage服务配置相对应)
7、配置nginx
在nginx的配置文件中添加一个Server:
server {
listen 80;
server_name 192.168.101.3; location /group1/M00/{
#root /home/FastDFS/fdfs_storage/data;
ngx_fastdfs_module;
}
}
8、将libfdfsclient.so拷贝至/usr/lib下
cp/usr/lib64/libfdfsclient.so /usr/lib/
9、启动nginx
附:使用的基本代码
1,FastDFSClient
package taotao.utils; import org.csource.common.NameValuePair;
import org.csource.fastdfs.*;
/**
* Created by Angelina on 2017/6/7.
*/
public class FastDFSClient { private TrackerClient trackerClient = null;
private TrackerServer trackerServer = null;
private StorageServer storageServer = null;
private StorageClient1 storageClient = null; public FastDFSClient(String conf) throws Exception { if (conf.contains("classpath:")) {
String url = this.getClass().getResource("/").getPath();
url = url.substring(1);
conf = conf.replace("classpath:", url);
}
ClientGlobal.init(conf);
trackerClient = new TrackerClient();
trackerServer = trackerClient.getConnection();
storageServer = null;
storageClient = new StorageClient1(trackerServer, storageServer);
} public String uploadFile(String fileName, String extName, NameValuePair[] metas) throws Exception {
return storageClient.upload_file1(fileName, extName, metas);
}
public String uploadFile(String fileName, String extName) throws Exception {
return storageClient.upload_file1(fileName, extName, null);
} public String uploadFile(String fileName) throws Exception {
return storageClient.upload_file1(fileName, null, null);
} public String uploadFile(byte[] fileContent, String extName, NameValuePair[] metas) throws Exception {
return storageClient.upload_file1(fileContent, extName, metas);
} public String uploadFile(byte[] fileContent, String extName) throws Exception {
return storageClient.upload_file1(fileContent, extName, null);
} public String uploadFile(byte[] fileContent) throws Exception {
return storageClient.upload_file1(fileContent, null, null);
} }
2,应用实例
@Value("${IMAGE_SERVER_BASE_URL}")
private String IMAGE_SERVER_BASE_URL; @Override
public PictureResult uploadPic(MultipartFile picFile){
PictureResult result=new PictureResult();
//check the picture
if (picFile.isEmpty()){
result.setError(1);
result.setMessage("the file not found");
return result;
}
//upload the picture to the server
try{
//get the file's extension
String originalFilename=picFile.getOriginalFilename();
String extName=originalFilename.substring(originalFilename.lastIndexOf(".")+1);
FastDFSClient client=new FastDFSClient("classpath:properties/client.conf");
String url=client.uploadFile(picFile.getBytes(),extName);
//stitching the URL
url=IMAGE_SERVER_BASE_URL+url;
result.setError(0);
result.setUrl(url);
}catch(Exception e){
e.printStackTrace();
}
return result;
}
FTP的搭建过程,以及遇到的坑的更多相关文章
- FTP 的搭建过程和遇到的问题
http://linux.it.net.cn/e/server/ftp/2015/0227/13554.htmlhttps://mp.weixin.qq.com/s?__biz=MzA3OTgyMDc ...
- 【Mysql】Mysql主从库搭建过程(爬完坑后整理所得)
Mysql主从数据库搭建流程 新手开始学习mysql主从库,遇到一些问题,总结后写出以下流程 下面以5.7.23版本为例介绍 第一步:去官网下载5.7.23版本的免安装压缩包形式的mysql文件,贴上 ...
- 记一次ftp服务器搭建走过的坑
记一次ftp服务器搭建走过的坑 1.安装 ①下载 wget https://security.appspot.com/downloads/vsftpd-3.0.3.tar.gz #要FQ ②解压 ta ...
- Ftp站点搭建的详细过程(包括指定用户登录)
最近接到要部署一个Ftp站点的一个任务,然后过程中有点小插曲踩了一些坑(指定用户登录,用户名和密码都是对的,输入了超级多遍,还是不行,登录不上,后面详细说明解决方案),特此记录一下.避免大家踩坑. 参 ...
- Centos7搭建FTP服务详细过程
Centos7搭建FTP服务详细过程https://blog.csdn.net/sinat_30802291/article/details/81706152
- FTP服务器搭建及操作(一)
FTP服务器搭建及操作(一) FTP搭建 PHP FTP操作 搭建方法参照(windows):http://www.cnblogs.com/lidan/archive/2012/06/04/25351 ...
- FTP-Linux中ftp服务器搭建
一.FTP工作原理 (1)FTP使用端口 [root@localhost ~]# cat /etc/services | grep ftp ftp-data 20/tcp #数据链路:端口20 ftp ...
- ftp&nginx搭建图片服务器
下面使用ftp+nginx搭建一个简单的服务器 ftp用于文件的传输 nginx提供http服务 nginx服务器的安装和配置可以参照之前的教程:nginx安装及其配置详细教程 下面介绍ftp服务的安 ...
- VS2017 + EF + MySQL 我使用过程中遇到的坑
原文:VS2017 + EF + MySQL 我使用过程中遇到的坑 写在前面: 第一次使用MySQL连接VS的时候本着最新版的应该就是最好的,在MySQL官网下载了最新版的MySQL没有并且安装完成之 ...
随机推荐
- python读xml文件
# -*- coding:utf-8 -*- import jsonimport requestsimport os curpath=os.path.dirname(os.path.realpath( ...
- Tomcat控制台乱码问题
乱码效果图 解决办法 1.修改cmd的编码格式 快捷键win+R打开运行程序,输入regedit打开注册表,找到以下路劲并且修改. [HKEY_LOCAL_MACHINE\SOFTWARE\Micro ...
- 洛谷 P3313 [SDOI2014]旅行
题目描述 S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天面条神教.隐形独角兽教.绝地教都是常见的信仰. 为了方便,我 ...
- Android(java)学习笔记108:Android的Junit调试
1. Android的Junit调试: 编写android应用的时候,往往我们需要编写一些业务逻辑实现类,但是我们可能不能明确这个业务逻辑是否可以成功实现,特别是逻辑代码体十分巨大的时候,我们不可能一 ...
- php有哪些优化技巧
1. echo 比 print 快.2. 使用echo的多重参数代替字符串连接.3. 在执行for循环之前确定最大循环数,不要每循环一次都计算最大值,最好运用foreach代替.4. 对global变 ...
- Python 生成器和协程
Python3 迭代器与生成器 迭代器 迭代是Python最强大的功能之一,是访问集合元素的一种方式. 迭代器是一个可以记住遍历的位置的对象. 迭代器对象从集合的第一个元素开始访问,直到所有的元素被访 ...
- Luogu [P3951] 小凯的疑惑
题目详见:[P3951]小凯的疑惑 首先说明:此题为一道提高组的题.但其实代码并没有提高组的水平.主要考的是我们的推断能力,以及看到题后的分析能力. 分析如下: 证明当k>ab-a-b时,小凯可 ...
- 使用struts2实现文件上传与下载功能
这个问题做了两天,在网上找了很多例子,但是还有一些功能没有实现,暂时先把代码贴出来,以后在做这方面的功能时在修改 文件上传: 一开始我在网上找到基于servlet+jsp环境写的文件上传,但是在将页面 ...
- C#4.0中的dynamic关键字和ExpandoObject对象
dynamic最大的特点我想莫过于在它的类型在运行时才确定,这也是它与往静态类型关键字的最大区别.如果你在你的代码操作中用到了dynamic关键字去定义一个变量时,那么这个变量在编译的时候编译器不会对 ...
- 解决升级mac os X EI Capitan后遇到LibclangError: dlopen(libclang.dylib, 6): image not found.的问题
打开文件./frameworks/cocos2d-x/tools/bindings-generator/clang/cindex.py 把第 3395 行 改为 : library = cdll.Lo ...