如何在宝塔部署Flarum并进行基本配置
注意
本文默认你安装了lnmp

环境

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

配置

进入软件商店-php8.0-设置,选择安装扩展

确保安装fileinfo扩展,否则无法继续安装

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

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

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

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

Composer

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

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 工具。
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

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

创建站点,开始安装

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

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

PHP版本请选择8

申请SSL

进入站点设置配置SSL👆

不然以后资源访问可能出错

建议开启强制SSL

点击根目录地址就可以直接跳转了

进入根目录

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

接下来打开上方的终端

执行以下指令:

composer create-project flarum/flarum .
当然,你不想看到这玩意的话,建议创建个新用户

出现提示直接按下回车即可

安装中

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

安装完成,进行配置

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

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

指定运行目录

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

警告
忽略本项可导致论坛访问(如后台)404
# 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.输入 composer require ***(星号为要安装的扩展)

进入后台

点击Administration即可

中文语言包

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

安装指令:

composer require flarum-lang/chinese-simplified

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

如图
点击

其他扩展安装

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

composer update

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

内容:

{
    "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联系我(3467317100),我可以免费代部署。其他的一些问题也可以咨询我。

暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