How to Change domain on Bookstack #3524

Closed
opened 2026-02-05 06:59:39 +03:00 by OVERLORD · 27 comments
Owner

Originally created by @Nitro-Zeus98 on GitHub (Feb 22, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hi, i have used this ticket as "help" to my problem; https://github.com/BookStackApp/BookStack/issues/2305
But I cant get it to work, I want to change my domain name for bookstack since it's expiring soon, an I already have a new ready.

I tried to enter the path -> cd /etc/apache2/sites-enabled
then -> sudo nano bookstack.conf
ctrl + W
ctrl + R
i replaced my old domain with the new one. and saved the file.

Then exit and tried to restart apache with the command -> service apache2 restart

But i get error, see the picture.
Dont know what to do here?

2023-02-22_18-38-59

I have installed Bookstack with this guide: https://www.bookstackapp.com/docs/admin/installation/
Ubuntu 22.04 Installation Script without any errors. before now where i need to change the domain name.

Exact BookStack Version

Ubuntu 22.04 Installation Script

Log Content

No response

PHP Version

No response

Hosting Environment

Server hosted in Hetzner on ESXI
The Virtual Machine with bookstack is sitting behind a pFsense firewall.

Originally created by @Nitro-Zeus98 on GitHub (Feb 22, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Hi, i have used this ticket as "help" to my problem; https://github.com/BookStackApp/BookStack/issues/2305 But I cant get it to work, I want to change my domain name for bookstack since it's expiring soon, an I already have a new ready. I tried to enter the path -> cd /etc/apache2/sites-enabled then -> sudo nano bookstack.conf ctrl + W ctrl + R i replaced my old domain with the new one. and saved the file. Then exit and tried to restart apache with the command -> service apache2 restart But i get error, see the picture. Dont know what to do here? ![2023-02-22_18-38-59](https://user-images.githubusercontent.com/109220608/220743829-b42d97b2-05b8-4fd7-8a4c-0572c95858db.jpg) I have installed Bookstack with this guide: https://www.bookstackapp.com/docs/admin/installation/ Ubuntu 22.04 Installation Script without any errors. before now where i need to change the domain name. ### Exact BookStack Version Ubuntu 22.04 Installation Script ### Log Content _No response_ ### PHP Version _No response_ ### Hosting Environment Server hosted in Hetzner on ESXI The Virtual Machine with bookstack is sitting behind a pFsense firewall.
OVERLORD added the 🐕 Support label 2026-02-05 06:59:39 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 22, 2023):

@Nitro-Zeus98 Based on that error, it's very likely the edited apache config file is now invalid in some way.
The shown output is providing a hint to gain more information on the error.
Run sudo journalctl -xeu apache2.service to gain more info on what's wrong. Otherwise you might find more info in the apache error log file (Commonly at /var/log/apache2/error.log).

@ssddanbrown commented on GitHub (Feb 22, 2023): @Nitro-Zeus98 Based on that error, it's very likely the edited apache config file is now invalid in some way. The shown output is providing a hint to gain more information on the error. Run `sudo journalctl -xeu apache2.service` to gain more info on what's wrong. Otherwise you might find more info in the apache error log file (Commonly at `/var/log/apache2/error.log`).
Author
Owner

@Nitro-Zeus98 commented on GitHub (Feb 22, 2023):

i have changed the domain back as i did not work with the new one, so i can still access bookstack and everything.

See .txt and picture, what log do you want me to open ?
2023-02-22_21-27-02
journalctl .txt

@Nitro-Zeus98 commented on GitHub (Feb 22, 2023): i have changed the domain back as i did not work with the new one, so i can still access bookstack and everything. See .txt and picture, what log do you want me to open ? ![2023-02-22_21-27-02](https://user-images.githubusercontent.com/109220608/220751247-30e60229-4ffd-4093-bfb1-49b726e8f30d.jpg) [journalctl .txt](https://github.com/BookStackApp/BookStack/files/10808056/journalctl.txt)
Author
Owner

@ssddanbrown commented on GitHub (Feb 22, 2023):

@Nitro-Zeus98 error.log is the one. Running tail -n 500 error.log should give you the last 500 lines of it.

@ssddanbrown commented on GitHub (Feb 22, 2023): @Nitro-Zeus98 `error.log` is the one. Running `tail -n 500 error.log` should give you the last 500 lines of it.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Feb 23, 2023):

The website is currently on https://nitrozeus.site/

See the two pictures.
2023-02-23_16-05-51
2023-02-23_16-07-36

@Nitro-Zeus98 commented on GitHub (Feb 23, 2023): The website is currently on https://nitrozeus.site/ See the two pictures. ![2023-02-23_16-05-51](https://user-images.githubusercontent.com/109220608/220945815-b2ff6641-f347-43dc-97ac-66e183a72b5f.jpg) ![2023-02-23_16-07-36](https://user-images.githubusercontent.com/109220608/220946255-a806054d-baf3-4135-8df0-cf578bfb4e24.jpg)
Author
Owner

@ssddanbrown commented on GitHub (Feb 23, 2023):

@Nitro-Zeus98 Thanks but you may have gotten to that a little late. Same with the journalctl.txt provided above. These logs can fill fairly fast. Ideally you'll want to check these right after the error has occurred so that the error should be expected at the end of the logs.

@ssddanbrown commented on GitHub (Feb 23, 2023): @Nitro-Zeus98 Thanks but you may have gotten to that a little late. Same with the `journalctl.txt` provided above. These logs can fill fairly fast. Ideally you'll want to check these right after the error has occurred so that the error should be expected at the end of the logs.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Feb 23, 2023):

alright, that makes sense, so what do you want me to do? I tried to change the domain name from nitrozeus.site to cloud-chefen.dk it did not work, so I changed it back. can you give me a guide perhaps on how to do that, I only need to change the domain, I will use certbot later to create a certificate for the domain.

@Nitro-Zeus98 commented on GitHub (Feb 23, 2023): alright, that makes sense, so what do you want me to do? I tried to change the domain name from nitrozeus.site to cloud-chefen.dk it did not work, so I changed it back. can you give me a guide perhaps on how to do that, I only need to change the domain, I will use certbot later to create a certificate for the domain.
Author
Owner

@ssddanbrown commented on GitHub (Feb 23, 2023):

You could check the logs right after causing the error to occur again.
Alternatively, you could provide your config file and explain the changes you made to see if there's anything obvious.

@ssddanbrown commented on GitHub (Feb 23, 2023): You could check the logs right after causing the error to occur again. Alternatively, you could provide your config file and explain the changes you made to see if there's anything obvious.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 1, 2023):

I'm not so experienced in this. all did was follow the same thing that was posted here: https://github.com/BookStackApp/BookStack/issues/2305

Is it possible for you to tell me what to do, if I need to change the domain, where should I make the changes? I cannot find any guide on it anywhere :(

If I could just get a how-to I would have no problem doing so, but I need to know where to do the changes :)

@Nitro-Zeus98 commented on GitHub (Mar 1, 2023): I'm not so experienced in this. all did was follow the same thing that was posted here: https://github.com/BookStackApp/BookStack/issues/2305 Is it possible for you to tell me what to do, if I need to change the domain, where should I make the changes? I cannot find any guide on it anywhere :( If I could just get a how-to I would have no problem doing so, but I need to know where to do the changes :)
Author
Owner

@ssddanbrown commented on GitHub (Mar 1, 2023):

@Nitro-Zeus98 I'd need to know the current state of your BookStack Apache config first to be able to accurately make recommendations. There are things, such as if HTTPS is at play in the config, that can significantly change the steps required.

@ssddanbrown commented on GitHub (Mar 1, 2023): @Nitro-Zeus98 I'd need to know the current state of your BookStack Apache config first to be able to accurately make recommendations. There are things, such as if HTTPS is at play in the config, that can significantly change the steps required.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 1, 2023):

alright, what info would you like me to send to you :)
HTTPS does not matter, i will use certbot later to create that for the new domain.

