如何在 Debian 10 上使用 Apache 和 Lets Encrypt 安装 ElkArte 论坛如何在 Debian 10 上使用 Apache 和 Lets Encrypt 安装 ElkArte 论坛如何在 Debian 10 上使用 Apache 和 Lets Encrypt 安装 ElkArte 论坛如何在 Debian 10 上使用 Apache 和 Lets Encrypt 安装 ElkArte 论坛
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Debian 10 上使用 Apache 和 Lets Encrypt 安装 ElkArte 论坛

在此页

  1. 要求
  2. 开始
  3. 安装 Apache、MariaDB 和 PHP
  4. 为 ElkArte 配置数据库
  5. 下载 ElkArte
  6. 为 ElkArte 创建虚拟主机
  7. 访问 ElkArte 网络界面
  8. 使用 Lets Encrypt 保护 ElkArte

ElkArte 是一款免费、开源且功能强大的论坛软件,可让您创建自己的在线论坛社区。它是基于 PHP 的简单、轻量级的现代论坛平台,使用 MySQL/MariaDB 来存储其数据。 ElkArte 具有丰富的功能,包括通知、帖子点赞、草稿、自动保存、拖放文件附件、youtube 集成视频嵌入、通过电子邮件发布、改进的反垃圾邮件措施等等。

在本教程中,我们将解释如何在 Debian 10 服务器上安装 ElkArte。

要求

  • 运行 Debian 10 的服务器。
  • 已为您的服务器设置根密码。

入门

在开始之前,您需要使用最新版本更新您的系统。您可以通过运行以下命令来执行此操作:

apt-get update -y
apt-get upgrade -y

服务器更新后,重新启动服务器以应用更改。

安装 Apache、MariaDB 和 PHP

首先,您需要在服务器上安装 Apache Web 服务器、MariaDB 数据库服务器、PHP 和其他所需的库。您可以通过运行以下命令来安装所有这些:

apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-curl php-intl php-mbstring php-xmlrpc php-mysql php-gd php-pgsql php-xml php-cli php-imagick php-bcmath php-gmp php-zip unzip -y

安装所有软件包后,打开 php.ini 文件并调整一些设置:

nano /etc/php/7.3/apache2/php.ini

更改以下行:

memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

完成后保存并关闭文件。然后,使用以下命令重新启动 Apache Web 服务器:

systemctl restart apache2

为 ElkArte 配置数据库

接下来,您需要为 ElkArte 创建数据库和用户。为此,请使用以下命令登录到 MariaDB shell:

mysql -u root -p

在出现提示时提供您的 root 密码,然后使用以下命令创建数据库和用户:

MariaDB [(none)]> CREATE DATABASE elkartedb;
MariaDB [(none)]> CREATE USER 'elkarte'@'localhost' IDENTIFIED BY 'password';

接下来,使用以下命令将所有权限授予 ElkArte:

MariaDB [(none)]> GRANT ALL ON elkartedb.* TO 'elkarte'@'localhost' WITH GRANT OPTION;

接下来,使用以下命令刷新权限并退出 MariaDB shell:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

完成后,您可以继续下一步。

下载 ElkArte

首先,您需要从 Git 存储库下载最新版本的 ElkArte。要下载它,请运行以下命令:

wget https://github.com/elkarte/Elkarte/archive/master.zip

下载完成后,使用以下命令解压缩下载的文件:

unzip master.zip

接下来,将提取的目录移动到 Apache web 根目录:

mv Elkarte-master /var/www/html/elkarte

接下来,更改 elkarte 目录的所有权并使用以下命令提供必要的权限:

chown -R www-data:www-data /var/www/html/elkarte
chmod -R 755 /var/www/html/elkarte

完成后,您可以继续下一步。

为 ElkArte 创建虚拟主机

接下来,您需要创建一个 Apache 虚拟主机配置文件来为 ElkArte 提供服务。您可以使用以下命令创建它:

nano /etc/apache2/sites-available/elkarte.conf

添加以下行:

<VirtualHost *:80>
     ServerAdmin 
     DocumentRoot /var/www/html/elkarte
     ServerName example.com

     <Directory /var/www/html/elkarte/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
    
</VirtualHost>

完成后保存并关闭文件。然后,使用以下命令启用虚拟主机文件和 Apache 重写模块:

a2ensite elkarte.conf
a2enmod rewrite

最后,重新启动 Apache 网络服务器以应用更改:

systemctl restart apache2

访问 ElkArte Web 界面

ElkArte 现已安装和配置。是时候访问 ElkArte Web 界面了。

打开 Web 浏览器并输入 URL http://example.com。您将被重定向到 ElkArte 欢迎页面:

单击继续按钮。您应该会看到以下页面:

提供您的数据库名称、数据库用户名、密码,然后单击“继续”按钮。您应该会看到以下页面:

提供您的论坛名称、论坛 URL,然后单击继续按钮。您应该会看到以下页面:

现在,单击“继续”按钮。您应该看到管理员创建页面:

提供所需的管理员名称、密码、电子邮件、数据库密码,然后单击“继续”按钮。安装完成后,您应该会看到以下页面:

现在,单击“您新安装的论坛”。您应该在以下页面中看到 ElkArte 仪表板:

使用 Lets Encrypt 保护 ElkArte

首先,您需要在服务器上安装 Certbot。 Certbot 用于从 Let's Encrypt 获取 SSL 证书并配置 Apache 以使用此证书。

默认情况下,最新版本的 Certbot 在 Debian 10 默认存储库中不可用。因此,您需要在服务器上添加 Certbot 存储库。

首先,使用以下命令添加 Certbot 存储库:

add-apt-repository ppa:certbot/certbot

添加存储库后,更新存储库并使用以下命令安装 Certbot:

apt-get update -y
apt-get install certbot python-certbot-apache -y

Certbot 现已安装并可以使用。

运行以下命令为您的域获取 SSL 证书:

certbot --apache -d example.com

首先,您需要提供一个有效的电子邮件地址并同意如下所示的服务条款:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/example.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/example.com-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/example.com-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

接下来,选择选项 2 为您的域下载并安装免费的 SSL 证书。一旦安装成功完成。您应该得到以下输出:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/example.com.conf to ssl vhost in /etc/apache2/sites-available/
example.com-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2019-10-22. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

恭喜!您的 ElkArte 现在已使用 SSL 证书进行保护。您现在可以通过访问 URL https://example.com 安全地访问它。

©2015-2025 艾丽卡 support@alaica.com