【工具部署】使用宝塔面板搭建WebStack个人网址导航

背景

公司组内项目比较多了,各种域名、网址不利于记忆,故搭建一套统一的导航网站,网上找了一下,发现WebStack非常不错,最终选择了它,又在官方仓库的issues里发现了利用宝塔面板搭建的教程,所以就直接拿来用了,详细教程如下

一、安装宝塔面板

本文忽略,默认已安装

二、宝塔面板中安装php7.2

三、删除如下PHP禁用函数

  • passthru
  • proc_open

四、安装MySQL5.7版本

五、宝塔新建一个站点,例如:www.demo.com

六、拉取源码&部署

1.进入站点根目录

cd /www/wwwroot/www.demo.com

2.clone代码(这一步下载不动可以手动下载源码上传解压到网站根目录)

sudo git clone https://github.com/hui-ho/WebStack-Laravel.git

3.安装Composer包管理器并且全局处理

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

4.更换源为国内源,国外服务器可忽略此步骤

sudo composer config -g repo.packagist composer https://packagist.laravel-china.org

5.安装依赖

sudo composer install --ignore-platform-reqs

6.编辑配置

cp .env.example .env
在站点根目对.env文件的编辑以下内容
...
DB_DATABASE=数据库名称
DB_USERNAME=数据库用户名
DB_PASSWORD=数据库密码
...

7.生成Key值会自动填入.env文件中

sudo php artisan key:generate

8.迁移数据

sudo php artisan migrate:refresh --seed

9.本地测试

sudo php artisan serve

禁用Debugbar 分析器

在站点根目录下的.env文件中APP_DEBUG的值置成false

修改站点端口

清除数据

sudo php artisan webstack:clean

七、错误排查

1.数据库编码错误,需要指定为utf8mb4_unicode_ci

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'admin_config' already exists (SQL: create table `admin_config` (`id` int unsigned not null auto_increment primary key, `name` varchar(255) not null, `value` varchar(255) not null, `description`   
  text null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)  

2.升级composer

  • 升级命令:sudo composer self-update
Warning: This development build of composer is over 60 days old. It is recommended to update it by running "/usr/local/bin/composer self-update" to get the latest version.
Do not run Composer as root/super user! See https://getcomposer.org/root for details

3.composer self-update 出现 [ErrorException]  zlib_decode(): data error提示

  • 解决办法:编辑php.ini中zlib.output_compression = On、zlib.output_compression_level = 5

4.composer install遇到:Your requirements could not be resolved to an installable set of packages

  • 解决办法:直接忽略版本 composer install --ignore-platform-reqs 或者 composer update --ignore-platform-reqs

5.访问admin后台页面,提示如下报错

PHP Fileinfo extension must be installed/enabled to use Intervention Image. (View: /www/wwwroot/live-test.internal.weimobqa.com/vendor/james.xue/login-captcha/resources/views/index.blade.php)
  • 解决方案:在宝塔的PHP里面安装fileinfo插件

6.访问admin后台页面,提示如下报错

The stream or file "/www/wwwroot/live-test.internal.weimobqa.com/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
  • 解决方案:log日志没有写入权限,加上写入权限

八、最终效果展示

九、相关链接

开源地址:https://github.com/hui-ho/WebStack-Laravel
魔改版本:https://github.com/CrazyBoyM/WebStack-Laravel
宝塔搭建教程:https://spoience.com/webstack.html
https://blog.csdn.net/sanbingyutuoniao123/article/details/77512051
https://www.jianshu.com/p/d68f0ec0572b

posted @ 2020-08-06 12:45  时光走散了故人。  阅读(1056)  评论(2编辑  收藏  举报