完美的服务器 - 与Apache,BIND,Dovecot,PureFTPD和ISPConfig 3.1的Debian 9(Stretch)

本教程将介绍如何准备安装ISPConfig 3.1的Debian 9服务器(具有Apache2,BIND,Dovecot)以及如何安装ISPConfig。 网络托管控制面板ISPConfig 3允许您通过Web浏览器配置以下服务:Apache或nginx Web服务器,Postfix邮件服务器,Courier或Dovecot IMAP / POP3服务器,MySQL,BIND或MyDNSNameservers,PureFTPd,SpamAssassin,ClamAV,还有很多。 此设置涵盖Apache(而不是nginx),BIND和Dovecot。

1初步说明

在本教程中,我将使用IP地址为192.168.1.100的主机名server1.example.com和网关192.168.1.1 。 这些设置可能会有所不同,因此您必须在适当的情况下更换它们。 在继续进行之前,您需要安装最少的Debian 9.这可能是主机提供商的Debian最小图像,或者您使用最小Debian Server教程设置基本系统。

2安装SSH服务器(可选)

如果在系统安装期间未安装OpenSSH服务器,则可以立即执行:

apt-get install ssh openssh-server

从现在开始,您可以使用SSH客户端(如PuTTY),并从工作站连接到Debian 9服务器,并按照本教程中的其余步骤操作。

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

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

apt-get install nano vim-nox

如果vi是您最喜爱的编辑器,那么在以下命令中用vi替换nano以编辑文件。

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

输出应为:

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

5更新您的Debian安装

首先,确保您的/etc/apt/sources.list包含stretch / updates存储库(这将确保您始终获得最新的安全更新),并且contribnon-free存储库已启用,因为某些必需软件包不是在主仓库。

nano /etc/apt/sources.list
deb http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch main contrib non-free

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

跑:

apt-get update

更新apt包数据库

apt-get upgrade

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

6更改默认的Shell

/ bin / sh/ bin / dash的符号链接,但是我们需要/ bin / bash ,not / bin / dash 。 所以我们这样做:

dpkg-reconfigure dash

使用破折号作为默认系统shell(/ bin / sh)? < - 不

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

7同步系统时钟

通过互联网将系统时钟与NTP( n工作协议)服务器同步是一个好主意。 只需运行

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

您将被问到以下问题:

General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com

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

mysql_secure_installation

回答以下问题:

Change the root password? [Y/n] <-- y
New password: <-- Enter a new MySQL root password
Re-enter new password: <-- Repeat the MySQL root password
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

我们希望MySQL在所有接口上监听,而不仅仅是本地主机。 因此,我们编辑   /etc/mysql/mariadb.conf.d/50-server.cnf   并注释掉该行   bind-address = 127.0.0.1并添加行sql-mode =“NO_ENGINE_SUBSTITUTION”

nano /etc/mysql/mariadb.conf.d/50-server.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

sql-mode="NO_ENGINE_SUBSTITUTION"

[...]

将MariaDB中的密码验证方法设置为native,以便稍后使用PHPMyAdmin以root用户身份进行连接:

echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root

编辑文件/etc/mysql/debian.cnf并在密码开头的行中设置MYSQL / MariaDB root密码两次。

nano /etc/mysql/debian.cnf

需要添加的MySQL根密码以读取方式显示,在此示例中,密码为“youcl”。

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = root
password = youcl
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password = youcl
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

然后我们重新启动MariaDB:

service mysql restart

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

netstat -tap | grep mysql

输出应该如下所示:

root@server1:/home/administrator# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 17776/mysqld
root@server1:/home/administrator#

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设置使用amavisd在内部加载SpamAssassin过滤器库,所以我们可以停止SpamAssassin释放一些RAM:

service spamassassin stop
systemctl disable spamassassin

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

此步骤安装Metronome XMPP服务器,该服务器提供与XMPP协议兼容的聊天服务器。 此步骤是可选的,如果您不需要聊天服务器,则可以跳过此步骤。 没有其他ISPConfig功能取决于此软件。

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

echo "deb http://packages.prosody.im/debian stretch 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

为Metronome添加一个shell用户。

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

将Metronome下载到/ opt目录并进行编译。

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

Metronome现已安装到/ opt / metronome。

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