### Install Aliyun SMS package Source: https://github.com/lizhipay/acg-faka/blob/main/vendor/mrgoon/aliyun-sms/README.md Install the package via Composer. ```bash composer require mrgoon/aliyun-sms ``` -------------------------------- ### Render Installation Environment View Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html This function generates the HTML structure for the environment check page, including status pills, extension grids, and file system permission rows. It also binds event listeners for rechecking the environment and proceeding to the next step. ```javascript class="name">' + esc(t('env.php')) + ' ' + esc(php.version || '?') + '' + '
' + th('env.php.sub', {cur: php.version, min: php.min}) + '
' + pill(php.ok, php.ok ? 'env.status.ok' : 'env.status.low') + '' + '' + '

' + esc(t('env.group.ext')) + '

' + extKeys.filter(function (k) { return e.ext\[k\]; }).length + ' / ' + extKeys.length + '
' + '
' + extKeys.map(function (k) { return '
' + esc(k) + '' + (e.ext\[k\] ? 'check\_circle' : 'cancel') + '
'; }).join('') + '
' + '
' + '

' + esc(t('env.group.fs')) + '

' + fsKeys.map(function (k) { var w = e.writable\[k\]; return '
' + (w ? 'folder' : 'folder\_off') + '' + '
' + esc(k) + '/
' + esc(t('env.fs.' + k)) + '
' + pill(w, w ? 'env.status.ok' : 'env.status.unwritable') + '
'; }).join('') + '
' + (ok ? '' : renderFix(e)) + '
' + '' + '' + '' + '
'; swap(html, function (view) { view.querySelector('#next').addEventListener('click', function () { if (env.install) setStep(1); }); view.querySelector('#recheck').addEventListener('click', function () { recheck(true); }); bindCopy(view); if (!ok) pollTimer = setInterval(function () { recheck(false); }, POLL\_S \* 1000); }); } ``` -------------------------------- ### Render Fix Suggestions Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html Generates HTML for fixing environment issues, including CLI commands for installing missing PHP extensions or setting file permissions. ```javascript function renderFix(e) { var items = \[\]; var php = e.php || {}; if (!php.ok) { items.push('
' + esc(t('env.php')) + '

' + th('env.fix.php', {cur: php.version, min: php.min}) + '

'); } var missing = e.missing || \[\]; if (missing.length) { var apt = 'apt install ' + missing.map(function (m) { return 'php8.2-' + m.replace('pdo\_mysql', 'mysql').replace('pdo', 'mysql'); }).filter(function (v, i, a) { return a.indexOf(v) === i; }).join(' '); var yum = 'yum install ' + missing.map(function (m) { return 'php-' + m.replace('pdo\_mysql', 'mysqlnd').replace('pdo', 'pdo'); }).filter(function (v, i, a) { return a.indexOf(v) === i; }).join(' '); var dk = 'docker-php-ext-install ' + missing.join(' '); items.push('
' + th('env.fix.ext', {list: missing.join(', ')}) + '' + '

' + esc(t('env.fix.ext.bt')) + '

' + cmd(t('env.fix.ext.cli'), apt) + cmd('', yum) + cmd(t('env.fix.ext.docker'), dk) + '

' + esc(t('env.fix.ext.restart')) + '

'); } var unw = e.unwritable || \[\]; if (unw.length) { items.push('
' + th('env.fix.fs', {list: unw.join(', ')}) + '

' + esc(t('env.fix.fs.desc')) + '

' + cmd('', 'chown -R www:www ' + '/path/to/site' + ' && chmod -R 755 ' + '/path/to/site') + '
'); } return '

' + esc(t('env.fix.title')) + '

