How to Install and Configure Appwrite on CyberPanel

How to Install and Configure Appwrite on CyberPanel

Β·

3 min read

Some HouseKeeping ( Shall We?? )

Appwrite is a secure, open-source, and self-hosted (yes you own your data) backend as a service that is platform agnostic. It provides a set of easy-to-use and integrated REST APIs for developers to manage their core backend needs.

CyberPanel is an open-source web hosting panel which is powered by OpenLiteSpeed. Like Appwrite, CyberPanel is also self-hostedπŸ˜ƒπŸ˜.

This article assumes that the reader already has an instance of CyberPanel installed on their machine.

Appwrite Installation

To be able to install Appwrite you should tick all the following boxes

  • 2GB of RAM, and an operating system that supports Docker.
  • Docker installed on your host machine

Since CyberPanel only supports Linux distributions name Centos 7.x, Centos 8.x, Ubuntu 18.04, Ubuntu 20.04 here is the installation script for Appwrite. ( 0.11.0 represents the version of Appwrite , the latest at the time of writing - many moons ago)

docker run -it --rm \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
    --entrypoint="install" \
    appwrite/appwrite:0.11.0

Kindly note -> CyberPanel uses port 80 for HTTP and port 443 for HTTPS for web hosting therefore the Appwrite containers should use other ports than 80 and 443 on installation. This is achieved by specifying the ports for HTTP and HTTPS respectively on installation. For this post, we are going to assume that you have chosen port 3700 for HTTP and 3443 for HTTPS. In simple terms, we are mapping port 3700(HTTP) and port 3443(HTTPS) to the outside world, making it accessible externally.

Use localhost as the Appwrite hostname ( default option ). We will use a reverse proxy, OpenLightSpeed, to connect to the Appwrite instance. Using a reverse proxy will also save us from SSL certificate-related headaches on Appwrite as we will just issue a certificate, Let's Encrypt, using CyberPanel to our domain and then reverse proxy that domain to our Appwrite instance.

To verify our installation docker ps | grep appwrite/appwrite will return the Appwrite version which we have just installed, 0.11.0.

Reverse Proxy Traffic To Appwrite Container

Assuming you have already created your website on CyberPanel, navigate to /usr/local/lsws/conf/ on the terminal and edit the httpd_config.conf file. This can be achieved by using 'nano' or any editor of your choice using this one-liner.

nano /usr/local/lsws/conf/httpd_config.conf

The following configuration which you are supposed to add to the http_config.conf file above does the following:

  • Specifies the name of the external application. The name is an identifier of our external application. (For this tutorial the name will be cypwrite)
  • Specifies the type of the external ( proxy in our case )
  • The address of the application (Since we chose localhost on Appwrite installation as the hostname and port 3700 as the HTTP port, the address would be 127.0.0.0.1:3700 in our case
extprocessor cypwrite {
  type                    proxy
  address                 127.0.0.1:3700
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

You can learn more about OpenLiteSpeed Directives here

The Home Run!! πŸ‘£

home_run.png Click on your website's rewrite rules and edit the rewrite rule to point the website to our application which we configured in /usr/local/lsws/conf/httpd_config.conf. Should be cypwrite if my memory serves me correctly.πŸ˜… . The following rule will do the job of redirecting to our Appwrite application hosted locally and enable you to access your appwrite instance using your website's URL.

REWRITERULE ^(.*)$ HTTP://cypwrite/$1 [P]

CyberPanel fully supports mod_rewrite syntax. You can go a step further and force your site to redirect to HTTPS(SSL) assuming that you have issued a certificate for your website. SSL certificates are free as Let's Encrypt is used to issue certificates.

If you enjoyed this article, kindly share it with your friends and colleagues!

Β