搭建 lsky Pro Free 2.0

更新系统包列表

sudo apt update && sudo apt upgrade -y

lsky Pro Free2.0 项目地址 lsky-org/lsky-pro: ☁️兰空图床(Lsky Pro) – Your photo album on the cloud.

创建站点目录

mkdir lsky
cd lsky

下载压缩包并解压

wget https://github.com/lsky-org/lsky-pro/releases/download/2.1/lsky-pro-2.1.zip
unzip lsky-pro-2.1.zip 
cd

创建网站目录

sudo mkdir -p /home/wwwroot/

移动 lsky 到 /home/wwwroot/ 下

sudo mv lsky /home/wwwroot/

设置用户/组为 www-data 和 755 权限

sudo chown -R www-data:www-data /home/wwwroot/lsky/
sudo chmod -R 755 /home/wwwroot/lsky/

创建Nginx配置文件

sudo nano /etc/nginx/sites-available/lsky.conf

粘贴以下内容 (根据自己的需求修改和设置)

server {
listen 80;
server_name www.domain.com;
root /home/wwwroot/lsky/public;
index index.php index.html;
# 伪静态规则( 以LskyPro文档为准 )
location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.2-fpm-lsky.sock;  # 确认PHP版本并且自定义PHP-FPM 池 关闭防跨站攻击
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.(?!well-known).* {
    deny all;
}

}

为 lsky 开启 HTTPS

sudo certbot --nginx -d www.domain.com

在lsky中添加

ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache    shared:SSL:10m;
ssl_session_timeout  1d;
ssl_ciphers          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers on;

创建符号链接到 sites-enabled

sudo ln -s /etc/nginx/sites-available/lsky.conf /etc/nginx/sites-enabled/

通过 PHP-FPM 池配置 关闭防跨站攻击

# 创建使用新的PHP-FPM配置 我比较懒直接CP默认的稍作修改
sudo cp /etc/php/8.2/fpm/pool.d/www.conf /etc/php/8.2/fpm/pool.d/lsky.conf
sudo nano /etc/php/8.2/fpm/pool.d/lsky.conf

以下是一个简单的示例

[lsky] # 随意设置 自己能区分即可
user = www-data
group = www-data
listen = /run/php/php8.2-fpm-lsky.sock

; 取消 open_basedir 限制(设置为 none)
php_admin_value[open_basedir] = none

; 其他必要配置(如进程管理、资源限制等)
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

检查是Nginx和自定义PHP池是否存在错误

sudo php-fpm8.2 -t
sudo nginx -t

启用配置并重启服务

sudo nginx -s reload
sudo systemctl restart nginx php8.2-fpm

为lsky创建数据库

CREATE DATABASE lsky CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

创建用户并设置密码

CREATE USER 'lsky'@'localhost' IDENTIFIED BY 'Password123!';

授予用户权限

GRANT ALL PRIVILEGES ON lsky.* TO 'lsky'@'localhost';

刷新权限

FLUSH PRIVILEGES;

退出 MySQL 控制台

EXIT;
赞(0)
未经允许不得转载:一点孩子气 » 搭建 lsky Pro Free 2.0

登录

找回密码

注册