Let me know the commands i should run and i will send you data.

@Nitro-Zeus98 commented on GitHub (Mar 1, 2023): alright, what info would you like me to send to you :) HTTPS does not matter, i will use certbot later to create that for the new domain. Let me know the commands i should run and i will send you data.
Author
Owner

@ssddanbrown commented on GitHub (Mar 1, 2023):

Please provide the contents of the /etc/apache2/sites-available/bookstack.conf file if it exists.

@ssddanbrown commented on GitHub (Mar 1, 2023): Please provide the contents of the `/etc/apache2/sites-available/bookstack.conf` file if it exists.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 1, 2023):

2023-03-01_13-29-44

@Nitro-Zeus98 commented on GitHub (Mar 1, 2023): ![2023-03-01_13-29-44](https://user-images.githubusercontent.com/109220608/222139777-2fdc400a-2335-4716-b9cd-838ae990afd2.jpg)
Author
Owner

@ssddanbrown commented on GitHub (Mar 1, 2023):

Okay, Since there's HTTPS variants for the current apache config it's properly cleaner to set things up as a new virtualhost entry. Before anything, ensure you have the machine backed-up/snapshotted if possible. Some of these commands are potentially dangerous to the system or BookStack content.

If you encounter errors along the way, or things are not as you might expect, stop at that step and report back.

Step 1

Create a new apache virtualhost file, with the path & name: /etc/apache2/sites-available/bs2023.conf, containing the below contents. Replace the single instance of docs.example.com with your new domain in the content of this file.

<VirtualHost *:80>

	# This is a simple example of an Apache VirtualHost configuration
	# file that could be used with BookStack.
	# This assumes mod_php has been installed and is loaded.
	#
	# Change the "docs.example.com" usage in the "ServerName" directive
	# to be your web domain for BookStack.
	#
	# Change the "/var/www/bookstack/public/", used twice below, to the
	# location of the "public" folder within your BookStack installation.
	#
	# This configuration is only for HTTP, Not HTTPS.
	# For HTTPS we recommend using https://certbot.eff.org/

	ServerName docs.example.com
	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>

Step 2

Activate the above config via sudo a2ensite bs2023.conf.
Then restart apache via sudo systemctl restart apache2.service.

Step 3

Assuming the domain is pointing at your server, test access by visiting your domain URL.
Visit with /login on the end if your site requires login. You should see your BookStack instance load on that URL
but any further links may lead you back to the old site. Also, styles could be missing making everything look strange, that's expected and we'll adjust that later.

Step 4

Go through the certbot process now if you're looking to add HTTPS. Run certbot and select the new domain.
Easiest to do that now to avoid repeating the next couple of steps.

Step 5

Now we need to configure the new domain with BookStack.
Edit the /var/www/bookstack/.env file and update the APP_URL variable to start with the new base URL for your BookStack site. This should start with http:// (or https:// if done step 4) and should not have a trailing slash.

Step 6

Now, we need to update the URL in the BookStack database content. This can be done via the below command, but you'll need to replace the two URLs in this command, so the old base URL is first, and the new base URL is second.

php /var/www/bookstack/artisan bookstack:update-url https://old-domain.example.com https://new-domain.bookstackapp.com
@ssddanbrown commented on GitHub (Mar 1, 2023): Okay, Since there's HTTPS variants for the current apache config it's properly cleaner to set things up as a new virtualhost entry. **Before anything, ensure you have the machine backed-up/snapshotted if possible.** Some of these commands are potentially dangerous to the system or BookStack content. If you encounter errors along the way, or things are not as you might expect, stop at that step and report back. ### Step 1 Create a new apache virtualhost file, with the path & name: `/etc/apache2/sites-available/bs2023.conf`, containing the below contents. Replace the single instance of `docs.example.com` with your new domain in the content of this file. ```apache <VirtualHost *:80> # This is a simple example of an Apache VirtualHost configuration # file that could be used with BookStack. # This assumes mod_php has been installed and is loaded. # # Change the "docs.example.com" usage in the "ServerName" directive # to be your web domain for BookStack. # # Change the "/var/www/bookstack/public/", used twice below, to the # location of the "public" folder within your BookStack installation. # # This configuration is only for HTTP, Not HTTPS. # For HTTPS we recommend using https://certbot.eff.org/ ServerName docs.example.com 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> ``` ### Step 2 Activate the above config via `sudo a2ensite bs2023.conf`. Then restart apache via `sudo systemctl restart apache2.service`. ### Step 3 Assuming the domain is pointing at your server, test access by visiting your domain URL. Visit with `/login` on the end if your site requires login. You should see your BookStack instance load on that URL but any further links may lead you back to the old site. Also, styles could be missing making everything look strange, that's expected and we'll adjust that later. ### Step 4 Go through the certbot process now if you're looking to add HTTPS. Run certbot and select the new domain. Easiest to do that now to avoid repeating the next couple of steps. ### Step 5 Now we need to configure the new domain with BookStack. Edit the `/var/www/bookstack/.env` file and update the `APP_URL` variable to start with the new base URL for your BookStack site. This should start with `http://` (or `https://` if done step 4) and should **not** have a trailing slash. ### Step 6 Now, we need to update the URL in the BookStack database content. This can be done via the below command, but you'll need to replace the two URLs in this command, so the old base URL is first, and the new base URL is second. ```bash php /var/www/bookstack/artisan bookstack:update-url https://old-domain.example.com https://new-domain.bookstackapp.com ```
Author
Owner

@ssddanbrown commented on GitHub (Mar 6, 2023):

Since there's been no follow-up on the above I'll close this off but feel free to still comment if needed.

@ssddanbrown commented on GitHub (Mar 6, 2023): Since there's been no follow-up on the above I'll close this off but feel free to still comment if needed.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 7, 2023):