' + items.join('') + '
'; } ``` -------------------------------- ### 使用 docker compose 启动 Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 使用 docker compose up -d 启动编排,此方式下内置的 MariaDB/Redis 不会启动,app 容器只跑 nginx + php-fpm,数据库走独立的 mysql 服务。 ```bash docker compose up -d ``` -------------------------------- ### 查看 MySQL 密码 Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 在 compose 方式下,通过 docker compose exec 进入 mysql 容器查看生成的随机密码。 ```bash docker compose exec mysql cat /secrets/mysql_root ``` -------------------------------- ### 单容器运行 acg-faka Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 使用 docker run 启动 acg-faka 容器,映射端口 80 到主机,挂载数据卷 acg_data 到 /data,并设置重启策略。镜像自带 MariaDB 和 Redis,数据库密码首次启动随机生成。 ```bash docker run -d --name acg-faka -p 80:80 -v acg_data:/data --restart unless-stopped ghcr.io/lizhipay/acg-faka:latest ``` -------------------------------- ### 降级 PHP 版本构建 Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 通过 --build-arg 指定 PHP_VERSION 构建 app 镜像。注意 PHP 8.0/8.1 已停止安全维护,且系统包可能无法获得安全更新。 ```bash docker compose build --build-arg PHP_VERSION=8.0 app ``` -------------------------------- ### Docker 部署命令 Source: https://github.com/lizhipay/acg-faka/blob/main/README.md 使用 Docker 运行异次元店铺系统,镜像自带 MariaDB 与 Redis,启动后访问 http://服务器IP 进入安装向导。数据存储在 /data 卷中,务必挂载。 ```bash docker run -d --name faka -p 80:80 -v acg_data:/data --restart unless-stopped ghcr.io/lizhipay/acg-faka:latest ``` -------------------------------- ### 常用 Docker Compose 命令 Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 查看日志、重启、停止(保留数据)和彻底清理(删除所有数据)的常用命令。 ```bash docker compose logs -f app # 看日志(访问日志只由 nginx 出,不重复) ``` ```bash docker compose restart app # 重启 ``` ```bash docker compose down # 停止(数据保留) ``` ```bash docker compose down -v # 停止并清空所有数据,回到全新状态 ``` -------------------------------- ### 手动指定镜像源安装线程管理器 Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 当 GitHub 直连不稳导致下载不完整时,脚本会自动换镜像源重试;仍不行可手动指定 TM_MIRRORS 环境变量。 ```bash TM_MIRRORS="https://ghfast.top/" ./app/Plugin/ThreadManager/service.sh install ``` -------------------------------- ### Nginx 伪静态配置 Source: https://github.com/lizhipay/acg-faka/blob/main/README.md Nginx 服务器必须配置的伪静态规则,用于阻止访问敏感文件(如日志、配置、密钥)并支持前端路由。请整段复制,不要只抄最后的 location /。 ```nginx if ($uri ~* "^/(?!(?-i:index\.php)(/|$)).*\.php(/|$)") { return 404; } location ~* ^/(runtime|kernel|config|vendor)/ { return 404; } location ~ (^|/)(runtime|\.acgcache)(/|$) { return 404; } location ~ /\.(?!well-known) { return 404; } location ~* \.(log|sql|sqlite|db|db-wal|db-shm|bak|old|save|orig|swp|swo|tmp|ini|lock|key|pem|crt|cer|der|p12|pfx|p8|keystore|jks|asc|gpg|ppk|env|secret)$ { return 404; } location ~* (~|composer\.(json|lock)|package(-lock)?\.json)$ { return 404; } location / { try_files $uri $uri/ /index.php?s=$uri&$args; } ``` -------------------------------- ### Publish Laravel Configuration Source: https://github.com/lizhipay/acg-faka/blob/main/vendor/mrgoon/aliyun-sms/README.md Publish the package configuration file to your Laravel project. ```bash php artisan vendor:publish ``` -------------------------------- ### Configure Laravel Environment Variables Source: https://github.com/lizhipay/acg-faka/blob/main/vendor/mrgoon/aliyun-sms/README.md Add the required Aliyun SMS credentials to your .env file. ```text ALIYUN_SMS_AK=your access key ALIYUN_SMS_AS=your secret key ALIYUN_SMS_SIGN_NAME=sign name ``` -------------------------------- ### 安装线程管理器插件 Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 在应用商店安装插件后,进入容器执行安装脚本。只需执行一次,二进制会落在数据卷里。 ```bash docker compose exec app ./app/Plugin/ThreadManager/service.sh install ``` ```bash # 单容器:docker exec -it acg-faka ./app/Plugin/ThreadManager/service.sh install ``` -------------------------------- ### 修改端口后启动 compose Source: https://github.com/lizhipay/acg-faka/blob/main/docker/README.md 通过环境变量 ACG_HTTP_PORT 修改对外端口,然后启动 compose。 ```bash ACG_HTTP_PORT=8081 docker compose up -d ``` -------------------------------- ### 手動安裝原始碼獲取 Source: https://github.com/lizhipay/acg-faka/blob/main/README.zh-TW.md 使用 Composer 指令下載系統原始碼。 ```bash composer create-project lizhipay/acg-faka ``` -------------------------------- ### Generate Command Block Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html Creates a UI component for displaying terminal commands with a copy-to-clipboard button. ```javascript function cmd(label, text) { return '
' + (label ? '' + esc(label) + '' : '') + '' + esc(text) + '' + '
'; } ``` -------------------------------- ### Recheck Environment Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html Initiates a recheck of the environment status, updating the UI with a loading state. ```javascript var rechecking = false; function recheck(manual) { if (rechecking) return; rechecking = true; var btn = panel.querySelector('#recheck'); if (manual && btn) { btn.classList.add('loading'); ``` -------------------------------- ### Send SMS in non-Laravel environments Source: https://github.com/lizhipay/acg-faka/blob/main/vendor/mrgoon/aliyun-sms/README.md Manually configure and use the AliSms class outside of the Laravel framework. ```php $config = [ 'access_key' => 'your access key', 'access_secret' => 'your access secret', 'sign_name' => 'your sign name', ]; $aliSms = new Mrgoon\AliSms\AliSms(); $response = $sms->sendSms('phone number', 'tempplate code', ['name'=> 'value in your template'], $config); ``` -------------------------------- ### Fallback Copy Implementation Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html Provides a fallback mechanism for copying text to the clipboard using a temporary textarea element. ```javascript function fallbackCopy(text) { var ta = document.createElement('textarea'); ta.value = text; ta.setAttribute('readonly', ''); ta.style.position = 'fixed'; ta.style.opacity = '0'; document.body.appendChild(ta); ta.select(); try { document.execCommand('copy'); } catch (e) {} document.body.removeChild(ta); } ``` -------------------------------- ### Register Laravel Service Provider Source: https://github.com/lizhipay/acg-faka/blob/main/vendor/mrgoon/aliyun-sms/README.md Add the service provider to the providers array in config/app.php. ```php Mrgoon\AliSms\ServiceProvider::class ``` -------------------------------- ### Bind Copy Functionality Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html Attaches click listeners to elements with data-copy attributes to copy text to the clipboard. ```javascript function bindCopy(view) { view.querySelectorAll('\[data-copy\]').forEach(function (b) { b.addEventListener('click', function () { var text = b.getAttribute('data-copy'); var done = function () { toast(t('btn.copied')); }; if (navigator.clipboard && window.isSecureContext) navigator.clipboard.writeText(text).then(done, function () { fallbackCopy(text); done(); }); else { fallbackCopy(text); done(); } }); }); } ``` -------------------------------- ### Send SMS in Laravel Source: https://github.com/lizhipay/acg-faka/blob/main/vendor/mrgoon/aliyun-sms/README.md Use the AliSms class to send an SMS message within a Laravel application. ```php $aliSms = new AliSms(); $response = $aliSms->sendSms('phone number', 'SMS_code', ['name'=> 'value in your template']); //dump($response); ``` -------------------------------- ### Generate Status Pill Source: https://github.com/lizhipay/acg-faka/blob/main/app/View/Install.html Helper function to create a status pill component with an icon and translated text. ```javascript function pill(ok, key) { return '' + (ok ? 'check' : 'close') + '' + esc(t(key)) + ''; } ```