完美的服务器 - Ubuntu 17.04 (Zesty Zapus),带有 Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot 和 ISPConfig 3.1完美的服务器 - Ubuntu 17.04 (Zesty Zapus),带有 Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot 和 ISPConfig 3.1完美的服务器 - Ubuntu 17.04 (Zesty Zapus),带有 Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot 和 ISPConfig 3.1完美的服务器 - Ubuntu 17.04 (Zesty Zapus),带有 Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot 和 ISPConfig 3.1
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

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

完美的服务器 - Ubuntu 17.04 (Zesty Zapus),带有 Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot 和 ISPConfig 3.1

本教程适用于这些操作系统版本

  • Ubuntu 16.04(Xenial Xerus)

在此页

  1. 1。初步说明
  2. 2。编辑 /etc/apt/sources.list 并更新您的 Linux 安装
  3. 3。更改默认外壳
  4. 4。禁用 AppArmor
  5. 5。同步系统时钟
  6. 6。安装 Postfix、Dovecot、MariaDB、rkhunter 和 binutils
  7. 7.安装 Amavisd-new、SpamAssassin 和 Clamav
  8. 7.1 安装 Metronome XMPP 服务器(可选)

本教程展示了使用 Apache2、Postfix、Dovecot、Bind 和 PureFTPD 安装 Ubuntu 17.04 (Zesty Zapus) Web 托管服务器,为安装 ISPConfig 3.1 做准备。生成的系统将提供 Web、邮件、邮件列表、DNS 和 FTP 服务器。

ISPConfig 3 是一个网络托管控制面板,允许您通过网络浏览器配置以下服务:Apache 或 nginx 网络服务器、Postfix 邮件服务器、Courier 或 Dovecot IMAP/POP3 服务器、MySQL、BIND 或 MyDNS 名称服务器、PureFTPd、SpamAssassin、 ClamAV 等等。此设置包括 Apache(而不是 Nginx)、BIND(而不是 MyDNS)和 Dovecot(而不是 Courier)的安装。

本教程是关于 Ubuntu 17.04 的,它是一个非 LTS(长期支持)版本。大多数用户更喜欢 LTS 版本作为服务器,它可以获得更长时间的更新和安全补丁。最新的 LTS 版本是 Ubuntu 16.04,本教程也存在于 Ubuntu 16.04 版本中。仔细考虑您是否需要最新的软件包(并且不介意支持时间短),然后继续本教程。如果您需要长期支持,请改用 Ubuntu 16.04 完美服务器教程。

1. 初步说明

在本教程中,我使用主机名 server1.example.com 以及 IP 地址 192.168.1.100 和网关 192.168.1.1 。这些设置可能因您而异,因此您必须在适当的地方替换它们。在继续之前,您需要按照教程中的说明对 Ubuntu 17.04 进行基本的最小安装。

2. 编辑 /etc/apt/sources.list 并更新你的 Linux 安装

编辑 /etc/apt/sources.list。从文件中注释掉或删除安装 CD,并确保启用了 universe 和 multiverse 存储库。之后应该是这样的:

nano /etc/apt/sources.list
#

# deb cdrom:[Ubuntu-Server 17.04 _Zesty Zapus_ - Release amd64 (20170412)]/ zesty main restricted

#deb cdrom:[Ubuntu-Server 17.04 _Zesty Zapus_ - Release amd64 (20170412)]/ zesty main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu/ zesty main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ zesty-updates main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ zesty universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty universe
deb http://de.archive.ubuntu.com/ubuntu/ zesty-updates universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ zesty multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty multiverse
deb http://de.archive.ubuntu.com/ubuntu/ zesty-updates multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ zesty-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu zesty partner
# deb-src http://archive.canonical.com/ubuntu zesty partner

deb http://security.ubuntu.com/ubuntu zesty-security main restricted
# deb-src http://security.ubuntu.com/ubuntu zesty-security main restricted
deb http://security.ubuntu.com/ubuntu zesty-security universe
# deb-src http://security.ubuntu.com/ubuntu zesty-security universe
deb http://security.ubuntu.com/ubuntu zesty-security multiverse
# deb-src http://security.ubuntu.com/ubuntu zesty-security multiverse

然后运行

apt-get update

更新 apt 包数据库和

apt-get upgrade

安装最新的更新(如果有的话)。如果您看到作为更新的一部分安装了新内核,您应该在之后重新启动系统:

reboot

3.更改默认外壳

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

dpkg-reconfigure dash

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

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

4.禁用AppArmor

AppArmor 是一个安全扩展(类似于 SELinux),应该提供扩展的安全性。在我看来,你不需要它来配置一个安全的系统,而且它通常会导致更多的问题而不是好处(在你完成一周的故障排除后想想它,因为某些服务没有按预期工作,然后你发现一切正常,只有 AppArmor 导致了问题)。因此,我禁用它(如果您想稍后安装 ISPConfig,这是必须的)。

我们可以像这样禁用它:

service apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

5.同步系统时钟

运行物理服务器时,最好通过 Internet 将系统时钟与 NTP(网络时间协议)服务器同步。如果您运行虚拟服务器,则应跳过此步骤。赶紧跑

apt-get -y install ntp

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

6. 安装 Postfix、Dovecot、MariaDB、rkhunter 和 binutils

为了安装 postfix,我们需要确保没有安装和运行 sendmail。要停止和删除 sendmail,请运行以下命令:

service sendmail stop; update-rc.d -f sendmail remove

错误信息:

Failed to stop sendmail.service: Unit sendmail.service not loaded.

没关系,这只是意味着没有安装sendmail,所以没有什么可以删除的。

现在我们可以使用一个命令安装 Postfix、Dovecot、MariaDB(作为 MySQL 的替代品)、rkhunter 和 binutils:

apt-get -y 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

您将被问及以下问题:

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

重要的是,您使用子域作为“系统邮件名称”,例如 server1.example.com 或 server1.yourdomain.com,而不是您以后要用作电子邮件域的域(例如 yourdomain.tld)。

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

nano /etc/postfix/master.cf

取消对提交和 smtps 部分的注释,如下所示 - 添加行 -o smtpd_client_restrictions=permit_sasl_authenticated,reject 到这两个部分,然后留下所有注释:

[...]
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=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=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
[...]

注意:\-o ....\行前面的空格很重要!

之后重新启动 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 中设置一个 root 密码。跑步:

mysql_secure_installation

你会被问到这些问题:

Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

将 MariaDB 中的密码验证方法设置为本机,以便我们稍后可以使用 PHPMyAdmin 以 root 用户身份连接:

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

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

nano /etc/mysql/debian.cnf

需要添加的MySQL root密码显示在read中,本例中密码为\howtoforge\。

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

然后我们重启MariaDB:

service mysql restart

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

netstat -tap | grep mysql

输出应如下所示:

:~#

7. 安装 Amavisd-new、SpamAssassin 和 Clamav

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

apt-get -y 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
update-rc.d -f spamassassin remove

要启动 ClamAV,请使用:

freshclam
service clamav-daemon start

第一次运行freshclam可以忽略下面的错误。

ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).

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

Metronome XMPP 服务器提供了一个 XMPP 聊天服务器。这一步是可选的,如果你不需要聊天服务器,那么你可以跳过这一步。没有其他 ISPConfig 功能依赖于此软件。

使用 apt 安装以下软件包。

apt-get -y 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