完美的服务器 - Debian 8.4 Jessie(Apache2、BIND、Dovecot、ISPConfig 3.1)完美的服务器 - Debian 8.4 Jessie(Apache2、BIND、Dovecot、ISPConfig 3.1)完美的服务器 - Debian 8.4 Jessie(Apache2、BIND、Dovecot、ISPConfig 3.1)完美的服务器 - Debian 8.4 Jessie(Apache2、BIND、Dovecot、ISPConfig 3.1)
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

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

完美的服务器 - Debian 8.4 Jessie(Apache2、BIND、Dovecot、ISPConfig 3.1)

本教程介绍如何为安装 ISPConfig 3.1 准备 Debian Jessie 服务器(带有 Apache2、BIND、Dovecot),以及如何安装 ISPConfig。虚拟主机控制面板 ISPConfig 3 允许您通过网络浏览器配置以下服务:Apache 或 nginx 网络服务器、Postfix 邮件服务器、Courier 或 Dovecot IMAP/POP3 服务器、MySQL、BIND 或 MyDNS 名称服务器、PureFTPd、SpamAssassin、ClamAV、还有很多。此设置涵盖 Apache(而不是 nginx)、BIND 和 Dovecot(而不是 Courier)。

1 初步说明

在本教程中,我将使用主机名 server1.example.com,IP 地址为 192.168.1.100,网关为 192.168.1.1。这些设置可能因您而异,因此您必须在适当的地方替换它们。在继续之前,您需要安装 Debian 8 的最小化版本。这可能是您的托管服务提供商提供的 Debian 最小化镜像,或者您可以使用 Minimal Debian Server 教程来设置基本系统。

这个版本的教程有什么新内容?

  • 支持新的 ISPConfig 3.1 功能。
  • 支持 Lets Encrypt SSL 证书。
  • 支持 HHVM(HipHop 虚拟机)运行 PHP 脚本。
  • 支持 XMPP(节拍器)。
  • 支持使用 Postgrey 将电子邮件列入灰名单。
  • UFW 作为防火墙来取代 Bastille。
  • RoundCube Webmail 而不是 Squirrelmail。

2 安装 SSH 服务器(可选)

如果您在系统安装时没有安装OpenSSH服务器,您现在可以安装:

apt-get install ssh openssh-server

从现在开始,您可以使用 PuTTY 等 SSH 客户端从您的工作站连接到您的 Debian Jessie 服务器,然后按照本教程中的其余步骤进行操作。

3 安装 shell 文本编辑器(可选)

我们将在本教程中使用 nano 文本编辑器。有些用户更喜欢经典的 vi 编辑器,因此我们将在此处安装这两个编辑器。默认的 vi 程序在 Debian 和 Ubuntu 上有一些奇怪的行为;为了解决这个问题,我们安装 vim-nox:

apt-get install nano vim-nox

如果 vi 是你最喜欢的编辑器,那么在以下命令中将 nano 替换为 vi 来编辑文件。

4 配置主机名

服务器的主机名应该是一个子域,如 \server1.example.com\。不要使用没有子域部分的域名作为主机名,如 \example.com\,因为这会导致以后的邮件设置出现问题。首先,您应该检查 /etc/hosts 中的主机名,并在必要时进行更改。该行应为:\IP 地址 - 空格 - 完整主机名,包括域 - 空格 - 子域部分\。对于我们的主机名 server1.example.com,该文件应如下所示:

nano /etc/hosts
127.0.0.1       localhost.localdomain   localhost
192.168.1.100   server1.example.com     server1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

然后编辑 /etc/hostname 文件:

nano /etc/hostname

它应该只包含子域部分,在我们的例子中:

server1

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

reboot

再次登录并使用以下命令检查主机名是否正确:

hostname
hostname -f

输出应如下所示:

:/tmp# hostname -f
server1.example.com

5 更新您的 Debian 安装

首先确保您的 /etc/apt/sources.list 包含 jessie/updates 存储库(这确保您始终获得最新的安全更新),并且启用了 contrib 和 non-free 存储库(一些软件包,例如 libapache2- mod-fastcgi 不在主存储库中)。

nano /etc/apt/sources.list
#deb cdrom:[Debian GNU/Linux 8.0.0 _Jessie_ - Official amd64 NETINST Binary-1 20150425-12:50]/ jessie main

deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

跑步:

apt-get update

更新 apt 包数据库

apt-get upgrade

并安装最新的更新(如果有的话)。

6 更改默认Shell

/bin/sh 是 /bin/dash 的符号链接,但是我们需要 /bin/bash,而不是 /bin/dash。因此我们这样做:

dpkg-reconfigure dash

使用 dash 作为默认系统 shell (/bin/sh)? <- 没有

如果您不这样做,ISPConfig 安装将失败。

7 同步系统时钟

将系统时钟与 Internet 上的 NTP (network ttime protocol) 服务器同步是个好主意。只需运行

apt-get install ntp

并且您的系统时间将始终保持同步。

8 安装 Postfix、Dovecot、MySQL、rkhunter 和 Binutils

我们可以使用一个命令安装 Postfix、Dovecot、MySQL、rkhunter 和 binutils:

apt-get install postfix postfix-mysql postfix-doc mariadb-client mariadb-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve dovecot-lmtpd sudo

如果您更喜欢 MySQL 而不是 MariaDB,请将上述命令中的包 \mariadb-client mariadb-server\ 替换为 \mysql-client mysql-server\。

您将被问及以下问题:

一般邮件配置类型:<-- Internet Site
系统邮件名称:<-- server1.example.com
MariaDB \root\ 用户的新密码:<-- yourrootsqlpassword
重复密码对于 MariaDB \root\ 用户:<-- yourrootsqlpassword

要保护 MariaDB/MySQL 安装并禁用测试数据库,请运行以下命令:

mysql_secure_installation

我们不必更改 MySQL root 密码,因为我们只是在安装过程中设置了一个新密码。回答以下问题:

Change the root password? [Y/n] <-- n
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Remove test database and access to it? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

接下来,在 Postfix 中打开 TLS/SSL 和提交端口:

nano /etc/postfix/master.cf

如下取消提交和 smtps 部分的注释,并在必要的地方添加行,以便 master.cf 文件的这一部分看起来与下面的完全一样。

[...]
submission inet n - - - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
smtps inet n - - - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING [...]

之后重启 Postfix:

service postfix restart

我们希望 MariaDB 监听所有接口,而不仅仅是本地主机,因此,我们编辑 /etc/mysql/my.cnf 并注释掉 bind-address=127.0.0.1 行:

nano /etc/mysql/my.cnf
[...]
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
[...]

然后我们重启MySQL:

service mysql restart

现在检查网络是否已启用。跑步

netstat -tap | grep mysql

输出应如下所示:

:/# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 16806/mysqld

9 安装 Amavisd-new、SpamAssassin 和 ClamAV

要安装 amavisd-new、SpamAssassin 和 ClamAV,我们运行

apt-get install amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl postgrey

ISPConfig 3 安装程序使用在内部加载 SpamAssassin 过滤器库的 amavisd,因此我们可以停止 SpamAssassin 以释放一些 RAM:

service spamassassin stop
systemctl disable spamassassin

9.1 安装 Metronome XMPP 服务器(可选)

此步骤安装 Metronome XMPP 服务器,它提供与 XMPP 协议兼容的聊天服务器。这一步是可选的,如果你不需要聊天服务器,那么你可以跳过这一步。没有其他 ISPConfig 功能依赖于此软件。

在 Debian 中添加 Prosody 软件包存储库。

echo "deb http://packages.prosody.im/debian jessie main" > /etc/apt/sources.list.d/metronome.list
wget http://prosody.im/files/prosody-debian-packages.key -O - | sudo apt-key add -

更新包列表:

apt-get update

并使用 apt 安装软件包。

apt-get install git lua5.1 liblua5.1-0-dev lua-filesystem libidn11-dev libssl-dev lua-zlib lua-expat lua-event lua-bitop lua-socket lua-sec luarocks luarocks
luarocks install lpc

为节拍器添加一个 shell 用户。

adduser --no-create-home --disabled-login --gecos 'Metronome' metronome

下载节拍器到/opt 目录并编译它。

cd /opt; git clone https://github.com/maranda/metronome.git metronome
cd ./metronome; ./configure --ostype=debian --prefix=/usr
make
make install

节拍器现已安装到 /opt/metronome。

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