Hi, my technology forum is online!

Posted by Havery Jay on Wed, 16 Feb 2022 03:49:40 +0100

Last weekend, I launched my personal blog site [1]. You can collect and subscribe to it if you are interested. Future learning articles will be synchronized here for the first time: https://devopsman.cn

Many experienced gods can see what wordpress does here at a glance. They have used hugo and Hexo before, but how to say, they are not very satisfied, so they can use this temporarily before they encounter a satisfactory theme.

After tossing WordPress over the weekend, I found that his message function looks very weak. For example, when I write some notes, I can't finish writing an article, but if I comment, I can only leave a message for discussion under a certain article, which is not conducive to learning and retrieval for a long time. However, the forum can start a discussion on a topic at any time, so it found flarum.

The place used to record and provide you with online discussion of technical issues is mainly interested in his simplicity and freshness. The most important thing is the timeline of his communication area, as follows:

Construction background

Facilitate discussion on a technical topic. Easy retrieval. After all, QQ groups and wechat groups are mostly blowing water, which is not conducive to information induction and retrieval. Everyone knows...

Manual installation

Record the construction process of flarum.

Because my personal blog site uses wordpress Therefore, there is a ready-made PHP environment in the environment, which can be opened directly according to the official documents. If your environment is clean, you need to install PHP, PHP FPM and other software environments in advance, as well as the support of composer. For details, please refer to the installation document of flarum Chinese community [2]

flarum is installed through composer, so install composer first

# wget -O composer-setup.php https://getcomposer.org/installer
# php composer-setup.php --install-dir=/usr/local/bin --filename=composer
# composer -v
Composer version 2.2.4 2022-01-08 12:30:42

Next, create an installation directory of flarum files and directly download the source code to this directory

mkdir /apps/flarum && cd $_
# Download flarum source code
composer create-project flarum/flarum . --stability=beta --ignore-platform-req=ext-fileinfo

Finally, configure nginx proxy flarum forum Note that some annotated parameters need to be configured or modified.

server {
    listen 80;
    listen 443 ssl http2;

    ssl_certificate /www/server/panel/vhost/nginx/ssl/flarum.devopsman.cn_bundle.pem; # https certificate of flarum Forum
    ssl_certificate_key /www/server/panel/vhost/nginx/ssl/flarum.devopsman.cn.key;
    #include snippets/ssl-params.conf;

    # should be changed
    server_name flarum.devopsman.cn; # Modify to your own domain name
    client_max_body_size 20m; # modify

    root /www/flarum/public/; # Installation directory of flarum
    index index.php index.html;

    server_tokens off;
    access_log /www/wwwlogs/flarum-access.logi main; # Define the log parsing format and storage location of the forum
    error_log /www/wwwlogs/flarum-error.log;

    # prevent webshell attack
    location ~ ^/assets.*\.php {
        deny all;
        return 404;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000; # Here is the php FPM service address for parsing php
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

   # Pass requests that don't refer directly to files in the filesystem to index.php
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /sitemap.xml {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # The following directives are based on best practices from H5BP Nginx Server Configs
    # https://github.com/h5bp/server-configs-nginx

    # Expire rules for static content
    location ~* \.(?:manifest|appcache|html?|xml|json)$ {
        add_header Cache-Control "max-age=0";
    }

    location ~* \.(?:rss|atom)$ {
        add_header Cache-Control "max-age=3600";
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc)$ {
        add_header Cache-Control "max-age=2592000";
        access_log off;
    }

    location ~* \.(?:css|js)$ {
        add_header Cache-Control "max-age=31536000";
        access_log off;
    }

    location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
        add_header Cache-Control "max-age=2592000";
        access_log off;
    }

    # Gzip compression
    gzip on;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
        application/atom+xml
        application/javascript
        application/json
        application/ld+json
        application/manifest+json
        application/rss+xml
        application/vnd.geo+json
        application/vnd.ms-fontobject
        application/vnd.api+json
        application/x-font-ttf
        application/x-web-app-manifest+json
        application/xhtml+xml
        application/xml
        font/opentype
        image/bmp
        image/svg+xml
        image/x-icon
        text/cache-manifest
        text/css
        text/plain
        text/vcard
        text/vnd.rim.location.xloc
        text/vtt
        text/x-component
        text/x-cross-domain-policy;
}

It's basically finished here. During initialization, you need to initialize the MySQL database, so you can prepare the remote connection account in advance. Access address: https://flarum.devopsman.cn

This is the front page of flarum. Some problems are also encountered during deployment. For example, the interface message 500 is found when uploading pictures. These problems can be found through the operation log under the flarum installation directory:

The classified labels of flarum are also very distinctive. You can quickly read the discussion of the specified labels:

Containerization

Because I already have nginx, php, MySQL, etc. in my own running environment, it is easier and more efficient for me to install flarum directly. If you start from scratch, you can use container deployment:

https://github.com/devsecops-ecosystem/flarum-docker-env.git

Here, you can directly deploy it through docker compose with one click and modify it slightly.

Finally, welcome to build and maintain the cloud primary ecosystem - technology forum

reference material

[1] Yunyuan ecosystem: https://devopsman.cn

[2]flarum Chinese document: https://discuss.flarum.org.cn/d/1246