优米格
分享有营养的

安装composer及用composer安装flarum、插件的过程

BraUndress.png

Flarum是一个免费且开源论坛组件。这里记录了我部署Flarum论坛的过程。

一、环境

  • php 8.0
  • MariaDB 10.6.4 database server;
  • Debian 10;
  • nginx: 1.14.2;
  • 用户:winbert,非root

二、部署过程

2.1 部署composer

winbert@winbert-debian:~/flarum$ pwd
/home/winbert/flarum
winbert@winbert-debian:~/flarum$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
winbert@winbert-debian:~/flarum$ php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 2.1.11) successfully installed to: /home/winbert/flarum/composer.phar
Use it: php composer.phar

winbert@winbert-debian:~/flarum$ php -r "unlink('composer-setup.php');"
winbert@winbert-debian:~/flarum$ 
winbert@winbert-debian:~/flarum$ 
winbert@winbert-debian:~/flarum$ ls -al
total 2248
drwxr-xr-x 2 winbert winbert    4096 Nov  9 05:17 .
drwxr-xr-x 9 winbert winbert    4096 Nov  9 05:17 ..
-rwxr-xr-x 1 winbert winbert 2286233 Nov  9 05:17 composer.phar
winbert@winbert-debian:~/flarum$ 
winbert@winbert-debian:~/flarum$ sudo mv composer.phar /usr/local/bin/composer
winbert@winbert-debian:~/flarum$ composer --version
Composer version 2.1.11 2021-11-02 12:10:25

2.2 部署flarum

注意: Php安装后,默认的运行用户及用户组是www-data:www-data,这里我使用的winbert用户,所以你的情况跟我一样的话,请修改为你的当前用户,不然部署flarum及其他组件的时候会提示没有权限,修改方式参考: 如何更改php的运行用户?

winbert@winbert-debian:~/www/html/flarum$ pwd
/home/winbert/www/html/flarum
winbert@winbert-debian:~/www/html/flarum$
winbert@winbert-debian:~/www/html/flarum$ 
winbert@winbert-debian:~/www/html/flarum$ composer create-project flarum/flarum .

2.3 安装插件

flarum支持安装额外的插件,来完善自身功能,以安装简体中文包为例:

composer require flarum-lang/chinese-simplified
php flarum cache:clear

执行命令的位置是composer.jsoncomposer.lock所在目录。

三、访问论坛主页,进行论坛配置

我的nginx配置如下:

server {
    server_name bbs.ddmit.com;

    root /home/winbert/www/html/flarum/public;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm;

        location / {
          try_files $uri $uri/ /index.php?$args;
        }

    access_log  /var/log/nginx/ddmit-bbs.access.log;
    error_log  /var/log/nginx/ddmit-bbs.error.log;

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
        include fastcgi_params;  
        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
        # With php-cgi (or other tcp sockets):
        #fastcgi_pass 127.0.0.1:9000;
        #fastcgi_param HTTP_HOST $host;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }

}

其中主目录root对应的是flarum下的public目录。在浏览器输入论坛名称,数据库信息进行配置即可。

参考:

  1. Download Composer-Command-line installation
  2. 在Debian上搭建Flarum论坛
  3. Flarum 简体中文语言包 2021
  4. 关于Flarum CV的插件详细介绍
赞(1)
未经允许禁止转载:优米格 » 安装composer及用composer安装flarum、插件的过程

评论 1

合作&反馈&投稿

商务合作、问题反馈、投稿,欢迎联系

广告合作侵权联系