Issues with Subdirectory Setup on Apache2 #932

Closed
opened 2026-02-04 23:01:17 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @Stackhollow on GitHub (Dec 2, 2018).

Hey,

I got some issues setting up BookStack in a subdirectory. I have followed the instructions Subdirectory Setup and once added the configuration with custom folders in my vhost. Unfortunately, the site does not load at all.

BookStack should be available at https://domain.name/bookstack.

The location of BookStack is /var/www/bookstack/... .

I have also added the domain in the .env.

Here is my config.

<IfModule mod_ssl.c>

<VirtualHost domain.name:443>
        ServerName domain.name.tld
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

       # BookStack Configuration
       Alias "/bookstack" "/var/www/bookstack/public"

       <Directory "/var/www/bookstack/public">
          Options FollowSymlinks
          AllowOverride None
          Require all granted

          RewriteEngine On
          # Redirect Trailing Slashes If Not A Folder...
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)/$ /$1 [L,R=301]

          # Handle Front Controller...
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule ^ index.php [L]
       </Directory>


       <Directory "/var/www/bookstack">
          AllowOverride None
          Require all denied
       </Directory>
        # End BookStack Configuration

        SSLCertificateFile /path/to/certificate/file
        SSLCertificateKeyFile /path/to/certificate/key/file
        Include /etc/letsencrypt/options-ssl-apache.conf

        RewriteEngine on
        RewriteCond %{SERVER_NAME} =domain.name.tld
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Thanks for ur help.

Originally created by @Stackhollow on GitHub (Dec 2, 2018). Hey, I got some issues setting up BookStack in a subdirectory. I have followed the instructions [Subdirectory Setup](https://www.bookstackapp.com/docs/admin/subdirectory-setup/) and once added the configuration with custom folders in my vhost. Unfortunately, the site does not load at all. BookStack should be available at https://domain.name/bookstack. The location of BookStack is /var/www/bookstack/... . I have also added the domain in the .env. Here is my config. ``` <IfModule mod_ssl.c> <VirtualHost domain.name:443> ServerName domain.name.tld ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # BookStack Configuration Alias "/bookstack" "/var/www/bookstack/public" <Directory "/var/www/bookstack/public"> Options FollowSymlinks AllowOverride None Require all granted RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </Directory> <Directory "/var/www/bookstack"> AllowOverride None Require all denied </Directory> # End BookStack Configuration SSLCertificateFile /path/to/certificate/file SSLCertificateKeyFile /path/to/certificate/key/file Include /etc/letsencrypt/options-ssl-apache.conf RewriteEngine on RewriteCond %{SERVER_NAME} =domain.name.tld RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost> </IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet ``` Thanks for ur help.
Author
Owner

@lommes commented on GitHub (Dec 3, 2018):

I'm not sure if this might be the solution to your problem, but for mod_rewrite to work (which laravel uses for pretty URLs) you need at least

AllowOverride FileInfo

@lommes commented on GitHub (Dec 3, 2018): I'm not sure if this might be the solution to your problem, but for mod_rewrite to work (which laravel uses for pretty URLs) you need at least `AllowOverride FileInfo`
Author
Owner

@Stackhollow commented on GitHub (Dec 3, 2018):

I'm not sure if this might be the solution to your problem, but for mod_rewrite to work (which laravel uses for pretty URLs) you need at least

AllowOverride FileInfo

Thanks for your help, lommes!

I just figured out, that the configuration for HTTP works like expected.

<VirtualHost *:80>
    ServerName domain.name
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # BookStack Configuration
    Alias "/bookstack" "/var/www/bookstack/public"

    <Directory "/var/www/bookstack/public">
        Options FollowSymlinks
        AllowOverride none
        Require all granted

        RewriteEngine On
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)/$ /$1 [L,R=301]

        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </Directory>


    <Directory "/var/www/bookstack">
        AllowOverride None
        Require all denied
    </Directory>
    # End BookStack Configuration

</VirtualHost>

But when I put in the config for HTTPS (I created a certificate with certbot/letsencrypt), I get the login page without styles. As I log in, it takes me to HTTP-domain with error 404 Not found.

Here's my current SSL config:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName domainname
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # BookStack Configuration
    Alias "/bookstack" "/var/www/bookstack/public"

    <Directory "/var/www/bookstack/public">
        Options FollowSymlinks
        AllowOverride none
        Require all granted

        RewriteEngine On
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)/$ /$1 [L,R=301]

        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </Directory>


    <Directory "/var/www/bookstack">
        AllowOverride None
        Require all denied
    </Directory>
    # End BookStack Configuration

    SSLEngine on
    SSLCertificateFile /path/to/certificate/file
    SSLCertificateKeyFile /path/to/certificate/key/file
    Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

I don't get the problem with this.

