# BookStack Installation on Ubuntu 24.04

### 📄 Description:

This page documents the complete process for installing **BookStack**, a self-hosted wiki and knowledge base, on a fresh Ubuntu 24.04 server using PHP, Nginx, and MariaDB. This service is used as my primary knowledge repository.

<p class="callout info">ref. [https://www.bookstackapp.com/docs/admin/installation/](https://www.bookstackapp.com/docs/admin/installation/)</p>

### ✅ Prerequisites

- Fresh Ubuntu 24.04 LTS server (minimal install) LXC
- Root or sudo access
- Static IP address

### Ubuntu 24.04 Installation Script

A script to install BookStack on a fresh instance of Ubuntu 24.04 is available. This script is ONLY FOR A FRESH OS it will install Apache, MySQL 8.0 &amp; PHP 8.3 and could OVERWRITE any existing web setup on the machine. It also does not set up mail settings or configure system security, so you will have to do those separately. You can use the script as a reference if you’re installing on a non-fresh machine.

#### Running the Script

```
# Ensure you have read the above information about what this script does before executing these commands.

# Download the script
wget https://codeberg.org/bookstack/devops/raw/branch/main/scripts/installation-ubuntu-24.04.sh

# Make it executable
chmod a+x installation-ubuntu-24.04.sh

# Run the script with admin permissions
sudo ./installation-ubuntu-24.04.sh
```

The script will output a log file for debugging within your current working directory when running the script. Permissions for the BookStack installation files &amp; folders will be set based on the user used to run the script.

#### **✅ Change your BookStack instance URL**

#### 1. **Set up a domain name (DNS)**

Make sure that `wiki.example.com` points to your server's **public IP address** (private/internal). In my case, I used Cloudflare tunnel.

##### 2. **Configure BookStack's `.env`**

Edit the BookStack environment file to reflect the new domain:

```
sudo nano /var/www/bookstack/.env
```

Update this line:

```
APP_URL=https://wiki.example.com
```

Then restart the web server:

```
sudo systemctl restart apache2
```

#### ✅ **Set up HTTPS with Let's Encrypt (Optional but Recommended)**

Install Certbot:

```
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d wiki.example.com
```

It will automatically get and install the SSL certificate.

#### **✅ Step-by-Step Mail Setup**

##### **1. Edit the `.env` File**

Open the BookStack environment config:

```
sudo nano /var/www/bookstack/.env
```

Look for or add the following section:

```
MAIL_DRIVER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your@email.com
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=your@email.com
MAIL_FROM_NAME="BookStack"
```

🔁 Replace the values depending on your email provider.

##### **2. Clear the config Cache (optional but recommended)**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">  
</div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>```
cd /var/www/bookstack
php artisan config:clear
```