Beginning
Hello there! Recently, I’ve been thinking about moving my blog system from WordPress/GitHub Pages to a more reliable environment. My friend Edi Wang mentioned that his Moonglade Blog System can be deployed without Azure, and I’ve been interested in his blog system for a long time. So, I decided to start my 996 deployment.
Environment Setup:
- A server (Windows/Linux; I chose a Vultr VPS with Ubuntu 24.04 LTS x64 for this guide)
- A domain with properly configured DNS pointing to your server
-
An already set-up database(Means ctreat database,tables can be automatically creat by Moonglade)
Some Tips:
- Sever chosening :You can opt for an Oracle ‘Always Free’ cloud instance for the Linux server, but the firewall settings can be quite complex.If u r looking for a cheap but reliable vps,try vultr with my aff.I recommend a 1 CPU, 1 GB RAM server for $5/month, which I’ve tested and found adequate for this system.
- Database & Domain : Moonglade supports multiple database systems (Microsoft SQL Server, MySQL, PostgreSQL. Please Check this link FYI). Database setup is not covered in this guide. The same applies to domain registration and DNS configuration.
- Why not Dockers :as my saids in title,an reliable environment.
- Building Soucre Code : Using the Release Version is highly recommended; avoid using the master branch.
Setp to setp deployment
Get code and Build project
download the latest “Source code(zip)” in https://github.com/EdiWang/Moonglade/releases in a Linux/Windows environment.I strongly recommend that you start compiling from the source code. Because every time I use the version compiled by github, strange problems will occur.
If your Linux server performance is good enough, it’s okay to build by following these steps
Install .NET on Linux:
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-8.0
Move to the project source file:
cd Moonglade-14.8.0\src\Moonglade.Web
then build
dotnet publish --configuration Release -o /path/to/output
You will find the directory in /path/to/output as you set.
or
use Viusal Studio in Windows Build source code by urself,then install asp.net runtime on ur server
sudo apt-get update && \
sudo apt-get install -y aspnetcore-runtime-8.0
Set server eniverment
Log in to your server,upload Moongalde (I choose /var/www/Moonglade for example) and install Nginx
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
If your server’s performance is weak and you build on another environment, you should install the .NET runtime to run Moonglade:
sudo apt-get update && \
sudo apt-get install -y aspnetcore-runtime-8.0
Test Nginx and get a SSL Cert
curl http://localhost
If Nginx is working, you should see the Nginx welcome page, which looks like this:
root@vultr:~# curl http://localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
root@vultr:~#
Try entering http://{your_server_ip} to double-check the Nginx welcome page. If you encounter a 404 or 521 error, check the firewall settings.
now use certbot to get free SSL cert:
sudo apt-get install certbot python3-certbot-nginx
sudo certbot --nginx
Register your email address and domain name. If your DNS is correct, this should be an easy task, and the certificate will automatically be stored on your server and configured in Nginx. Once everything is set up, configure automatic certificate updates:
sudo certbot renew --dry-run
You can use curl or a web browser to check the HTTPS status.
Deploy Moonglade
First, move to the location of the Moonglade files (or upload them to your server if you haven’t already; let’s assume the document name is “Moonglade”). Then, set up Moonglade using nano:
nano Moonglade/appsettings.json
The configuration JSON will look like this :
{
"ConnectionStrings": {
"MoongladeDatabase": "Server=(localdb)\\MSSQLLocalDB;Database=moonglade;Trusted_Connection=True;",
"DatabaseType": "SqlServer"
},
"Authentication": {
"Provider": "Local",
"EntraID": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "",
"TenantId": "",
"ClientId": "",
"CallbackPath": "/signin-oidc"
}
},
"ContentModerator": {
"Provider": "Local",
"ApiEndpoint": "",
"ApiKey": ""
},
"Email": {
"ApiEndpoint": "",
"ApiKey": "",
"ApiKeyHeader": "x-functions-key"
},
"ForwardedHeaders": {
"Enabled": false,
"HeaderName": "",
"KnownProxies": []
},
"ImageStorage": {
"AllowedExtensions": [ ".png", ".jpg", ".jpeg", ".gif" ],
"Provider": "filesystem",
"FileSystemPath": "C:\\UploadedImages",
"AzureStorageSettings": {
"ConnectionString": "",
"ContainerName": ""
},
"MinioStorageSettings": {
"EndPoint": "",
"AccessKey": "",
"SecretKey": "",
"BucketName": "",
"WithSSL": false
}
},
"Editor": "HTML",
"AllowPingbackToLocalhost": false,
"AllowPingbackFromLocalhost": false,
"AllowWebmentionToLocalhost": false,
"AllowWebmentionFromLocalhost": false,
"CacheSlidingExpirationMinutes": {
"Post": 20,
"Page": 20,
"Image": 60,
"Widget": 30
},
"Setup": {
"AutoDatabaseMigration": true,
"SQLScriptDownloadTimeout": 30,
"DatabaseMigrationScript": {
"SqlServer": "https://raw.githubusercontent.com/EdiWang/Moonglade/master/Deployment/mssql-migration.sql",
"MySql": "",
"PostgreSql": ""
}
},
"Experimental": {
"SetLastModifiedHeaderForPages": true,
"ChinaFriendly": true
},
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft": "Warning"
}
},
"AllowedHosts": "*"
}
Remember to paste your database connection string into "MoongladeDatabase" (and manually set "DatabaseType" as well). Then, carefully set "ImageStoragePath"—I set mine to /var/www/MoongladeUploadedImages. The JSON will look like this:
"ImageStorage": {
"AllowedExtensions": [ ".png", ".jpg", ".jpeg", ".gif" ],
"Provider": "filesystem",
"FileSystemPath": "/var/www/MoongladeUploadedImages",
"AzureStorageSettings": {
"ConnectionString": "",
"ContainerName": ""
},
"MinioStorageSettings": {
"EndPoint": "",
"AccessKey": "",
"SecretKey": "",
"BucketName": "",
"WithSSL": false
}
Then, copy the files to /var/www/ and create the UploadedImages directory as shown in my command:
sudo cp -r Moonglade /var/www/
sudo mkdir /var/www/MoongladeUploadedImages
Try to run Moonglade for the first time
cd /var/www/Moonglade
dotnet Moonglade.Web.dll
If everything goes well, you should see this in the console:
Configure Nginx to Route to Moonglade
We need to set a port for the Moonglade service, using port 4560 as follows. Afterward, we need to set up Nginx :
cd /etc/nginx/sites-enabld
Using the `ls` command, you should see only a default file in this path. You can create a new configuration file.
sudo nano Moonglade
And paste this: :
server {
listen 443 ssl;
server_name {your domain};
ssl_certificate /etc/letsencrypt/live/{your domain}/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/{your domain}/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://localhost:4560; # .NET application port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
if ($host = {your domain}) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name {your domain};
return 404; # managed by Certbot
}
This configuration is for HTTPS and redirects HTTP to HTTPS. Save the file, remove the default configuration, and test it.
sudo mv /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default.backup
sudo nginx -t
sudo systemctl restart nginx
If everything goes well, you can start Moonglade in the background.
cd /var/www/Moonglade
sudo nohup dotnet Moonglade.Web.dll --urls "http://localhost:4560" &
`nohup` will handle Moonglade well..
Things to note
Shutdown Moonglade
Just kill it
pgrep -f Moonglade
kill <PID>
Can’t show Captcha Code
So, on a Linux system, you need to install the ‘OpenSans-Bold’ font. Download it from [this link](https://github.com/EdiWang/Moonglade/tree/master/build) and upload it to your server. Then:
sudo mkdir -p /usr/share/fonts/opentype/OpenSans
sudo cp OpenSans-Bold.ttf /usr/share/fonts/opentype/OpenSans/
check it
fc-cache -fv
fc-list | grep "OpenSans-Bold"
everythins go well just kill Monglade and start again.
Can’t upload pictures on writring post(HTTP 500)
Because the image storage path is set to `/var/www/`, which requires root authentication to access, restart Moonglade with `sudo`.
Wise you enjoy!