Deploy Waline on Self Host
Waline is derived from Valine and is a very simple and secure comment system. With rich features, Waline is an excellent choice as a blog comment system. There are various deployment methods available for Waline, but if you have your own server, it is preferable to deploy Waline on it with a local database. This article mainly shares the experience of deploying Waline with a local database on a self host.
Here are all the deploy methods supported by Waline. On a self host, you can choose to install it directly or in a Docker container. Waline supports various types of databases, including MongoDB, MySQL/MariaDB, TiDB, and PostgreSQL. This article mainly introduces the deploy procedure using MySQL/MariaDB as the database. (deploy with other databases is similar)
Client | Server | Storage |
---|---|---|
@waline/client | Vercel | LeanCloud |
MiniValine | Deta | CloudBase |
sodesu | CloudBase | MongoDB |
Railway | MySQL | |
Render | SQLite | |
Zeabur | PostgreSQL | |
Netlify | GitHub | |
Docker | Deta Base | |
Self Host | TiDB |
Prepare Database
Open a MySQL prompt and create a new user for Waline to access the database (or use an existing user), then create a database for Waline. Grant the user all privileges for that database.
|
|
Note:If the database name contains special characters such as “.” or “-”, you need to enclose it in “``”.
Some PHP versions are not compatible with the MySQL new authentication plugin caching_sha2_password
. Starting from MySQL 8.0.4, the default authentication plugin for MySQL has been changed from mysql_native_password
to caching_sha2_password
. Waline does not support this authentication method by now. If the account provided to Waline uses the caching_sha2_password
authentication plugin, Waline will not be able to start correctly. You can change the authentication plugin to mysql_native_password
by changing the user’s password.
|
|
Note:For security reasons, it is recommended to create a separate account for Waline with the
mysql_native_password
authentication instead of changing the authentication method of an existing account.
Start a MySQL prompt with Waline’s MySQL account, and import waline.sql to create the Waline data structure.
|
|
Install Waline
npm
have been installed on your system. Some official of the Linux distributions may only provide elder versions of Node.js. You can follow the instructions on installing Node.js via package manager to install a proper version.Install Waline directly using npm
|
|
Note:Without –prefix <waline_install_dir> option, Waline will be installed to the current working directory by default.
Configure Waline
Currently, almost all the Linux distributions use systemd
, so we will use systemd
to manage the Waline service. First, you need to create a systemd
unit file, create the waline.service file under the path /etc/systemd/system/multi-user.target.wants/, and fill in the your configurations. Here is an example using MySQL:
|
|
systemd
supports the syntaxEnvironment=<param1>=<value1> "<param2>=<value2> <value3>"
to add environment variables.systemd
also supports usingEnvironmentFile=<file_path>
to specify the environment configure file. Adding a prefix “-” before the <file_path> ignores the read error if the file does not exist. Other database environment variables configuration can be found in the Official Documentation.
After creating the unit file, use sudo systemctl daemon-reload
to reload the systemd unit and then start Waline.
|
|
You can use sudo systemctl status waline
to check the current running status of Waline. If Active is shown, it indicates Waline is now running.
|
|
If error occurs, you can use
sudo journalctl -u waline
to view the complete Waline running log for debugging.
If Waline is running properly, you can access http://<server IP or domain name>:8360/ui/register
to register a user account. The first registered user will automatically become an administrator.
Traffic of port 8360 needs to be allowed for Waline web accessing. If you don’t want to use a port to access Waline, you can refer to Nginx Reverse Proxy.