【工具部署】使用寶塔面板搭建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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM