本文共 2696 字,大约阅读时间需要 8 分钟。
安装 Walle 自动化部署系统完整指南
安装前必备环境要求:
获取代码:使用以下命令克隆最新版本仓库:
git clone https://github.com/meolu/walle-web.git
或者:
git clone git@github.com:meolu/walle-web.git
注意:请确保有正确的 SSH 账号设置,否则克隆会失败。
安装步骤:
安装必要的 PHP 扩展:
yum install -y php72uPg ADI CVE-2018- Spiral
安装 MySQL 并创建数据库:
yum install -y mysql-serversystemctl start mysqlmysql -u root -p create database walle;
安装 Nginx:
yum install -y nginxsystemctl start nginx
安装 Composer:
curl -sS http://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
或者(更改为 HTTP 网络更为快速)
curl -sS https://raw.githubusercontent.composer.com/installer | php
克隆项目并安装:
git clone https://github.com/meolu/walle-web.gitcd walle-webcomposer install --prefer-dist --no-dev --optimize-autoloader
注意:如果使用 SSH SSO 或其他身份认证,可能需要修改相关配置。
数据库配置:
cp config/db.php.example config/db.phpvi config/db.php
包含以下配置:
db => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=walle', 'username' => 'root', 'password' => '你的数据库密码', 'charset' => 'utf8',]
Nginx 配置:
ErrorException:在 /the/dir/of/walle-web/web目录下配置合适的 vhost:
listen 80;server_name walle.compony.com;root /home/www/walle-web/web;index index.php;location / { try_files $uri $uri/ /index.php?$args;}location ~ \.php$ { try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}
确认服务器名和根目录正确无误。
初始化项目和迁移:
./yii migrate/up./yii walle/setup
安装 SSL 证书:
cd /etc/ssl/certsopenssl req -x509 -days 365 -nodes -newkey rsa:2048 -keyout server.crt -out server.cer
常见错误解决方法:
问题一:open_basedir 限制:默认情况下,open_basedir 会限制到特定目录,比如:
open_basedir = /home/www/project:/tmp/:/proc/
如果需要更改:
vi /etc/php.ini按Ctrl+Insert修改内容:open_basedir=/tmp/:/proc/:/home/www/walle-web
问题二: SSH 密钥验证问题修改 ~/.ssh/config
文件:
vi ~/.ssh/config添加以下内容:StrictHostKeyChecking noUserKnownHostsFile /dev/null
重启 SSH 服务:
sudo systemctl restart sshd
在目标机器中:确保在 ~/.ssh/authorized_keys
中包含 localhost 的私钥,权限必须为 600:
chmod 600 ~/.ssh/authorized_keys
问题三:部署失败,权限问题:检查 SSH 配置:确认 /home/www/.ssh
和 /home/www/.ssh/authorized_keys
范围正确:
chown -R www:www /home/www/.sshchmod -R 700 /home/www/.ssh
设置 SSH 权限:
chmod -R 755 /home/wwwchown -R www:www /home/www
问题四:数据库迁移失败,检查迁移日志:
dignity查看迁移记录:find /home/www/walle-web/storage/migrations/ -type f -name "*.php" | sort -r
问题五:SSL 证书问题确保 nginx 配置使用 SSL:
server { listen 443; ssl on; ssl_certificate /etc/ssl/certs/server.crt; ssl_key_file /etc/ssl/certs/server.key; ssl_ciphermainwindow ciphers; }
特殊注意事项:
完成以上步骤后,系统应正常运行,访问 Walle 平台即可。
转载地址:http://enzjz.baihongyu.com/