如何在宝塔部署Flarum并进行基本配置

mtr MTR

warning 本文默认你安装了lnmp

环境

本文使用Nginx(1.18)、MySQL 5.7.34、php 8.0.2。

配置

进入软件商店-php8.0-设置,选择安装扩展
stings
fileinfo
确保安装fileinfo扩展,否则无法继续安装

primary 如果安装不上,请尝试暂停MySQL后再试(生产环境请勿暂停!

然后进入禁用函数选项卡,删除“putenv 、 pcntl_signal 以及 proc_open”.

disable-disable

同时,建议在配置修改选项卡把以下框上的两个分别改为600、512.

提示

更改本项可以防止扩展执行超时,如果不更改此项可能导致频繁报错!

sts

安装

Composer

通过SSH连接(或通过“终端”连接),执行以下命令:

1
2
3
4
5
cd
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer

这将会为你安装Composer

更换源地址(可选)

引用自ryanc.cc

由于 Composer 的服务器在国外,可能导致下载 Flarum 已经依赖包会很慢,所以我们需要更换一下源地址。至于 Composer 是啥,其实就是 PHP 的一个包管理,类似 Java 的 Maven 和 Gradle 工具。

1
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

如果没解禁了putenv() 函数,会导致此命令执行失败,非大陆服务器无需执行

创建站点,开始安装

  1. 直接照常创建即可,其中数据库请选择utf8mb4.

Flarum也支持一些其他的数据库,如mariaDB等

image.png

  1. PHP版本请选择8。创建站点之后请配置SSL,并启用HSTS(强制SSL)。

ss

如果不启用强制SSL,可能导致部分资源访问出错。

  1. 进入根目录

img 点击根目录即可快速进入

如没有完全删除删净文件,安装Flarum时会报错。删不掉的文件可以再试一次。

ss

4.接下来打开上方的终端,并执行以下命令。

1
composer create-project flarum/flarum .

s
出现本提示直接按下Enter按键即可。

12
出现类似的提示就是安装成功了。

安装完成,但是还需要进一步配置。

安装完成,进行配置

关掉终端,来到“网站”选项卡,打开刚刚搭建的网站。

进入第三个“网站目录”,进行如下更改:

随后,在“伪静态”中输入以下内容:

忽略本项可导致论坛访问(如后台)404

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Pass requests that don't refer directly to files in the filesystem to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}

# Uncomment the following lines if you are not using a `public` directory
# to prevent sensitive resources from being exposed.
# location ~* ^/(\.git|composer\.(json|lock)|auth\.json|config\.php|flarum|storage|vendor) {
# deny all;
# return 404;
# }

# 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/javascript
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;

记得保存。

随后,来到站点根目录,全选所有文件,随后按照如图所示操作.

接下来,访问你的论坛吧!

安装后配置

如果你现在访问论坛,会发现出现如下画面,因为还没有经过初始化。

可以参照我的填法进行填充:

好耶!你现在也拥有一个属于自己的Flarum论坛了!

然而,这距离真正的使用还差了一点。

如何安装扩展

适用于语言包、主题或者功能性扩展

  1. 来到站点根目录,并打开“终端”

  2. 输入

    1
    composer require ***

    (星号为要安装的扩展)

进入后台

中文语言包

首先,你一定想要把页面改为中文吧,然而,Flarum本身不带任何语言包(除了英语),你需要自行安装。

安装指令:

1
composer require flarum-lang/chinese-simplified

如何启用:进入后台,把左边的扩展列表划到最下面



其他扩展安装(不推荐)

本扩展列表仅能保证兼容Flarum 1.2.0。

我将分享一个composer.json文件的内容,下载后请覆盖根目录的原composer.json,然后在根目录执行

1
composer update

之后,来到后台即可发现安装了无数扩展,你就可以按需启用了。

内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
"name": "flarum/flarum",
"description": "Delightfully simple forum software.",
"type": "project",
"keywords": [
"forum",
"discussion"
],
"homepage": "https://flarum.org/",
"license": "MIT",
"authors": [
{
"name": "Flarum",
"email": "info@flarum.org",
"homepage": "https://flarum.org/team"
}
],
"support": {
"issues": "https://github.com/flarum/core/issues",
"source": "https://github.com/flarum/flarum",
"docs": "https://docs.flarum.org/"
},
"require": {
"afrux/asirem": "^0.1.6",
"afrux/forum-stats-widget": "*",
"afrux/news-widget": "*",
"afrux/online-users-widget": "*",
"afrux/top-posters-widget": "*",
"askvortsov/flarum-categories": "^3.0",
"askvortsov/flarum-moderator-warnings": "^0.6.1",
"askvortsov/flarum-rich-text": "^2.1",
"blessing/flarum-oauth-client": "^2.0",
"clarkwinkelmann/flarum-ext-emojionearea": "^1.0",
"clarkwinkelmann/flarum-ext-group-list": "^1.0",
"clarkwinkelmann/flarum-ext-who-read": "^1.4",
"darkle/fancybox": "^1.0",
"dem13n/topic-starter-label": "^0.1.7",
"ffans/lang-simplified-chinese": "v1.1.1.1220",
"flarum-lang/chinese-simplified": "v1.1.1.1220",
"flarum/approval": "*",
"flarum/bbcode": "*",
"flarum/core": "^1.2",
"flarum/emoji": "*",
"flarum/flags": "*",
"flarum/lang-english": "*",
"flarum/likes": "*",
"flarum/lock": "*",
"flarum/markdown": "*",
"flarum/mentions": "*",
"flarum/nicknames": "*",
"flarum/pusher": "*",
"flarum/statistics": "*",
"flarum/sticky": "*",
"flarum/subscriptions": "*",
"flarum/suspend": "*",
"flarum/tags": "*",
"flarumite/simple-spoilers": "^1.0",
"fof/best-answer": "^1.1",
"fof/cookie-consent": "^1.0",
"fof/drafts": "*",
"fof/frontpage": "^1.0",
"fof/gamification": "^1.3",
"fof/html-errors": "^1.0",
"fof/impersonate": "*",
"fof/linguist": "^1.0",
"fof/links": "^1.0",
"fof/merge-discussions": "*",
"fof/nightmode": "^1.2",
"fof/pages": "^1.0",
"fof/polls": "^1.0",
"fof/prevent-necrobumping": "^1.0",
"fof/profile-image-crop": "^1.0",
"fof/sitemap": "^1.0",
"fof/socialprofile": "^1.1",
"fof/split": "^1.0",
"fof/subscribed": "^1.0",
"fof/terms": "^1.1",
"fof/upload": "^1.1",
"fof/user-bio": "^1.0",
"fof/user-directory": "^1.2",
"fof/username-request": "^1.0",
"ganuonglachanh/sonic": "^0.1.5",
"ianm/flarum-diff": "^3.0",
"ianm/level-ranks": "*",
"ianm/syndication": "*",
"ianm/synopsis": "^1.2",
"jslirola/flarum-ext-login2seeplus": "^0.2.0",
"justoverclock/auto-post-count-badge": "*",
"justoverclock/discussion-info": "*",
"justoverclock/flarum-ext-contactme": "^0.2.3",
"justoverclock/flarum-ext-guestengagement": "^1.0",
"justoverclock/hot-discussions": "*",
"kilowhat/flarum-ext-audit-free": "^1.4",
"kvothe/pipetables": "^1.0",
"kyrne/whisper": "^0.1.4",
"lawaxi/harmony": "*",
"league/oauth2-github": "^3.0",
"malago/flarum-ads": "^0.3.2",
"minishlink/web-push": "^6.0",
"nearata/flarum-ext-embed-video": "^3.0",
"pipecraft/flarum-ext-id-slug": "^1.1",
"serakoi/flarum-skyswift": "^0.0.6",
"subasteve/flarum-action-log": "^0.1.5",
"sycho/flarum-profile-cover": "^1.3",
"the-turk/flarum-diff": "^1.1",
"v17development/flarum-user-badges": "^1.0",
"webbinaro/flarum-age-check": "*",
"yannisme/cntheme": "^1.0",
"yannisme/confixtheme": "^2.3",
"yannisme/oxotheme": "^2.1",
"zequeen/acgembed-remastered": "^1.1",
"zerosonesfun/direct-links": "^3.0"
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}

这些已经足够一般社区使用。

通过常规方法安装扩展?

你可以访问Extiverse 来获取扩展。在Extiverse,几乎99%的兼容最新Flarum的扩展都可以被找到。

还是不会部署?

你可以通过QQ联系我(2678015815),但是开学了时间少了,我可以免费代部署。其他的一些问题也可以咨询我。

  • 本文标题:如何在宝塔部署Flarum并进行基本配置
  • 本文作者:mtr
  • 创建时间:2023-02-12 12:12:12
  • 本文链接:https://blog.mtr.pub/2023/02/12/wp-deploy-flarum-in-bt/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
 评论