Nginx
指令
- nginx -s stop – 快速的停止Nginx
- nginx -s quit – 优雅的停止Nginx
- nginx -s reload – 重载配置文件
- nginx -s reopen – 重新打开日志
注意
location /img/ {
alias /var/www/image/;
}
#若按照上述配置的话,则访问/img/目录里面的文件时,ningx会自动去/var/www/image/目录找文件
location /img/ {
root /var/www/image;
}
#若按照这种配置的话,则访问/img/目录下的文件时,nginx会去/var/www/image/img/目录下找文件。]
FastDFS
1、启动storaged
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
2、启动storaged
vi /etc/fdfs/storage.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
为什么要用FastDFS呢?
https://blog.csdn.net/ChengHuanHuaning/article/details/105340710
pom
<dependency>
<groupId>net.oschina.zcx7878</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.27.0.0</version>
</dependency>
//客户端配置文件
String conf_filename = "fdfs_client.conf";
//本地文件,要上传的文件
String local_filename = "C:\\Users\\86185\\Desktop\\002.jpg";
try {
ClientGlobal.init(conf_filename);
//注册中心客户端,服务器
TrackerClient trackerClient = new TrackerClient();
TrackerServer trackerServer = trackerClient.getConnection();
//实际保存文件客户端,服务器
StorageServer storageServer = null;
StorageClient storageClient = new StorageClient(trackerServer, storageServer);
String[] fileIds = storageClient.upload_file(local_filename, "jpg", null);
System.out.println(fileIds[0]);
System.out.println(fileIds[1]);
//关闭资源
trackerServer.close();
} catch (IOException e) {
e.printStackTrace();
} catch (MyException e) {
e.printStackTrace();
}