flarum轻社区安装文档

作者:泥泥
发布于:2020年2月18日 08:37
更新于:2020年3月6日 10:26

为方便学员和网友提问,回答.这几天在尝试着搭建些轻爽界面的轻社区系统.flarum就是其中之一

服务器系统准备,centos7.5.64位系统.

一.安装Nginx最新稳定版本

1.编译代码

yum install -y pcre pcre-devel openssl openssl-devel 

yum install gcc-c++ -y

yum install gcc -y

mkdir /server/tools/ -p
cd /server/tools/
yum install -y pcre pcre-devel openssl openssl-devel
useradd nginx -s /sbin/nologin -M
wget http://nginx.org/download/nginx-1.17.8.tar.gz
tar xzf nginx-1.17.8.tar.gz
cd nginx-1.17.8
./configure --prefix=/application/nginx-1.17.8 --user=nginx --group=nginx --with-http_sub_module --with-http_ssl_module
make
make install
/application/nginx-1.17.8/sbin/nginx -t
/application/nginx-1.17.8/sbin/nginx
netstat -lntup|egrep "nginx"

 

二.安装mysql

2.1.官方文档要求如下

  • Apache (with mod_rewrite enabled) or Nginx
  • PHP 7.1+ with the following extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
  • MySQL 5.6+ or MariaDB 10.0.5+
  • SSH (command-line) access to run Composer

所以选择mysql5.7,Cmake安装

cd /server/tools/

tar zxf cmake-3.16.4.tar.gz

./configure

gmake

gmake install

cd ..

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29.tar.gz
tar xf mysql-5.7.29.tar.gz 
cd mysql-5.7.29
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.29 -DMYSQL_DATADIR=/application/mysql-5.7.29/data -DMYSQL_UNIX_ADDR=/application/mysql-5.7.29/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0 -DWITH_BOOST=/usr/local/boost/boost_1_59_0  

报错:

This CMake script will look for boost in <directory>.  If it is not there it will download and unpack it (in that directory) for you.

解决方法参考:https://blog.csdn.net/u012767761/article/details/78185768/

 

mkdir -p /usr/local/boost
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
tar -xvzf boost_1_59_0.tar.gz

编译参数添加

-DWITH_BOOST=/usr/local/boost 

继续安装

gmake
gmake install
/application/mysql-5.7.29/bin/mysqld --initialize --user=mysql --basedir=/application/mysql-5.7.29/ --datadir=/application/mysql-5.7.29/data/
ln -s /application/mysql-5.7.29/ /application/mysql
chown mysql.mysql /application/mysql-5.7.29/data 
ls -l /application/mysql-5.7.29/data/ -d
source /etc/profile
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

修改配置文件,vim /etc/my.cnf

 

[mysqld]
basedir=/application/mysql-5.7.29/
datadir=/application/mysql-5.7.29/data/

socket = /application/mysql-5.7.29/tmp/mysql.sock
user = mysql
tmpdir = /application/mysql-5.7.29/tmp
symbolic-links=0

[mysqld_safe]

log-error = /application/mysql-5.7.29/tmp/error.log
pid-file = /application/mysql-5.7.29/tmp/mysql.pid

启动服务

touch /application/mysql-5.7.29/tmp/error.log
chown mysql.mysql /application/mysql-5.7.29/tmp/error.log
/etc/init.d/mysqld start

通过临时密码,进入客户端.改root密码

set password for 'root'@localhost = PASSWORD("123456");
flush privileges;
chkconfig mysqld on

 

三.安装php7.1

3.1.下载源码

https://www.php.net/downloads.php

3.2.安装依赖库

yum -y install wget pcre pcre-devel openssl openssl-devel libicu-devel autoconf libjpeg libjpeg-devel \

libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel \

glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap \

openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel \

gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline \

readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel gdbm-devel

 

3.3.增加运行的用户组

groupadd www

useradd -g www www

 

3.4.解压编译安装

cd /server/tools/
wget https://www.php.net/distributions/php-7.3.14.tar.gz
tar zxf php-7.3.14.tar.gz

 

报错,解决办法

1、configure: error: DBA: Could not find necessary header file(s).

安装下 yum install gdbm-devel

2、configure: error: Cannot find ldap libraries in /usr/lib

拷贝下文件 cp -frp /usr/lib64/libldap* /usr/lib/

3.configure: error: Please reinstall the libzip distribution

在 https://libzip.org/download/ 下载源码,进行安装

tar xf libzip-1.5.2.tar.gz

cd libzip-1.5.2

mkdir build && cd build && cmake .. && make && make install

configure: error: off_t undefined; check your library configuration

进行如下操作:

vi /etc/ld.so.conf

# 添加如下几行

/usr/local/lib64

/usr/local/lib

/usr/lib

