一、相关依赖
- PHP 8.2
- MySQL 5.7+
- KeyVal
- Nginx (any version)
二、安装组件
安装官方PHP包
pacman -S php php-fpm php-igbinary php-redis readline file c-ares postgresql-libs
php -m | grep -E 'redis|fileinfo|swoole|readline|event'
安装自有软件包,需要和版本一致
pacman -U php-event-3.1.4-1-x86_64.pkg.tar.zst php-openswoole-git-22.1.2.r76.g525c247b0-1-any.pkg.tar.zst
安装redis
pacman -S redis
开启插件并且检/查
/etc/php/php.in
extension=curl
extension=gd
extension=iconv
extension=mysqli
extension=pdo_mysql
extension=sockets
extension=zip
echo "extension=sockets" | sudo tee /etc/php/conf.d/20-sockets.ini
echo "extension=event" | sudo tee /etc/php/conf.d/30-event.ini
echo "extension=fileinfo" | sudo tee /etc/php/conf.d/20-fileinfo.ini
echo "extension=igbinary" | sudo tee /etc/php/conf.d/20-igbinary.ini
php -m | grep -E 'redis|fileinfo|swoole|readline|event'
event
fileinfo
openswoole
readline
redis
安装mysql
pacman -U libmysqlclient80-8.0.42-1-x86_64.pkg.tar.zst mysql-clients80-8.0.42-1-x86_64.pkg.tar.zst mysql80-8.0.42-1-x86_64.pkg.tar.zst
安装nginx
pacman -S nginx
三、安装程序
# Enter site directory
cd /srv/http/xboard
# Clone repository
git clone https://github.com/cedar2025/Xboard.git ./
# Install dependencies
sh init.sh
四、安装主启动脚本
nano -w /etc/systemd/system/octane-xboard.service
[Unit]
Description=Laravel Octane (Swoole) - xboard
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/srv/http/xboard
# 可按需调整
Environment=APP_ENV=production
Environment=OCTANE_SERVER=swoole
Environment=OCTANE_HOST=0.0.0.0
Environment=OCTANE_PORT=7001
# 启动 / 重载 / 停止
ExecStart=/usr/bin/php artisan octane:start --server=${OCTANE_SERVER} --host=${OCTANE_HOST} --port=${OCTANE_PORT} --max-requests=500
ExecReload=/usr/bin/php artisan octane:reload
ExecStop=/usr/bin/php artisan octane:stop
# 保障项
Restart=always
RestartSec=3
TimeoutStopSec=60
KillSignal=SIGINT
LimitNOFILE=65535
# 生产环境通常不建议 --watch
# 若用 RoadRunner:把 OCTANE_SERVER 设为 roadrunner
[Install]
WantedBy=multi-user.target
五、安装计划任务
运行 Laravel 定时任务调度器
nano -w /etc/systemd/system/xboard-schedule.service
[Unit]
Description=XBoard Schedule Task Runner
After=network.target mysql.service
[Service]
Type=oneshot
User=root
Group=root
WorkingDirectory=/srv/http/xboard
ExecStart=/usr/bin/php artisan schedule:run
TimeoutStartSec=120
Environment=LANG=en_US.UTF-8
Environment=LC_ALL=en_US.UTF-8
StandardOutput=journal
StandardError=journal
SyslogIdentifier=xboard-schedule
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/srv/http/xboard/storage
ReadWritePaths=/srv/http/xboard/bootstrap/cache
nano -w xboard-schedule.timer
[Unit]
Description=Run XBoard Scheduled Tasks every minute
Requires=xboard-schedule.service
[Timer]
OnCalendar=*:*:00
Persistent=true
RandomizedDelaySec=10
[Install]
WantedBy=timers.target
启动 Laravel Horizon 队列管理器
nano -w /etc/systemd/system/xboard-horizon.service
[Unit]
Description=XBoard Horizon Queue Manager
After=network.target mysql.service redis.service
Wants=network.target
Requires=redis.service
[Service]
Type=simple
User=root
Group=root
Restart=always
RestartSec=5s
StartLimitInterval=60s
StartLimitBurst=3
WorkingDirectory=/srv/http/xboard
ExecStart=/usr/bin/php artisan horizon
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
KillSignal=SIGTERM
TimeoutStopSec=60
Environment=LANG=en_US.UTF-8
Environment=LC_ALL=en_US.UTF-8
StandardOutput=journal
StandardError=journal
SyslogIdentifier=xboard-horizon
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/srv/http/xboard/storage
ReadWritePaths=/srv/http/xboard/bootstrap/cache
[Install]
WantedBy=multi-user.target