AsmBB

Power
Login Register

How to install AsmBB on VPS with Nginx and systemd

#15366 (ツ) johnfound
Created 25.02.2018, read: 28538 times

How to install AsmBB on VPS with Nginx and systemd

Recently I 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 /etc/nginx/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.

#15447 (ツ) ufuk
Created 29.06.2018, read: 24567 times

hi,

i need some help.

can you send me an example ngnix conf file.

thanks

#15448 (ツ) johnfound
Last edited: 30.06.2018 by johnfound, read: 24556 times
ufuk

hi,

i need some help.

can you send me an example ngnix conf file.

thanks

Well here it is. 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;
#15591 (ツ) ufuk
Last edited: 03.11.2018 by ufuk, read: 23450 times
johnfound
ufuk

hi,

i need some help.

can you send me an example ngnix conf file.

thanks

Well here it is. 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;

hi,

what is the wrong ?


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

server {
    listen       80;
    server_name  http://34.245.193.84;   
    root   /etc/asmbb;
    access_log /etc/asmbb/board_access.log combined buffer=32k flush=5m;

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

#15592 (ツ) johnfound
Created 04.11.2018, read: 23444 times
ufuk

hi,

what is the wrong ?


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

server {
    listen       80;
    server_name  http://34.245.193.84;   
    root   /etc/asmbb;
    access_log /etc/asmbb/board_access.log combined buffer=32k flush=5m;

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

I don't know actually. The server_name seems wrong. Should be without http://:

server_name  34.245.193.84;   

But right now, on IP 34.245.192.84 is no working web server at all. At least on port 80.

#15593 (ツ) ufuk
Created 06.11.2018, read: 23402 times
johnfound
ufuk

hi,

what is the wrong ?


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

server {
    listen       80;
    server_name  http://34.245.193.84;   
    root   /etc/asmbb;
    access_log /etc/asmbb/board_access.log combined buffer=32k flush=5m;

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

I don't know actually. The server_name seems wrong. Should be without http://:

server_name  34.245.193.84;   

But right now, on IP 34.245.192.84 is no working web server at all. At least on port 80.

hi, thanks

i fixed it. but now i get bad gateway error

http://52.212.49.177/

thanks

#15594 (ツ) ufuk
Created 06.11.2018, read: 23401 times
ubuntu@ip-1712:~$ sudo systemctl start asmbb
ubuntu@ip-1712:~$ sudo systemctl status asmbb
● asmbb.service - AsmBB forum engine FastCGI script.
   Loaded: loaded (/etc/systemd/system/asmbb.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-11-06 17:24:16 UTC; 31min ago
 Main PID: 3313 (engine)
    Tasks: 2 (limit: 547)
   CGroup: /system.slice/asmbb.service
           └─3313 /etc/asmbb/engine

Nov 06 17:24:16 ip-17112 systemd[1]: Started AsmBB forum engine FastCGI script.


#15595 (ツ) johnfound
Created 07.11.2018, read: 23396 times

Generally speaking "bad gateway" means, that the web server can't communicate to the FastCGI server through the specified socket.

But I see, that the asmbb engine works.

Is the socket /etc/asmbb/engine.sock exists after the engine is started?

Do the user that runs nginx server has access to this socket (and directory)?

Is the database (the file /etc/asmbb/board.sqlite) exists after the engine is started?

Actually locating AsmBB (or any other web application, regardless of the language) in /etc/ is somehow strange, because the files in /etc/ directory are usually owned by root and read-only for all other users.

But the engine itself and the web server must have full access to this directory in order everything to work. The web server at least must have read/write access to the socket.

Regards

#15596 (ツ) ufuk
Created 07.11.2018, read: 23392 times

thanks. Can it be about folder ownership ? Must i use nonroot user ?

#15597 (ツ) johnfound
Created 07.11.2018, read: 23391 times
ufuk

thanks. Can it be about folder ownership ? Must i use nonroot user ?

I am using only nonroot users for AsmBB directories and files. I can't say exactly what is the problem in your case. But it worth to test with different user permissions. IMHO. :-)

It is absolutely clear, that the user of the web server (nginx) must be able to read and write to the FastCGI interface socket. Of course the AsmBB user must be able to write to the AsmBB directory in order to be able to create the database and other files. Actually these two are the only mandatory requirements. This way, you can fine tune the users permissions from the security point of view. But I am not so experienced in Linux/Unix system administration in order to give detailed recommendations.

#15598 (ツ) ufuk
Last edited: 07.11.2018 by ufuk, read: 23382 times

hi, now i reinstalled, used root. and got this erros


2018/11/07 18:46:15 [crit] 3761#3761: *22 connect() to unix:/etc/asmbb/engine.sock failed (13: Permission denied) while connecting to upstream, client: 176.111.111.111.111, server: 54.154.211.89, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/etc/asmbb/engine.sock:", host: "54.154.211.89"



#15599 (ツ) johnfound
Created 07.11.2018, read: 23380 times
ufuk

hi, now i reinstalled, used root. and got this erros


2018/11/07 18:46:15 [crit] 3761#3761: *22 connect() to unix:/etc/asmbb/engine.sock failed (13: Permission denied) while connecting to upstream, client: 176.111.111.111.111, server: 54.154.211.89, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/etc/asmbb/engine.sock:", host: "54.154.211.89"

This seems to be error of the nginx (please, be more detailed in these messages). What you reinstalled? You definitely should not run AsmBB as root!

Try to run AsmBB from the same user as nginx (check the option user USERNAME; in the /etc/nginx/nginx.cong file); Also, set the owner of the directory where AsmBB is installed to the same USERNAME.

#15600 (ツ) ufuk
Created 07.11.2018, read: 23376 times

hi,

i mean i made a fresh install on a new server. but no sucses. i also tried non-root user. it is ufuk.


root@ip-1......5:~# ls -l /etc/asmbb
total 3748
-rw-r--r-- 1 ufuk ubuntu   13512 Sep  8 20:44 License.txt
-rw-r--r-- 1 ufuk root   1389115 Nov  7 18:06 asmbb.tar.gz
-rw-r--r-- 1 ufuk root      4096 Nov  7 19:47 asmbb_ipc.bin
-rw-r--r-- 1 ufuk root    364544 Nov  7 18:59 board.sqlite
-rw-r--r-- 1 ufuk root     32768 Nov  7 18:59 board.sqlite-shm
-rw-r--r-- 1 ufuk root     12392 Nov  7 18:59 board.sqlite-wal
-rw-r--r-- 1 ufuk root     13950 Nov  7 19:45 board_access.log
-rwxr-xr-x 1 ufuk ubuntu  126046 Sep  8 20:44 engine
srwxr-xr-x 1 ufuk root         0 Nov  7 18:59 engine.sock
drwxr-xr-x 5 ufuk ubuntu    4096 Sep  8 20:44 images
-rw-r--r-- 1 ufuk ubuntu    6833 Sep  8 20:44 install.txt
-rwxr-xr-x 1 ufuk ubuntu  759544 Sep  8 20:44 ld-musl-i386.so
-rwxr-xr-x 1 ufuk ubuntu 1073520 Sep  8 20:44 libsqlite3.so
-rw-r--r-- 1 ufuk ubuntu    1204 Sep  8 20:44 lighttpd.conf
-rw-r--r-- 1 ufuk ubuntu      41 Sep  8 20:44 manifest.uuid
drwxr-xr-x 7 ufuk ubuntu    4096 Sep  8 20:44 templates

#15623 (ツ) jose
Created 17.11.2018, read: 23206 times

Hey. Very nice software BTW.

I'm also running into problems when installing. VPS with NGINX and several domains running well. Browser gives med 502 Bad Gatewy

and...

root@isos:/etc/nginx/sites-available# systemctl status asmbb
● asmbb.service
   Loaded: loaded (/etc/systemd/system/asmbb.service; bad; vendor preset: enabled)
   Active: failed (Result: start-limit-hit) since Sat 2018-11-17 00:30:00 UTC; 1s ago
  Process: 19319 ExecStart=/var/www/mysite.dk/public_html/engine (code=exited, status=1/FAILURE)
 Main PID: 19319 (code=exited, status=1/FAILURE)

Nov 17 00:30:00 isos systemd[1]: asmbb.service: Service hold-off time over, scheduling restart.
Nov 17 00:30:00 isos systemd[1]: Stopped asmbb.service.
Nov 17 00:30:00 isos systemd[1]: asmbb.service: Start request repeated too quickly.
Nov 17 00:30:00 isos systemd[1]: Failed to start asmbb.service.
Nov 17 00:30:00 isos systemd[1]: asmbb.service: Unit entered failed state.
Nov 17 00:30:00 isos systemd[1]: asmbb.service: Failed with result 'start-limit-hit'.
#15624 (ツ) johnfound
Last edited: 17.11.2018 by johnfound, read: 23202 times
jose

Hey. Very nice software BTW.

I'm also running into problems when installing. VPS with NGINX and several domains running well. Browser gives med 502 Bad Gatewy

It is not so "nice" if it crashes miserably. rofl

Anyway, lets make it work:

At first, the directory where engine is installed looks somehow suspiciously. AsmBB needs separate subdomain. For example http://forum.mysite.dk, but not http://mysite.dk/forum/. So, this /var/www/mysite.dk/public_html/ looks wrong, unless you want to have forum on http://public_html.mysite.dk and have this subdomain configured properly.

check for existence of the file engine.sock, delete it if exists and restart the AsmBB engine again.

check for existence of the file "fault.txt" and attach it here or send it to me on email (johnfound at asm32 dot info). It contains the stack dump and the register values in the moment of the crash.

give me more details on what you are doing and how the crash happened.

#15625 (ツ) jose
Last edited: 17.11.2018 by jose, read: 23192 times
johnfound

It is not so "nice" if it crashes miserably. rofl

Anyway, lets make it work:

At first, the directory where engine is installed looks somehow suspiciously. AsmBB needs separate subdomain. For example http://forum.mysite.dk, but not http://mysite.dk/forum/. So, this /var/www/mysite.dk/public_html/ looks wrong, unless you want to have forum on http://public_html.mysite.dk and have this subdomain configured properly.

check for existence of the file engine.sock, delete it if exists and restart the AsmBB engine again.

check for existence of the file "fault.txt" and attach it here or send it to me on email (johnfound at asm32 dot info). It contains the stack dump and the register values in the moment of the crash.

give me more details on what you are doing and how the crash happened.

Well the software is very nice on your site ;)

I have multiple sites on my webserver and the directory structure is

/var/www/site1.dk/public_html
/var/www/site2.dk/public_html

etc

the public_html directory is where the server files live. It's not a subdirectory. Works with no problem in the other 5 domains in the same VPS.

server root is for me mydomain

/var/www/siteX.dk/public_html

I can serve html and php without problems from same domain, if i comment out

        fastcgi_pass unix:/var/www/mysite.dk/public_html/engine.sock;
        include fastcgi_params;

Otherwise i get 502 bad Gateway

There is no subdomain defined for that domain so the asmbb sofware resides on the root of the webserver.

i cannot find - engine.sock - fault.txt

#15626 (ツ) johnfound
Created 17.11.2018, read: 23187 times
jose

I have multiple sites on my webserver and the directory structure is

/var/www/site1.dk/public_html
/var/www/site2.dk/public_html

etc

the public_html directory is where the server files live. It's not a subdirectory. Works with no problem in the other 5 domains in the same VPS.

I see no problems with your configuration. It should work this way.

jose

Otherwise i get 502 bad Gateway

There is no subdomain defined for that domain so the asmbb sofware resides on the root of the webserver.

i cannot find - engine.sock - fault.txt

Then, the engine has never started. You should not find the main database as well.

So, lets fix it:

First of all, download the binary package again and update at least the executable file engine. I have made right now some changes that should fix possible issues with the socket permissions and the different users running nginx and asmbb engine.

What is the user you are trying to run AsmBB? It is in the line user=XXXX in the asmbb.service file you created.

Make sure the directory owner of the AsmBB directory is the same user and it has write permissions in this directory.

Try to run the service again with sudo systemctl start asmbb. If it refuse to run, navigate to the AsmBB directory and try to run ./engine manually from the console in order to check what happens. After successful first start it should create the main database board.sqlite.

#15627 (ツ) jose
Created 17.11.2018, read: 23184 times

You did magic and amazingly fast too. Thank you very very much

I just downloaded the new version and restarted the asmbb service and it started right away. It works in both a subdirectory forum.mysite.dk and mysite.dk. I'll experiment with this further.

I'm running a VPS (5 dollars) on Digital Ocean on Ubuntu and Nginx and with 7-8 different domains.

My prefered forum sofware is actually NoNonsense Forum. The reason is that its fast and nice and most important you don't need to register. Just provide a username and a password to protect the username and that's it. I use it as a light commenting system and it works perfectly with few users and posts.

I will be testing ASMBB as a more traditional forum for another site with 300- 1000 users and other usage type.

If others get problems in the future here my very simple configuration.

My asmbb service

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

[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/mysite.dk/public_html
ExecStart=/var/www/mysite.dk/public_html/engine
Restart=on-failure

[Install]
WantedBy=nginx.service

and my simplest possible Nginx conf (i think it can't be much simpler) (server files are in public_html directory)

server {
        listen 80;
        root /var/www/mysite.dk/public_html;
        server_name mysite.dk forum.mysite.dk; 
location / {
        fastcgi_pass unix:/var/www/mysite.dk/public_html/engine.sock;
        include fastcgi_params;
        index index.php index.html index.htm;
             }
}

#15628 (ツ) johnfound
Created 17.11.2018, read: 23179 times
jose

You did magic and amazingly fast too. Thank you very very much

I just downloaded the new version and restarted the asmbb service and it started right away.

It seems that the problem was something with the user permissions. Actually I am not very good in all these Linux/Unix sysadmin things. :-) It is good everything works now.

Regards.

#15705 (ツ) ganuonglachanh
Created 03.12.2018, read: 22982 times

Hi, I'm trying to install with Docker, since it is not fully support systemd, can we use it with supervisord ? Any tutorial setting would be appreciated rofl

And with Docker when I run./engine to test, the CPU usage increase and it still failed to access the board in webbrowser (setting in nginx conf is done as the guide)

How to install AsmBB on VPS with Nginx and systemd

AsmBB v2.9 (check-in: 6d407831308ba556); SQLite v3.31.1 (check-in: 3bfa9cc97da10598);
©2016..2020 John Found; Licensed under EUPL. Powered by Assembly language Created with Fresh IDE