CentOS 7 安装宝塔 Linux 面板(bt.cn)、Flarum


安装宝塔 Linux 面板(bt.cn)

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

添加站点,用于安装 Flarum

安装 Composer

wget https://getcomposer.org/composer.phar -O /usr/local/bin/composer
chmod a+x /usr/local/bin/composer

# 添加 composer bin 到 PATH
export PATH=$PATH:/root/.config/composer/vendor/bin
source /etc/profile

# composer http 改成 https,连接速度会更佳
composer config -g repo.packagist composer https://packagist.phpcomposer.com

安装 Flarum

# 安装 flarum
mkdir /tmp/flarum && cd /tmp/flarum && composer create-project flarum/flarum . --stability=beta

# 解决因PHP版本过高,安装依赖报错的问题
composer install --ignore-platform-reqs

# 拷贝 flarum 文件到 testweb 文件夹

rm -rf /www/wwwroot/testweb/* && cp -R /tmp/flarum/* /www/wwwroot/testweb

然后访问刚新建的站点,发现已经能访问 Flarum 了,只不过有几个问题:

问题1:The PHP extension 'fileinfo' is required.

解决方法:访问宝塔 Linux 面板,在 PHP 设置中安装 fileinfo 扩展,结果如下图:

问题2:The /www/wwwroot/testweb/assets directory is not writable.

Please chmod this directory and its contents to 0775.

解决方法:

chmod -R 0777 /www/wwwroot/testweb/assets

问题3:The /www/wwwroot/testweb/storage directory is not writable.

Please chmod this directory and its contents to 0775.

解决方法:

chmod -R 0777 /www/wwwroot/testweb/storage

解决问题后,访问到正常安装页面,填写数据库等相关信息即可安装。

 

提示:根据官方文档想要访问正常,必需 URL Rewriting。

URL Rewriting

Apache

Flarum includes a .htaccess file – make sure it’s been uploaded correctly. If you’re using shared hosting, confirm with your hosting provider that mod_rewrite is enabled. You may need to add the following to your Apache configuration:

<Directory "/path/to/your/forum">
    AllowOverride All
</Directory>

Nginx

Add the following lines to your server’s configuration block:

location / { try_files uriuri/ /index.php?query_string; }
location /api { try_filesuri uri/ /api.php?query_string; }
location /admin { try_files uriuri/ /admin.php?query_string; }

location ~* ^/(composer\.(json|lock)|config\.php|flarum|storage|vendor) {
    deny all;
    return 404;
}

location ~* \.php {
    fastcgi_split_path_info ^(.+.php)(/.+);
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAMEdocument_rootfastcgi_script_name;
    fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability
    fastcgi_index index.php;
}
    
location ~* \.html {
    expires -1;
}

location ~* \.(css|js|gif|jpe?g|png)$ {
    expires 1M;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types application/atom+xml
           application/javascript
           application/json
           application/vnd.ms-fontobject
           application/x-font-ttf
           application/x-web-app-manifest+json
           application/xhtml+xml
           application/xml
           font/opentype
           image/svg+xml
           image/x-icon
           text/css
           #text/html -- text/html is gzipped by default by nginx
           text/plain
           text/xml;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

Lighttpd

Add the following lines to your server’s configuration block:

url.rewrite-if-not-file = (
    "/admin.*" => "/admin.php",
    "/api.*"   => "/api.php",
    "/.*"      => "/index.php"
)

参考文档

https://www.bt.cn/bbs/thread-1186-1-1.html

https://flarum.org/docs/installation/


《“CentOS 7 安装宝塔 Linux 面板(bt.cn)、Flarum”》 有 2 条评论

  1. 你好我又几个问题可以问吗?可以微信联系我:barmah

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注