Lycheev4图床的安装方法。
最后更新于:2021-04-15 17:43:20
宝塔面板安装lychee v4图床的方法
lychee是一款非常不错的图床,但是在使用宝塔安装过程中进入不少误区。
要求服务器配置如下:
-
- Web服务器,例如Apache或Nginx
- 数据库-使用以下之一:
- MySQL (版本> 5.7.8) / MariaDB (版本> 10.2)、
PHP >= 7.4 具有以下PHP扩展名:
-
- BCMath
- Ctype
- Exif
- Ffmpeg (optional — to generate video thumbnails)
- Fileinfo
- GD
- Imagick (optional — to generate better thumbnails)
- JSON
- Mbstring
- OpenSSL
- PDO
- Tokenizer
- XML
- ZIP
首先要在php设置中删除默认禁止的函数
- exec
- putenv
且安装一下扩展
- fileinfo
- imagemagick
- exif
设置好后建立网站,利用ssh连接服务器使用以下命令
下载源码至网站根目录
git clone https://www.github.com/LycheeOrg/Lychee /var/www/html/Lychee
进入目录:
cd /www/wwwroot/lychee.com
安装所需的依赖项:
composer install --no-dev
安装完依赖后,调整站点所属用户组改为:www
设置站点运行目录为public
这里给出lychee给出的Nginx示例配置
server {
listen 80;
server_name .;
##### Path to the Lychee public/ directory.
root /var/www/lychee/public/;
# If the request is not for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# Serve /index.php through PHP
location = /index.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
######### Make sure this is the correct socket for your system
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "post_max_size=100M
max_execution_time=200
upload_max_filesize=30M
memory_limit=300M";
fastcgi_param PATH /usr/local/bin:/usr/bin:/bin;
include fastcgi_params;
}
# Deny access to other .php files, rather than exposing their contents
location ~ [^/]\.php(/|$) {
return 403;
}
# [Optional] Lychee-specific logs
error_log /var/log/nginx/lychee.error.log;
access_log /var/log/nginx/lychee.access.log;
# [Optional] Remove trailing slashes from requests (prevents SEO duplicate content issues)
rewrite ^/(.+)/$ /$1 permanent;
}
在宝塔中这些配置已经有了,其中lychee默认是需要隐藏index.php,把以下代码加入伪静态
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
输入你的域名访问,进行可视化安装,连接数据库默认为设置如下:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ID
DB_USERNAME=user
DB_PASSWORD=pass