Flarum 是一个免费、开源的下一代论坛应用程序,可帮助您构建自己的讨论论坛。它是用 PHP 编写的,简单、快速且易于部署。
至于用宝塔或者docker安装往往需要更大的运行内存,今天我就来在1C2G的机器上纯手工搭建,没有任何多余文件,纯净到极致!最后内存只占用300M左右。
准备如下材料:
1.vps
2.域名已经指向vps的ip
3.获得sudo 权限
安装步骤:
1.更新系统
apt-get update -y
2.安装LAMP
apt-get install apache2 mariadb-server php7.4 libapache2-mod-php7.4 php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-mysql php7.4-gd php7.4-xml php7.4-curl php7.4-cli php7.4-zip php7.4-tokenizer wget unzip curl git -y
3.编辑php配置文件:
nano /etc/php/7.4/apache2/php.ini
需要修改的部分:
file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_file_size = 150M
max_execution_time = 450
date.timezone = Asia/Kolkata
4.建立数据库
mysql
MariaDB [(none)]> CREATE DATABASE flarum;
MariaDB [(none)]> CREATE USER 'flarum'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON flarum.* TO 'flarum'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
在上面的步骤中,数据库名称、用户名和密码需要自己改一下;
5.安装Composer
curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer -V
Composer有版本输入即为安装正确;
6.安装Flarum
mkdir /var/www/html/flarum
cd /var/www/html/flarum
composer create-project flarum/flarum . --stability=beta
composer install
chown -R www-data:www-data /var/www/html/flarum/
chmod -R 755 /var/www/html/flarum/
7.配置 Apache
nano /etc/apache2/sites-available/flarum.conf
在文件中添加下面的行,注意,域名和邮箱改成你的:
<VirtualHost *:80>
ServerAdmin admin@800815.xyz
DocumentRoot /var/www/html/flarum/public
ServerName flarum.800815.xyz
DirectoryIndex index.php
<Directory /var/www/html/flarum/public/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/flarum-error_log
CustomLog /var/log/apache2/flarum-access_log common
</VirtualHost>
8.重启Apache
a2ensite flarum
a2enmod rewrite
systemctl restart apache2
systemctl status apache2
查看输出是否正确。
9.申请Let’s Encrypt 证书
apt-get install python3-certbot-apache -y
certbot --apache -d flarum.800815.xyz
这个过程中,需要1输入邮箱;2同意条款;3同意邮件;4获取证书;5是否启用证书;
10.此时,Flarum已经搭建完成,可以输入域名Flarum.800815.xyz访问并安装了。
怎么样?是不是挺简单的,整个安装过程只要是细心阅读,小心操作,小白也能无脑安装。
视频教程:
bilibili:https://www.bilibili.com/video/BV1iF411L7Cm/
Youtube:https://www.youtube.com/watch?v=8WjJBX3EeMc
评论区