@Stackhollow commented on GitHub (Dec 3, 2018): > I'm not sure if this might be the solution to your problem, but for mod_rewrite to work (which laravel uses for pretty URLs) you need at least > > AllowOverride FileInfo Thanks for your help, lommes! I just figured out, that the configuration for HTTP works like expected. ``` <VirtualHost *:80> ServerName domain.name ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # BookStack Configuration Alias "/bookstack" "/var/www/bookstack/public" <Directory "/var/www/bookstack/public"> Options FollowSymlinks AllowOverride none Require all granted RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </Directory> <Directory "/var/www/bookstack"> AllowOverride None Require all denied </Directory> # End BookStack Configuration </VirtualHost> ``` But when I put in the config for HTTPS (I created a certificate with certbot/letsencrypt), I get the login page without styles. As I log in, it takes me to HTTP-domain with error 404 Not found. Here's my current SSL config: ``` <IfModule mod_ssl.c> <VirtualHost *:443> ServerName domainname ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # BookStack Configuration Alias "/bookstack" "/var/www/bookstack/public" <Directory "/var/www/bookstack/public"> Options FollowSymlinks AllowOverride none Require all granted RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </Directory> <Directory "/var/www/bookstack"> AllowOverride None Require all denied </Directory> # End BookStack Configuration SSLEngine on SSLCertificateFile /path/to/certificate/file SSLCertificateKeyFile /path/to/certificate/key/file Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet ``` I don't get the problem with this.
Author
Owner

@lommes commented on GitHub (Dec 4, 2018):

Did you change the APP_URL in the .env file? Do you have both HTTP and HTTPS configured?

@lommes commented on GitHub (Dec 4, 2018): Did you change the APP_URL in the .env file? Do you have both HTTP and HTTPS configured?
Author
Owner

@ssddanbrown commented on GitHub (Dec 4, 2018):

@JustNoopie Could you also confirm your version of BookStack (Look at the version file for this)?

Also, to help solve your CSS issues, Could you open on the login page (Where styles are not loading) then view the browser devtools (Ctrl+Shift+I) in chrome > View the console tab > Reload the page > Screenshot/copy any errors you have and paste here (May contain your domain name so blank out if you want to keep that hidden).

I suspect you're either using the development files which have no styles or the path to the styles, that BookStack generates, is incorrect.

@ssddanbrown commented on GitHub (Dec 4, 2018): @JustNoopie Could you also confirm your version of BookStack (Look at the `version` file for this)? Also, to help solve your CSS issues, Could you open on the login page (Where styles are not loading) then view the browser devtools (Ctrl+Shift+I) in chrome > View the console tab > Reload the page > Screenshot/copy any errors you have and paste here (May contain your domain name so blank out if you want to keep that hidden). I suspect you're either using the development files which have no styles or the path to the styles, that BookStack generates, is incorrect.
Author
Owner

@Stackhollow commented on GitHub (Dec 4, 2018):

Hey guys,
thanks for your answers!

Did you change the APP_URL in the .env file? Do you have both HTTP and HTTPS configured?

That was the point, my bad. I'm sorry for that.

@ssddanbrown I'm using the v0.24.3. But I guess, it was my fault. The paths are correct, everything is working like a charm.

Just in case someone else has similar problems with the VirtualHost, here is my master solution:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName my.domain.tld
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # BookStack Configuration
    Alias "/bookstack" "/var/www/bookstack/public"

    <Directory "/var/www/bookstack/public">
        Options FollowSymlinks
        AllowOverride none
        Require all granted

        RewriteEngine On
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)/$ /$1 [L,R=301]

        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </Directory>


    <Directory "/var/www/bookstack">
        AllowOverride None
        Require all denied
    </Directory>
    # End BookStack Configuration

    SSLEngine on
    SSLCertificateFile /path/to/certificate/fullchain.pem
    SSLCertificateKeyFile /path/to/KeyFile/my.domain.tld/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

<VirtualHost *:80>
    Servername my.domain.tld
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]
    </IfModule>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
@Stackhollow commented on GitHub (Dec 4, 2018): Hey guys, thanks for your answers! > Did you change the APP_URL in the .env file? Do you have both HTTP and HTTPS configured? That was the point, my bad. I'm sorry for that. @ssddanbrown I'm using the v0.24.3. But I guess, it was my fault. The paths are correct, everything is working like a charm. Just in case someone else has similar problems with the VirtualHost, here is my master solution: ``` <IfModule mod_ssl.c> <VirtualHost *:443> ServerName my.domain.tld ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # BookStack Configuration Alias "/bookstack" "/var/www/bookstack/public" <Directory "/var/www/bookstack/public"> Options FollowSymlinks AllowOverride none Require all granted RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </Directory> <Directory "/var/www/bookstack"> AllowOverride None Require all denied </Directory> # End BookStack Configuration SSLEngine on SSLCertificateFile /path/to/certificate/fullchain.pem SSLCertificateKeyFile /path/to/KeyFile/my.domain.tld/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule> <VirtualHost *:80> Servername my.domain.tld ServerAdmin webmaster@localhost DocumentRoot /var/www/html <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA] </IfModule> </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#932