Bookstack
So I've had a thought of building my own Wiki. I've grown tired of OneNote, and while I am currently testing Obsidian, I've thought about using a Wiki for my note taking instead. Bookstack always gets rave, glowing reviews as being a tremendous Wiki. It seems full featured and robustly developed. It looks like just what I am interested in.
Install Operating System
I don't see any specific system requirements so I build a new virtual machine named BOOKSTACK-01 with 1vCPU, 4GB of RAM, and 20GB virtual disk. I remember to set the Secure Boot option to Microsoft UEFI Certificate Authority this time so I hopefully don't run into any trouble. I go through the Debian installation wizard. The installation gets to 90% and then starts looping back to 90% over and over. I can't get it to go forward past 90% and I can't get it to abort the installation. I can't get the virtual machine to power down or shut off. After quite some time everything finally times out and I am now able to power it off.
Trying again, I unmount and remount the Debian ISO. After the wizard, this time the installation completes successfully.
Configure Operating System
First I log into BOOKTSACK-01 as root.
- apt install sudo
- /sbin/adduser david sudo
- nano /etc/network/interfaces- Allow-hotplug eth0
- iface eth0 inet static
- Address 10.100.100.XXX
- Netmask 255.255.255.0
- Gateway 10.100.100.254
 
- sudo reboot
Now I log back in to BOOKSTACK-01 as david.
- ip -c addr
I confirm the IP address is set correctly.
From Windows Terminal on my dekstop:
- ssh-keygen -t ed25519
- Move-Item -Path c:\Users\david\filename* -Destination c:\Users\david\.ssh -Force
- I open Windows Terminal Settings
- I open JSONfile and add the following:
            {
                "colorScheme": "Ubuntu-ColorScheme",
                "commandline": "ssh -i \"~/.ssh/bookstack-01\" [email protected]",
                "experimental.retroTerminalEffect": false,
                "font": 
                {
                    "face": "Cascadia Code"
                },
                "guid": "{0caa0dad-35be-5f56-a8ff-afceaeaa6119}",
                "hidden": false,
                "name": "BOOKSTACK-01",
                "tabTitle": "BOOKSTACK-01"
            },
- I confirm the GUIDis unique and save theJSONfile
Steps performed from BOOKTSACK-01
- mkdir /home/david/.ssh
- nano /home/gooseneck/.ssh/authorized_keys- I paste in the public key and save the authorized_keys
 
- I paste in the public key and save the 
- chmod 600 /home/david/.ssh/authorized_keys
- sudo nano /etc/ssh/sshd_config- PermitRootLogin no
- PubkeyAuthentication yes
- PubkeyAcceptedKeyTypes ssh-ed25519
- PasswordAuthentication no
- AuthorizedKeysFile /home/david/.ssh/authorized_keys
- I save the sshd_config
 
- sudo sshd -t
- sudo systemctl restart ssh
Install Dependencies
Steps performed on BOOKTSACK-01
- sudo apt install -y git unzip apache2 php7.4 curl php7.4-fpm php7.4-curl php7.4-mbstring php7.4-ldap \ php7.4-tidy php7.4-xml php7.4-zip php7.4-gd php7.4-mysql libapache2-mod-php7.4 \ default-mysql-server
Setup Database
Steps performed on BOOKSTACK-01
- mysql -uroot- ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password';
- FLUSH PRIVILEGES;
- EXIT;
 
- mysql_secure_installation- I run through the wizard
 
- mysql -uroot -p- CREATE DATABASE bookstack;
- CREATE USER 'bookstack'@'localhost' IDENTIFIED BY 'Password';
- GRANT ALL ON bookstack.* TO 'bookstack'@'localhost';
- FLUSH PRIVILEGES;
- Exit;
 
Install PHP Package Manager
Steps performed on BOOKSTACK-01
- EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
- if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
- then- >&2 echo 'ERROR: Invalid composer installer checksum'
- rm composer-setup.php
- exit 1
 
