Installing BookStack on a Hostinger VPS with HestiaCP on Debian 11, using your domain globalsync.site, involves several steps. HestiaCP simplifies server management, but BookStack's installation still requires some manual configuration, especially for Nginx.

Here's a breakdown of the process:

I. Prerequisites and Initial Setup

  1. Hostinger VPS with Debian 11 and HestiaCP:

    • Ensure your Hostinger VPS is running Debian 11.
    • Confirm HestiaCP is already installed. If not, follow Hostinger's or HestiaCP's official guide to install it. You would typically select a Debian 11 template with HestiaCP when setting up the VPS.
    • Access your HestiaCP panel via https://your-vps-ip:8083 with your admin credentials.
  2. Domain Name (globalsync.site):

    • DNS Configuration: Point your domain globalsync.site to your Hostinger VPS's IP address. This is done through your domain registrar's DNS settings (e.g., Hostinger's DNS management). You'll typically set up an 'A' record for @ (your root domain) and www to your VPS IP.
    • Add Domain to HestiaCP:
      • Log in to your HestiaCP panel.
      • Go to the "Web" section.
      • Click "Add Web Domain."
      • Enter globalsync.site in the "Domain" field.
      • You generally do not need to check "Create DNS zone" if your DNS is managed by Hostinger or another registrar.
      • Ensure "Enable SSL for this domain" and "Use Let's Encrypt to obtain SSL certificate" are checked. HestiaCP will automatically handle the SSL certificate.
      • Click "Save."

II. BookStack Installation (Manual Method - Recommended for HestiaCP)

HestiaCP manages Nginx and Apache (if used), so directly using a BookStack installation script that sets up its own web server configuration might conflict. The manual installation gives you more control.

  1. SSH into your VPS: Use an SSH client (like PuTTY or Terminal) to connect to your VPS as root or a user with sudo privileges.

  2. Install BookStack Dependencies: BookStack requires PHP (>=8.2), MariaDB (or MySQL), Git, and Composer. HestiaCP usually installs most of these, but ensure they are the correct versions and necessary PHP extensions are present.

    sudo apt update && sudo apt upgrade -y
    sudo apt install -y git curl unzip mariadb-server php-cli php-fpm php-mysql php-gd php-mbstring php-xml php-zip php-json php-common php-tokenizer php-curl
    

    Note: HestiaCP uses PHP-FPM. The libapache2-mod-php package is typically for Apache and might not be needed if Nginx is acting as a proxy to PHP-FPM, which is HestiaCP's default setup.

  3. Install Composer:

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php composer-setup.php
    sudo mv composer.phar /usr/local/bin/composer
    php -r "unlink('composer-setup.php');"
    
  4. Create a MariaDB Database and User for BookStack:

    sudo mysql_secure_installation
    

    Follow the prompts to secure your MariaDB installation, set a root password, remove anonymous users, etc.

    Then, log in to MariaDB as root and create the database and user:

    sudo mysql -u root -p
    

    Enter the root password you just set.

    CREATE DATABASE bookstack;
    CREATE USER 'bookstack_user'@'localhost' IDENTIFIED BY 'YOUR_STRONG_PASSWORD'; -- Replace YOUR_STRONG_PASSWORD
    GRANT ALL ON bookstack.* TO 'bookstack_user'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    
  5. Download BookStack: Navigate to the web root directory for your domain in HestiaCP. For globalsync.site, this is typically /home/your_hestiacp_user/web/globalsync.site/public_html.

    cd /home/your_hestiacp_user/web/globalsync.site/public_html
    sudo git clone https://github.com/BookStackApp/BookStack.git .
    

    The . at the end clones it into the current directory. Make sure public_html is empty before doing this, or create a subdirectory like bookstack and adjust paths accordingly.

  6. Configure BookStack:

    cp .env.example .env
    sudo nano .env
    

    Edit the .env file with the following minimum changes:

    APP_URL=https://globalsync.site  # Your domain
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=bookstack          # The database name you created
    DB_USERNAME=bookstack_user     # The database user you created
    DB_PASSWORD=YOUR_STRONG_PASSWORD # The database password you created
    

    Save and exit Nano (Ctrl+X, Y, Enter).

  7. Install BookStack Dependencies (Composer) and Generate Key:

    sudo chown -R your_hestiacp_user:www-data /home/your_hestiacp_user/web/globalsync.site/public_html
    sudo chmod -R 775 /home/your_hestiacp_user/web/globalsync.site/public_html/storage
    sudo chmod -R 775 /home/your_hestiacp_user/web/globalsync.site/public_html/bootstrap/cache
    sudo -u www-data composer install --no-dev
    sudo php artisan key:generate
    sudo php artisan migrate --seed
    

    Note: your_hestiacp_user is the user you created in HestiaCP for globalsync.site. If you're running as root, be careful with permissions.

III. HestiaCP Web Domain Configuration (Nginx)

HestiaCP already sets up Nginx for your domain. You just need to ensure it's pointing correctly and can handle BookStack's routing.

  1. Adjust Document Root in HestiaCP: By default, HestiaCP points the web domain to public_html. BookStack's main entry point is within public_html/public. You need to tell HestiaCP to use the public subdirectory as the actual document root.

    • Log in to HestiaCP.
    • Go to the "Web" section.
    • Click on your globalsync.site domain.
    • Check "Custom document root".
    • Change the path from /home/your_hestiacp_user/web/globalsync.site/public_html to /home/your_hestiacp_user/web/globalsync.site/public_html/public.
    • Click "Save."
  2. Verify Nginx Configuration (Optional but Recommended): While HestiaCP should handle this, it's good to know where the Nginx configuration files are.

    • The primary Nginx config for your domain will be within HestiaCP's managed configuration, typically found around /home/your_hestiacp_user/conf/web/globalsync.site/nginx.conf or similar.
    • BookStack uses Laravel's routing, which relies on URL rewriting. HestiaCP's default Nginx templates for PHP-FPM generally include the necessary rewrite rules. If you encounter "Not Found" errors, you might need to inspect the Nginx template HestiaCP is using for your domain and ensure it has a block similar to this within the server block:
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    

    If you need to make custom Nginx configurations, HestiaCP allows you to create custom web templates, but this is an advanced topic. For most BookStack installations, the default PHP-FPM template after setting the correct document root should suffice.

  3. Restart Nginx (and potentially PHP-FPM): After making changes, restart the web server services. You can do this from the HestiaCP dashboard (Server -> Services) or via SSH:

    sudo systemctl restart nginx
    sudo systemctl restart php8.x-fpm # Replace 8.x with your PHP version
    

IV. Accessing BookStack

Open your web browser and navigate to https://globalsync.site.

You should see the BookStack login page.

  • Default Login:
    • Email: admin@admin.com
    • Password: password

V. Post-Installation Steps

  1. Change Default Credentials Immediately: Log in to BookStack and change the admin@admin.com user's email and password.
  2. Configure Application Settings: Explore the BookStack settings to customize it for your needs.
  3. Backups: Implement a regular backup strategy for your BookStack database and files. HestiaCP has a backup feature, which you should utilize.
  4. Security: Keep your system and BookStack updated.

By following these steps, you should have a working BookStack instance on your Hostinger VPS with HestiaCP.