Sorry for the late replies, have been kinda busy

The virtual machine is backed up with Veeam to a storage box.

Step one, how do i create a new apache virtual host file. How do i do that.

is there no other way than this :O I just ned the domain name changed? it's okay to remove the https if that helps?

@Nitro-Zeus98 commented on GitHub (Mar 7, 2023): Sorry for the late replies, have been kinda busy The virtual machine is backed up with Veeam to a storage box. Step one, how do i create a new apache virtual host file. How do i do that. is there no other way than this :O I just ned the domain name changed? it's okay to remove the https if that helps?
Author
Owner

@ssddanbrown commented on GitHub (Mar 7, 2023):

how do i create a new apache virtual host file. How do i do that.

You just create and edit a file at the described name (Using your favourite editor like nano or vim or whatever).

is there no other way than this :O I just ned the domain name changed?

There's probably a few ways, I have tried to provide the most direct way I could explain since the exiting website state can complicate matters.

it's okay to remove the https if that helps?

Not really, but i've made this optional as touched upon in step 4.

@ssddanbrown commented on GitHub (Mar 7, 2023): > how do i create a new apache virtual host file. How do i do that. You just create and edit a file at the described name (Using your favourite editor like nano or vim or whatever). > is there no other way than this :O I just ned the domain name changed? There's probably a few ways, I have tried to provide the most direct way I could explain since the exiting website state can complicate matters. > it's okay to remove the https if that helps? Not really, but i've made this optional as touched upon in step 4.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 7, 2023):

