Flarum beta9 安装

2019-11-23  本文已影响0人  realguan

一、compsoser 安装 Flarum 源码

先创建一个空文件夹作为项目目录,安装命令就是Flarum官方的命令:

sudo mkdir flarum  // 项目目录名自己定义
sudo chmod 777 flarum  // 为避免后面关于文件权限的问题,这里暂且给所有权
cd flarum
composer create-project flarum/flarum . --stability=beta

此处可能会报错,多为PHP的各种扩展的报错,如:curl、fileinfo。如果出现相关报错,请参考我的PHP安装教程:
Ubuntu 编译安装PHP7.3.8

二、Flarum Nginx 配置

安装完成后,我们先进行nginx配置,官方有nginx配置的样板,大家可以参考:
官方nginx配置参考
下面是我的nginx配置,供大家参考:

server {
    listen 80;
    listen [::]:80;

        server_name bbs.678fly.cn;    // 你的域名

    root /var/www/flarumbbs/public;    // 项目根目录
    index index.php index.htm index.html;

    access_log /var/log/nginx/bbs.678fly.cn.access.log;
    error_log /var/log/nginx/bbs.678fly.cn.error.log;

        # 此处以下都是复制的官方的配置,没有进行任何修改

    location ~* \.php$ {
        fastcgi_index   index.php;
        fastcgi_pass    127.0.0.1:9000;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }

    # Pass requests that don't refer directly to files in the filesystem to index.php
    location / {
            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/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;
}

设置完重启nginx即可

cd /etc/init.d
sudo nginx -s reload

三、Flarum 数据库配置

1、创建 Flarum 数据库

这里就不详细讲了,自己想好数据库名,编码设置 utf8 就行了。

2、Flarum 首次进入配置

浏览器输入域名进入首页,首次进入会有一些基本配置。安装的时候忘了截图,大概有以下需要配置项:

填完表单提交就OK了。大功告成!

上一篇 下一篇

猜你喜欢

热点阅读