如何使用Apache安装ElkArte论坛并在Debian 10上进行加密

如何使用Apache安装ElkArte论坛并在Debian 10上进行加密

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

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

要求条件

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

入门指南

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

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

添加以下行:


     ServerAdmin [email protected]
     DocumentRoot /var/www/html/elkarte
     ServerName example.com

     
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     

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

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

a2ensite elkarte.conf a2enmod rewrite

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

systemctl restart apache2

访问ElkArte Web界面

ElkArte现在已安装和配置。该访问ElkArte Web界面了。

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

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

数据库设置

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

论坛设置

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

填充数据库

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

创建一个管理员帐户

提供所需的管理员名称,密码,电子邮件,数据库密码,然后单击 继续 安装完成后,您将看到以下页面:

完成安装

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

ElkArte论坛

让我们加密来保护ElkArte

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

默认情况下,Debian 10默认存储库中不提供最新版本的Certbot存储库。因此,您需要在服务器上添加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): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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

接下来,选择选项 两个 为您的域下载并安装免费的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

Source

Sidebar