632 字
3 分钟
宝塔面板 Pixelfed 部署指南:图文详解,快速搭建你的去中心化社交网络
2024-03-22

官方文档
https://docs.pixelfed.org/running-pixelfed/installation.html

先决条件
apache nginx
php8.1
mysql5.7
redis7

宝塔面板里这些都可以提前安装好

添加网站申请好SSL

禁中php函数
putenv
symlink()
proc_open
pcntl_signal

ssh连后cd网站目录 以下命令拉仓库

git clone -b dev https://github.com/pixelfed/pixelfed.git pixelfed

拉取上一个版本(可选)最新的版本有很多BUG v0.11.12是版本号可以在作者github查看

git clone -b v0.11.12 https://github.com/pixelfed/pixelfed.git pixelfed

给用户和目录权限

cd pixelfed
sudo chown -R www:www .
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;

提前安装好composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer

以下命令会自动安装需要的依赖

composer install --no-ansi --no-interaction --optimize-autoloader

官司文档里,让复制.env.example改名.env

cp .env.example .env

但是最新版没有这个档案
从这里复制.env.example全部内容替换.env里的全部内容
https://github.com/pixelfed/pixelfed/blob/v0.11.12/.env.example
将数据库 域名 redis的密码都配置好后 执行以下命令

生成APP_KEY

php artisan key:generate

链接到应用程序目录

php artisan storage:link

导入数据库

php artisan migrate --force

启用对位置数据的支持

php artisan import:cities

如果在.env里启用了ActivityPub

php artisan instance:actor

如果在.env启用了 OAuth

php artisan passport:keys

缓存路由

php artisan route:cache
php artisan view:cache

每次改.env需要执行一次

php artisan config:cache

编辑网站配置文件将目录后面加上/public

这个时候应该是可以通过域名访问网站了 注册一个帐户先
用以下命令提升帐号为管理员

php artisan user:admin 帐号
php artisan horizon:install
php artisan horizon:publish

以下二选一
1.去这个目录
/etc/systemd/system/
添加新建档案pixelfed.service
复制以下内容粘上

[Unit]
Description=Pixelfed task queueing via Laravel Horizon
After=network.target
Requires=mysqld.service
Requires=php-fpm-81.service
Requires=redis.service
Requires=httpd.service
[Service]
Type=simple
ExecStart=/usr/bin/php /www/wwwroot/你的域名/pixelfed/artisan horizon
User=www
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo -u www /usr/bin/php /www/wwwroot/你的域名/pixelfed/artisan horizon
sudo systemctl daemon-reload
sudo systemctl start pixelfed
sudo systemctl status pixelfed
sudo systemctl enable --now pixelfed

2.安装Supervisor
Name填pixefled
Run User选www
Start command填

php artisan horizon

Process directory选网站目录/www/wwwroot/域名pixelfed
Processes填 1
保存

运行

php artisan package:discoveror
composer install

然后运行

php artisan horizon:install
php artisan route:cache

最差最后一步 二选一
1

crontab -e

最后一行添加

* * * * * /usr/bin/php /www/wwwroot/你的域名/pixelfed/artisan schedule:run >> /dev/null 2>&1

保存后选择以下命令来确认

crontab -l

2宝塔面板添加计划任务

/usr/bin/php /www/wwwroot/域名/pixelfed/artisan schedule:run

设定每1分钟运行一次

到此结束

关于更新

cd /pixelfed 安装目录
git reset --hard HEAD
git pull origin dev
composer install
php artisan config:cache
php artisan route:cache
php artisan migrate --force

清除配置缓存

php artisan config:clear

清除应用缓存

php artisan cache:clear

重启 Redis 服务(确保 Redis 配置正确)

systemctl restart redis
宝塔面板 Pixelfed 部署指南:图文详解,快速搭建你的去中心化社交网络
https://blog.wlens.top/posts/pixelfed在宝塔环境下部署笔记/
作者
Lao Wang
发布于
2024-03-22
许可协议
CC BY-NC-SA 4.0