How to install AsmBB on VPS with Nginx and systemd

0
(ツ) admin
Last edited: 02.03.2023 by admin
2965
16.11.2022

Recently I (JohnFound) migrated the whole my domain asm32.info on a new hosting - cheap $5 a month VPS from Vultr.

The migration was because of some bugs in Apache http2 module on my previous hosting provider that have broke the server sent events on the real time chat of AsmBB. As long as I was on a shared hosting, it was impossible to control the Apache settings, so I decided to take control in my hands. :)

Anyway, during the migration, I installed Nginx as a web server and in this post will explain how to setup AsmBB on this setting.

Prerequisites

For this tutorial I am assuming you have:

    Some Linux admin skills. You should be able to install packages and to setup a web server (at least following the countless tutorials on the Internet).

    Working GNU/Linux distribution with systemd. Of course any other distro will work, but you will need to setup the startup of AsmBB by yourself.

    Installed Nginx web server. I will explain only how to integrate AsmBB.

Installing AsmBB

Download the recent binary package from the permanent link: asmbb.tar.gz

Create a new directory, where the forum sub-domain will stay. I will name it PATH/TO/FORUM/. Put the downloaded file inside.

Untar with the following commands:

$ tar -xvzf asmbb.tar.gz
$ mv asmbb/* ./
$ rm -rf asmbb/

After the unpack, there are some unneeded files, like text files and example config files in the directory. You can safely delete them. Only the subdirectories and 3 executable files are required. Notice that the subdirectories may contain some important symlinks, so unpacking on local computer and then uploading through FTP will not work (because FTP can't copy symlinks).

All the files and the directory must be owned by some non-root user that will run AsmBB later. I will name it NON_ROOT.

Nginx configuration

Insert in the nginx config file (in etcnginx/nginx.cong or in the forum sub-domain configuration file) the following:

server {
  ..... # Your subdomain server configuration. 
        # Should contains at least "listen" and "server_name" nginx options.

  root /PATH/TO/FORUM/;

  location / {
    fastcgi_pass unix:/PATH/TO/FORUM/engine.sock;  
    include fastcgi_params;
  }
}

Don't forget to replace the placeholders!

Restart Nginx:

sudo systemctl restart nginx

Systemd configuration

Now configure systemd service that to manage AsmBB engine.

Will need root access here. Create as a root the file etc/systemd/system/asmbb.service with the following text (of course replace the placeholders PATH/TO/FORUM and NON_ROOT:

[Unit]
Description=AsmBB forum engine FastCGI script.
After=nginx.service

[Service]
Type=simple
User=NON_ROOT
WorkingDirectory=/PATH/TO/FORUM
ExecStart=/PATH/TO/FORUM/engine
Restart=on-failure

[Install]
WantedBy=nginx.service

Finalizing

You just finished the configuration.

Now you can open the forum sub-domain in your browser. You should get 502 bad gateway error, because AsmBB is still not running.

Now start AsmBB:

sudo systemctl start asmbb

Refresh the browser. The admin setup dialog of AsmBB should appear. Setup your admin user and the forum should start working in regular mode.

If everything is OK until now, let's make the startup of AsmBB automatic on server restart:

sudo systemctl enable asmbb

That is all. You now have working, blazingly fast web forum that can handle hundreds of users and million posts with very low system resources.

Login as an administrator and adjust the settings of the forum to your preferences.

Attached files:
FileSizeUploadedDownloadsMD5 hash
howto3.png34805 bytes02.03.20233341e0916bb42465031130fb79b5efec6e4
2963
16.11.2022

Well here is an example nginx conf file:

You must replace all placeholders with your real paths. I mean:

PATH_TO_ASMBB - where you put the AsmBB files.

PATH_TO_LOG_FILES - where you want nginx to store the log files.

PATH_TO_SSL_CERTIFICATES - where are placed your SSL certificates.

Also, the server_name value must to be replaced with the proper name for your setting.

# file: /etc/nginx/sites-available/board.conf
# AsmBB demo message board at https://board.asm32.info

server {
    listen       443 ssl http2;
    server_name  board.asm32.info;   
    root   /PATH_TO_ASMBB;
    access_log /PATH_TO_LOG_FILES/board_access.log combined buffer=32k flush=5m;

    location / {
        fastcgi_pass unix:/PATH_TO_ASMBB/engine.sock;
        include fastcgi_params;
    }

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_cache         shared:SSL:20m;
    ssl_session_timeout       60m;
    ssl_prefer_server_ciphers on;
    ssl_ciphers               ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DHE+AES128:!ADH:!AECDH:!MD5;

    ssl_certificate /PATH_TO_SSL_CERTIFICATES/fullchain.pem; 
    ssl_certificate_key /PATH_TO_SSL_CERTIFICATES/privkey.pem;
}

The file etc/nginx/fastcgi_params included in the location section is part of the standard nginx installation and contains only some environment variables:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

How to install AsmBB on VPS with Nginx and systemd

0