Skip to main content

Docusaurus Installation with Apache2

Apache2 will act as a webserver to serve the content for the site

First lets create the root directory on your new host.

sudo mkdir /var/websites && cd /var/websites/

Installing Docusaurus

sudo apt installl npm
sudo npx create-docusaurus@latest <my-website> classic --typescript
info

Change <my-website> to anything you'd like. Im going to make mine BankaiTechDocs.

Building the Files

cd <my-website>
npm run build

Installing Apache2

sudo apt install apache2

Creating vhost

sudo nano /etc/apache2/sites-available/documentation.conf

Paste the following.

Highlighted items will need to be modified
<VirtualHost *:8091>
ServerAdmin webmaster@localhost
DocumentRoot "/var/websites/<my-website>/build"
ServerName docs.<example>.com
<Directory "/var/websites/<my-website>/build">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

DirectoryIndex index.html

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

Now lets create a symbolic link of the vhost.

sudo ln -s /etc/apache2/sites-available/documentation.conf /etc/apache2/sites-enabled/

Configuring the Ports

In order to prevent port conflicts we will need to modify ports.conf

sudo nano /etc/apache2/ports.conf

Make it look like the following.

# Only listens on port 8091
# Listen 80
Listen 8091
<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

Restart Apache2

sudo systemctl restart apache2

Docusaurus has been Installed!

You can now install and configure a reverse proxy such as NGINX to forward traffic to Docusaurus.



Hi, how can I help you?