Flarum-beta 11 Install

2020-03-26   329 次阅读


Composer安装

安装前请务必确保已经正确安装了 PHP。打开命令行窗口并执行 php -v 查看是否正确输出版本号。

# php版本查看
[root@CentOS7 ~]# php -v

PHP 7.3.5 (cli) (built: May  6 2019 11:38:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies

从国外下载,速度很感人,我们可以通过国内的镜像来下载安装,比如阿里的镜像,安装方法如下:

# 下载
[root@CentOS7 ~]# curl -O https://mirrors.aliyun.com/composer/composer.phar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1891k  100 1891k    0     0  7476k      0 --:--:-- --:--:-- --:--:-- 7475k
[root@CentOS7 ~]# ls
composer.phar

# 进行chmod +x给权限
chmod +x composer.phar 

全局安装

全局安装是将 Composer 安装到系统环境变量 PATH 所包含的路径下面,然后就能够在命令行窗口中直接执行 composer 命令了。

打开命令行窗口并执行如下命令将前面下载的 composer.phar 文件移动到 /usr/local/bin/ 目录下面:

mv composer.phar /usr/local/bin/composer

切换到国内源(阿里源)

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

注意:在执行composer命令时你可能会遇到诸如以下的情况:

PHP Warning:  putenv() has been disabled for security reasons in phar:///www/server/php/73/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 149

Warning: putenv() has been disabled for security reasons in phar:///www/server/php/73/bin/composer/vendor/composer/xdebug-handler/src/Process.php on line 149
PHP Warning:  putenv() has been disabled for security reasons in phar:///www/server/php/73/bin/composer/bin/composer on line 57

Warning: putenv() has been disabled for security reasons in phar:///www/server/php/73/bin/composer/bin/composer on line 57
Composer version 1.8.5 2019-04-09 17:46:47

根据警示说的,应该是宝塔的php默认禁用了相关函数,总结了一下,要删除的有以下函数,因此在 PHP管理-禁用函数 里删除这三个即可。

# 删除这三个函数
putenv
pcntl_signal
proc_open

上述命令不会有任何的回显,但是会在当前用户的主目录下生成3个目录文件:“.cache”、“.config”和“.local”,进入“.config”就能看到composer目录。

[root@CentOS7 ~]# cd .config
[root@CentOS7 .config]# ls
composer

在composer目录下的文件config.json里能看到我们修改以后的阿里源记录。

[root@CentOS7 .config]# cd composer
[root@CentOS7 composer]# ls
auth.json  config.json
[root@CentOS7 composer]# cat config.json 
{
    "config": {},
    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        }
    }
}
[root@CentOS7 composer]#

最后

提示:不要忘了经常执行composer selfupdate以保持 Composer 一直是最新版本哦!

# 更新composer
[root@CentOS7 ~]# composer selfupdate
# composer版本查看 
[root@CentOS7 ~]# composer --version
Composer version 1.9.3 2020-02-04 12:58:49

Flarum官方文档似乎没有说明一个很重要的扩展,就是fileinfo,这个是flarum必须要装的扩展,宝塔面板 PHP管理-安装扩展 可以直接安装。

Flarum安装

添加站点

在宝塔面板 添加站点,数据库编码建议选择utf8mb4,当然utf8也行。

首先cd到网站根目录下,rm -rf *删除掉所有文件。

[root@CentOS7 bbs]# rm -rf *
[root@CentOS7 bbs]# ls -all
total 16
drwxr-xr-x 2 www  www  4096 Feb 21 12:30 .
drwxrwxrwx 3 root root 4096 Feb 21 12:23 ..
-rwxr-xr-x 1 www  www     1 Feb 21 12:23 .htaccess
-rw-r--r-- 1 root root   39 Feb 21 12:23 .user.ini
[root@CentOS7 bbs]# 

rm -rf * 删不干净,在宝塔面板的文件管理删除,.htaccess.user.ini都要删除,保证该目录下无文件。

使用Composer安装

[root@CentOS7 bbs]# composer create-project flarum/flarum . --stability=beta

注意

  • 如果出现Content-Length mismatch错误。若无,忽视之。
  [Composer\Downloader\TransportException]                                   
  Content-Length mismatch, received 310900 bytes out of the expected 431682
# 查看 cache-files-maxsize 大小,默认为300MiB
[root@CentOS7 ~]# composer config -gl
# 更改为1024MiB
composer config --global cache-files-maxsize 1024MiB
  • 安装过程可能会出现如下情况,无视之。
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-stratigility is abandoned, you should avoid using it. Use laminas/laminas-stratigility instead.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package zendframework/zend-httphandlerrunner is abandoned, you should avoid using it. Use laminas/laminas-httphandlerrunner instead.
Package oyejorge/less.php is abandoned, you should avoid using it. No replacement was suggested.

安装一个简体中文的插件

composer require csineneo/lang-simplified-chinese
  • 同样可能会出现以下情况,无视之。
Package oyejorge/less.php is abandoned, you should avoid using it. No replacement was suggested.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-httphandlerrunner is abandoned, you should avoid using it. Use laminas/laminas-httphandlerrunner instead.
Package zendframework/zend-stratigility is abandoned, you should avoid using it. Use laminas/laminas-stratigility instead.

对于以上的情况官方的说法是这样的。

Hi! This is just a notice which can be safely ignored. The underlying ‘issue’ is due to the project having been rebranded from Zend. has resolves this in Beta 12.

然后把网站目录下所有目录文件权限改为755,并将网站运行目录指向/public

权限755

网站运行目录指向/public

语言简体中文

http://bbs.notys.xyz

Q.E.D.

知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

隻言片語・於此匯聚!