# BookStack

# BookStack的Nginx設定檔

```
server {
  server_name docs.site.com;

  root /var/www/docs/BookStack/public;
  index index.php index.html;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
  }

}
```

# .env

```
cp .env.example .env
```

先copy再編輯

```
APP_URL=https://site.com
```

網站名稱

```
APP_LANG=zh_TW
```

語系

```
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=docs
DB_USERNAME=root
DB_PASSWORD=pwd
```

# 安裝

```
git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch
```

```
cd /BookStack
composer update
```

```
cp .env.example .env
```

```
chown -R www-data:www-data ../BookStack/
```

```
mysqladmin -u root create docs
```

```
php artisan key:generate --force
php artisan migrate --force
```

# 更新

```bash
php artisan cache:clear
php artisan config:clear
php artisan view:clear
```

```bash
git pull origin release
composer install --no-dev
php artisan migrate
```

[https://www.bookstackapp.com/docs/admin/updates/](https://www.bookstackapp.com/docs/admin/updates/)

<p class="callout info">我想要從 v24.0x.x 升到 v24.05.2 但無法成功，下面是硬更新的方式</p>

下載最新的tar.gz，解開後整個目錄蓋過去

```
git reset --hard origin/release
```

```
composer update
```

出現錯誤提醒，把test改成大寫的 Test

再跑一次 composer update 沒出現錯誤

```
php artisan migrate
```

PS.做這件事務必先備份網站及資料庫