- fi
- php composer-setup.php --quiet
- rm composer-setup.php
- mv composer.phar /usr/local/bin/composer
Download Bookstack PHP Webapp Files
Steps performed on BOOKTSACK-01
- cd /var/www
- git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch bookstack
- cd bookstack
Configure Bookstack
- Export COMPOSER_ALLOW_SUPERUSER=1
- php /usr/local/bin/composer install --no-dev --no-plugins
Success!
- cp .env.example .env
- nano .env- Set APP_URL
- Set DB_DATABASE
- Set DB_USERNAME
- Set DB_PASSWORD
 
- Set 
- php artisan key:generate --no-interaction --force- Application key set successfully
 
- chown www-data:www-data -R bootstrap/cache public/uploads storage
- chmod -R bootstrap/cache public/uploads storage- Invalid mode: 'bootstrap/cache'
 
Whoops! Silly typo!
- chmod -R 755 bootstrap/cache public/uploads storage
Configure Apache to Serve New Bookstack App
Steps performed on BOOKTSACK-01
- a2enmod rewrite
- a2enmod php7.4
- nano /etc/apache2/sites-available/bookstack.conf
<VirtualHost *:80>
            ServerName 10.100.100.XXX           # Set to static IP otherwise define hostname in DNS entry for it to work.
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/bookstack/public/
        <Directory /var/www/bookstack/public/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
            <IfModule mod_rewrite.c>
                <IfModule mod_negotiation.c>
                    Options -MultiViews -Indexes
                </IfModule>
                RewriteEngine On
                # Handle Authorization Header
                RewriteCond %{HTTP:Authorization} .
                RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
                # Redirect Trailing Slashes If Not A Folder...
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_URI} (.+)/$
                RewriteRule ^ %1 [L,R=301]
                # Handle Front Controller...
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule ^ index.php [L]
            </IfModule>
        </Directory>
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
- Saved
Verify Config and Enable
Steps performed on BOOKSTACK-01
- apachectl configtest- Syntax OK
 
- a2dissite 000-default.conf- Site 000-default disabled
 
- a2ensite bookstack.conf- Enabling site bookstack
 
- sudo sysemctl restart apache2- sysemctl: command not found
 
- sudo systemctl restart apache2- Job for apache2.service failed because the control process exited with error code.
 
- apachectl configtest- Syntax error on line 2
 
It looks like it did not like my inline comment.
- Removing # Set to static IP otherwise define hostname in DNS entry for it to work.
- apachectl configtest- Syntax OK
 
- sudo systemctl restart apache2
Success!
Login to Bookstack
Testing just produces a blank page. Huh. Let's try seeing if it will load a test file.
Steps performed on BOOKSTACK-01
- nano info.php
<?php
	phpinfo();
/php>
Nope. Nothing. Let's troubleshoot. I'm looking for what I've clearly missed. Ah! I missed a step under "Configure Bookstack."
- php artisan migrate --no-interaction --force- Access denied for user 'bookstore'@'localhost'
 
- mysql -uroot -p- USE mysql;
- SELECT user FROM user;
- Verify that bookstackdoes not exist.
- Exit;
 
- mysql -u bookstack -p- The login is successful so I have the right username and password documented.
- USE bookstack;
- SHOW GRANTS;
- GRANT ALL PROVILEGES ON 'bookstack'.* TO 'bookstack'@'localhost'
 
I found my problem now. You might have caught it above. In my .env file I used bookstore instead of bookstack. What a silly mistake!
- I correct my typos.
- php artisan migrate --no-interaction --force
Success!
Something else still seems to be wrong because I can't get info.php to load. Let's think here. Well now it looks like it is redirecting http://FQDN to https://FQDN. That is strange since I did not set that up right?
No, it isn't even doing that. It is redirecting http://FQDN to https://localhost/login which doesn't exist. Where is the redirect coming from? And why doesn't it load info.php?
I delete and recreate info.php and now it loads just fine. I must have had a typo the first time. Damn. Well I go back to the .env file. I don't have much experience with these .env files. I have never had a problem with or had to modify the APP_URL to anything other than localhost. But to test let's change it to the server IP.
This allows Bookstack to load. I suppose I need to read up more on the .env files.
Playing Around with Bookstack
- Logged in with default account
- Created my own account
- Logged out
- Logged in with my own account
- Deleted default account
I was able to play around with it for about five more minutes. I made a shelf, a book, a chapter, and a page. I made some quick revisions to the page. Damn, this is slick software!
