一个外观漂亮、易于使用的照片管理系统。上传、管理和共用来自本地应用程式的照片。

1、实现条件:

  • 安装Nginx (或者其他网页伺服器)
  • 安装PHP
  • MySql (这里是MariaDB)

参考这篇文章:赚钱宝2代安装lnmp

2、下载lychee相册文件:

cd /media/sda/www/

wget https://github.com/electerious/Lychee/archive/refs/tags/v3.1.6.tar.gz && tar xzv -f v3.1.6.tar.gz && mv Lychee-3.1.6/ lychee &&rm -rf  v3.1.6.tar.gz&&chown www-data:www-data -R ./lychee/

3、Nginx的lychee配置:

修改nano /etc/nginx/site-enabled/default文件。

4、启动Nginx服务

systemctl restart nginx

在浏览器中打开http://IP设置数据库等相关信息

添加权限:

chmod 777 /mnt/sda/www/html/lychee/data

chmod 777 /mnt/sda/www/html/lychee/uploads

5、完成安装

在浏览器中打开http://IP

注意:在上传照片的过程中出现了如下问题:

1、解决Request entity too large问题

参考网址:https://www.cnblogs.com/wangyuehan/p/10740810.html

根据经验判断应该是上传文件大小被限制了,检查了应用配置是10M,把它设置成100M,重启服务也不能解决问题。

原来我们的tomcat是通过nginx发现服务代理的,问题就出现nginx服务器上,原来nginx默认长传文件的大小是1M,可在nginx的配置中修改。

解决方法:

  • 1、打开nginx服务的配置文件nginx.conf, 路径一般是:/etc/nginx/nginx.conf。
  • 2、在http{}中加入client_max_body_size 100m,我这里配置的是100M。
    http {

client_max_body_size 100m;

include       mime.types;

default_type  application/octet-stream;

  • 3、重新nginx服务。

另外php.ini也限制的http上传文件的大小!参考:https://jingyan.baidu.com/article/4853e1e5bc96af1909f7269e.html

nano /etc/php/7.3/fpm/php.ini

upload_max_filesize = 2M改为upload_max_filesize = 100M

systemctl restart php7.3-fpm

2、the server responded with a status of 504 (Gateway Time-out)

解决方法:

ngixn反向代理上传文件时间较长浏览器报错Failed to load resource: the server responded with a status of 504 (Gateway Time-out)修改/etc/nginx/nginx.conf文件:

我针对某个接口设置了超时设置 proxy_send_timeout 600s;proxy_send_timeout 600s; proxy_read_timeout 600s;  三个属性,都设置为10分钟超时

http {

   client_max_body_size 50M;
   proxy_read_timeout 300;
   proxy_connect_timeout 300;
   proxy_send_timeout 300;

}

调整PHP配置

检查并调整PHP的配置文件(通常是php.ini):

  • upload_max_filesize:允许上传的最大文件大小。
  • post_max_size:POST数据的最大大小,包括文件上传。
  • max_execution_time:脚本允许的最大执行时间(秒)。
  • max_input_time:脚本允许的最大输入时间(秒)。

例如:

upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 300
max_input_time = 300

重启php服务

systemctl restart php7.3-fpm

标签: none

添加新评论