/usr/lib64

# 保存退出

:wq

# 使之生效

ldconfig -v

解决上述问题.继续编辑

./configure --prefix=/application/php-7.3.14 \
--with-config-file-path=/application/php-7.3.14/etc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--with-ldap=shared \
--with-gdbm \
--with-pear \
--with-gettext \
--with-curl \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-gd \
--enable-fpm \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-xml \
--enable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd-jis-conv \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-fileinfo \
--enable-opcache \
--enable-maintainer-zts \
--enable-exif

安装

make -j 4 && make install

 

3.5.安装后的配置

复制配置文件

cd /server/tools/php-7.3.14
cp php.ini-production /application/php-7.3.14/etc/php.ini
cd /application/php-7.3.14/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf

修改配置文件如下选 项

max_execution_time = 120

max_input_time = 120

memory_limit = 1024M

post_max_size = 128M

date.timezone = PRC

extension_dir = "/application/php-7.3.14/lib/php/extensions/no-debug-zts-20180731"

 

增加服务启动配置文件,启动测试

cd /server/tools/php-7.3.14
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
systemctl enable php-fpm.service
systemctl start php-fpm.service

 

检查效果

[root@qyi-5e4375265328b php-7.3.14]# ss -lnt
State      Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN     0      100                            127.0.0.1:25                                                 *:*                  
LISTEN     0      128                            127.0.0.1:9000                                               *:*                  
LISTEN     0      128                                    *:22                                                 *:*                  
LISTEN     0      100                                  ::1:25                                                :::*                  
LISTEN     0      80                                    :::3306                                              :::*                  
LISTEN     0      128                                   :::22                                                :::*   

 

四.安装程序包

4.1.安装Composer

官方网址https://getcomposer.org/download/,安装前,增加下php环境变量,执行如下命令

增加环境变量:
export PATH=/application/mysql/bin:/application/php-7.3.14/bin:$PATH

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

移动 composer.phar,这样 composer 就可以进行全局调用:

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

切换国内源

composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer selfupdate

 

4.2.安装

创建网站目录,然后在网站目录下面运行

composer create-project flarum/flarum . --stability=beta

安装下中文语言包

composer require csineneo/lang-simplified-chinese

修改网站文件权限和属主

chown www.www ./*
chmod -R 755 ./*

配置Nginx,增加如下配置文件.并把程序包里面的.nginx.conf文件加载

server {
        listen       80;
        server_name  ask.tfst8.com;
        root   /data/www/ask/public;
        #location / {
        #    index  index.php index.html index.htm;
        #}

         location ~ .*\.(php|php5)?$ {      
             fastcgi_pass  127.0.0.1:9000;
             fastcgi_index index.php;
             include fastcgi.conf;
         }

        access_log  logs/access.log  main;      

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        include /application/nginx-1.17.8/conf/conf.d/*.conf;
    }

 

ask.conf

# Pass requests that don't refer directly to files in the filesystem to index.php
location / {
  try_files $uri $uri/ /index.php?$query_string;
  index  index.php index.html index.htm;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

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

 

4.3.创建数据库

建立数据库,运行安装程序.一切顺利

附:插件单点登陆官网
     https://flagrow.io/extensions/maicol07/flarum-ext-sso
    https://github.com/fabwu/flarum-ext-sso
    https://discuss.flarum.org/

上传图片插件安装报错处理:

少了php扩展exif:

cd /server/tools/php-7.3.14/ext/exif/
./configure --with-php-config=/application/php-7.3.14/bin/php-config
make && make install
ls /application/php-7.3.14/lib/php/extensions/no-debug-zts-20180731/
vim /application/php-7.3.14/etc/php.ini  #增加插件配置
extension = "/application/php-7.3.14/lib/php/extensions/no-debug-zts-20180731/exif.so"
重启php-fpm
pkill php-fpm
ps -ef|grep php
/application/php-7.3.14/sbin/php-fpm

在phpinfo中可以看到如下插件
 

EXIF Support enabled
Supported EXIF Version 0220
Supported filetypes JPEG, TIFF
Multibyte decoding support using mbstring enabled
Extended EXIF tag formats Canon, Casio, Fujifilm, Nikon, Olympus, Samsung, Panasonic, DJI, Sony, Pentax, Minolta, Sigma, Foveon, Kyocera, Ricoh, AGFA, Epson

 

成功安装好.flarum编辑器的上传插件

fof-upload                       | 0.8.2
csineneo-lang-simplified-chinese | 1.11.12        |        |
| maicol07-sso                     | 1.4.5    

 

0
0

评论提问

微信好友

用微信扫描二维码,
加我好友。

QQ好友

用QQ扫描二维码,
加我好友。

295638643

用 QQ 扫描二维码,
加入天心数据 QQ 群。