安装参考https://www.cnblogs.com/handsomeye/p/9451568.html
nginx安装
下载:在什么目录下执行下面的命令则下载到什么目录
cd /opt/work 切换到指定目录中
wget http://nginx.org/download/nginx-1.10.0.tar.gz 下载nginx
tar -zxvf nginx-1.10.0.tar.gz 解压2.2 安装依赖项
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel 安装依赖项
2.3 配置Nginx安装选项
这里只配置安装到/opt/work目录下,其它选项可执行./configuration –help查看
cd /opt/work/nginx-1.10.0 跳转到解压后的目录
./configure --prefix=/opt/work/nginx --sbin-path=/usr/bin/nginx 配置安装属 配置安装属装性
2.4 编译并安装
make && make install
2.6 启动、停止、重启
下面可以使用 nginx 是因为在/ usr/bin 中有 nginx 指令 命令:
nginx 启动nginx
ps -ef | grep nginx
可通过ps -ef | grep nginx查看nginx是否已启动成功
nginx -s reload 重新启动
nginx -s stop 停止nginx
最后整比较坑,一直配不上然后参考这边
https://msd.misuland.com/pd/2884250034537239310
最后
./configure --prefix=/opt/work/nginx --sbin-path=/usr/bin/nginx --add-module=../fastdfs-nginx-module-master/src
终于把配置打上去了
fastDFS工具类
package com.sy.tool;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.UUID;
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:")) {
conf = conf.replace("classpath:", this.getClass().getResource("/").getPath());
}
ClientGlobal.init(conf);
trackerClient = new TrackerClient();
trackerServer = trackerClient.getConnection();
storageServer = null;
storageClient = new StorageClient1(trackerServer, storageServer);
}
/**
* 上传文件方法
* <p>Title: uploadFile</p>
* <p>Description: </p>
* @param fileName 文件全路径
* @param extName 文件扩展名,不包含(.)
* @param metas 文件扩展信息
* @return
* @throws Exception
*/
public String uploadFile(String fileName, String extName, NameValuePair[] metas) throws Exception {
String result = storageClient.upload_file1(fileName, extName, metas);
return result;
}
public String uploadFile(String fileName) throws Exception {
return uploadFile(fileName, null, null);
}
public String uploadFile(String fileName, String extName) throws Exception {
return uploadFile(fileName, extName, null);
}
/**
* 上传文件方法
* <p>Title: uploadFile</p>
* <p>Description: </p>
* @param fileContent 文件的内容,字节数组
* @param extName 文件扩展名
* @param metas 文件扩展信息
* @return
* @throws Exception
*/
public String uploadFile(byte[] fileContent, String extName, NameValuePair[] metas) throws Exception {
String result = storageClient.upload_file1(fileContent, extName, metas);
return result;
}
public String uploadFile(byte[] fileContent) throws Exception {
return uploadFile(fileContent, null, null);
}
public String uploadFile(byte[] fileContent, String extName) throws Exception {
return uploadFile(fileContent, extName, null);
}
//***************以下为自己新增***********************************************************
/**
* 下载文件到本地 张然
* @param b
* @param path
* @param fileName
*/
//将字节流写到磁盘生成文件
private void saveFile(byte[] b, String path, String fileName) {
File file = new File(path+fileName);
FileOutputStream fileOutputStream = null;
try {
fileOutputStream= new FileOutputStream(file);
fileOutputStream.write(b);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(fileOutputStream!=null){
try {
fileOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* 下载文件 张然
* @param group
* @param pathAndFilename
*/
public void downloadFile(String group,String pathAndFilename) {
try {
byte[] b = storageClient.download_file(group,
pathAndFilename);
String ext ="."+ pathAndFilename.split("\\.")[1];
if(b !=null){
System.out.println(b.length);
saveFile(b, "E:/FASTDFS_download/", UUID.randomUUID().toString()+ext);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 删除 文件 张然
* @param group
* @param pathAndFilename
*/
public void deleteFile(String group,String pathAndFilename){
try {
int i = storageClient.delete_file(group, pathAndFilename);
System.out.println( i==0 ? "删除成功" : "删除失败:"+i);
} catch (Exception e) {
e.printStackTrace();
}
}
}