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

  1. <dependency>
  2. <groupId>net.oschina.zcx7878</groupId>
  3. <artifactId>fastdfs-client-java</artifactId>
  4. <version>1.27.0.0</version>
  5. </dependency>
  1. //客户端配置文件
  2. String conf_filename = "fdfs_client.conf";
  3. //本地文件,要上传的文件
  4. String local_filename = "C:\\Users\\86185\\Desktop\\002.jpg";
  5. try {
  6. ClientGlobal.init(conf_filename);
  7. //注册中心客户端,服务器
  8. TrackerClient trackerClient = new TrackerClient();
  9. TrackerServer trackerServer = trackerClient.getConnection();
  10. //实际保存文件客户端,服务器
  11. StorageServer storageServer = null;
  12. StorageClient storageClient = new StorageClient(trackerServer, storageServer);
  13. String[] fileIds = storageClient.upload_file(local_filename, "jpg", null);
  14. System.out.println(fileIds[0]);
  15. System.out.println(fileIds[1]);
  16. //关闭资源
  17. trackerServer.close();
  18. } catch (IOException e) {
  19. e.printStackTrace();
  20. } catch (MyException e) {
  21. e.printStackTrace();
  22. }