Alright so step one the following command goes sudo nano /etc/apache2/sites-available/bs2023.conf
the replace docs.example.com with cloud-chefen.dk and paste in the command

image

step 2 does not work, i have not tried to type anything after that, what should i write.
image

@Nitro-Zeus98 commented on GitHub (Mar 7, 2023): Alright so step one the following command goes `sudo nano /etc/apache2/sites-available/bs2023.conf` the replace `docs.example.com` with `cloud-chefen.dk` and paste in the command ![image](https://user-images.githubusercontent.com/109220608/223445086-82d6196e-41c3-4dda-ad1e-650f22e5cee7.png) step 2 does not work, i have not tried to type anything after that, what should i write. ![image](https://user-images.githubusercontent.com/109220608/223445207-6af8d711-ec03-4d1d-abac-bd0f68db50ba.png)
Author
Owner

@ssddanbrown commented on GitHub (Mar 7, 2023):

step 2 does not work, i have not tried to type anything after that

I'm not sure I understand, that looks like it's worked.
Run the other command i listed in step 2 then move on to step 3.

@ssddanbrown commented on GitHub (Mar 7, 2023): > step 2 does not work, i have not tried to type anything after that I'm not sure I understand, that looks like it's worked. Run the other command i listed in step 2 then move on to step 3.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 7, 2023):

