手動(dòng)用Ubuntu20.04搭建Flarum論壇

Flarum 是一個(gè)免費(fèi)、開源的下一代論壇應(yīng)用程序,可幫助您構(gòu)建自己的討論論壇。它是用 PHP 編寫的,簡(jiǎn)單、快速且易于部署。
至于用寶塔或者docker安裝往往需要更大的運(yùn)行內(nèi)存,今天我就來在1C2G的機(jī)器上純手工搭建,沒有任何多余文件,純凈到極致!最后內(nèi)存只占用300M左右。
準(zhǔn)備如下材料:
1.vps
2.域名已經(jīng)指向vps的ip
3.獲得sudo 權(quán)限
安裝步驟:
1.更新系統(tǒng)
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.建立數(shù)據(jù)庫(kù)
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;
在上面的步驟中,數(shù)據(jù)庫(kù)名稱、用戶名和密碼需要自己改一下;
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.申請(qǐng)Let’s Encrypt 證書
apt-get install python3-certbot-apache -y
certbot --apache -d flarum.800815.xyz
這個(gè)過程中,需要1輸入郵箱;2同意條款;3同意郵件;4獲取證書;5是否啟用證書;
10.此時(shí),F(xiàn)larum已經(jīng)搭建完成,可以輸入域名Flarum.800815.xyz訪問并安裝了。

怎么樣?是不是挺簡(jiǎn)單的,整個(gè)安裝過程只要是細(xì)心閱讀,小心操作,小白也能無腦安裝。主機(jī)推薦:BV1bR4y137Fj?