my bad xD
i have some issues with firewall rules, regarding certificate registration, i will fix that and return later with info

@Nitro-Zeus98 commented on GitHub (Mar 7, 2023): my bad xD i have some issues with firewall rules, regarding certificate registration, i will fix that and return later with info
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023):

i think that's all should i do more as of now?
image

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023): i think that's all should i do more as of now? ![image](https://user-images.githubusercontent.com/109220608/223695185-5d185d22-e44e-4b4e-9ee1-11fc3687a017.png)
Author
Owner

@ssddanbrown commented on GitHub (Mar 8, 2023):

@Nitro-Zeus98 If you've gone through all the steps, that's all that should be needed.

@ssddanbrown commented on GitHub (Mar 8, 2023): @Nitro-Zeus98 If you've gone through all the steps, that's all that should be needed.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023):

should i do as it says on the picture
"Be sure to run php artisan cache:clear to clear any old URLs in the cache" ?

Website seems to be working amazing with the new domain name, Thank you so much <3 you don't know how much this means to me :)

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023): should i do as it says on the picture "Be sure to run `php artisan cache:clear` to clear any old URLs in the cache" ? Website seems to be working amazing with the new domain name, Thank you so much <3 you don't know how much this means to me :)
Author
Owner

@ssddanbrown commented on GitHub (Mar 8, 2023):

should i do as it says on the picture, "Be sure to run php artisan cache:clear to clear any old URLs in the cache" ?

Might as well, there's no harm in running that.

Website seems to be working amazing with the new domain name, Thank you so much <3 you don't know how much this means to me :)

Happy to hear that, thanks, and happy to help!

@ssddanbrown commented on GitHub (Mar 8, 2023): > should i do as it says on the picture, "Be sure to run php artisan cache:clear to clear any old URLs in the cache" ? Might as well, there's no harm in running that. > Website seems to be working amazing with the new domain name, Thank you so much <3 you don't know how much this means to me :) Happy to hear that, thanks, and happy to help!
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023):

Hmm does not seem to work xD
image

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023): Hmm does not seem to work xD ![image](https://user-images.githubusercontent.com/109220608/223711242-8ed61a8a-ce75-445f-872c-51f5f568d357.png)
Author
Owner

@ssddanbrown commented on GitHub (Mar 8, 2023):

@Nitro-Zeus98 Such commands are ran from your BookStack install directory.
So cd /var/www/bookstack first then run the command.

@ssddanbrown commented on GitHub (Mar 8, 2023): @Nitro-Zeus98 Such commands are ran from your BookStack install directory. So `cd /var/www/bookstack` first then run the command.
Author
Owner

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023):

Amazing works like a champ, thanks again Dan this is very much appreciated. Hope you have a nice day :)
image

@Nitro-Zeus98 commented on GitHub (Mar 8, 2023): Amazing works like a champ, thanks again Dan this is very much appreciated. Hope you have a nice day :) ![image](https://user-images.githubusercontent.com/109220608/223741353-97a3c5a3-9a09-432a-bcd0-4b9936f25376.png)
Author
Owner

@ssddanbrown commented on GitHub (Mar 8, 2023):

Awesome! will go ahead and close this off.

@ssddanbrown commented on GitHub (Mar 8, 2023): Awesome! will go ahead and close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3524