本教程显示如何为安装ISPConfig 3.1准备一个Debian 10服务器(带有Nginx,BIND,Dovecot),以及如何安装ISPConfig 3.1。ISPConfig 3是一个网络托管控制面板,可让您通过网络浏览器配置以下服务:Apache或nginx Web服务器,Postfix邮件服务器,Courier或Dovecot IMAP / POP3服务器,MySQL,BIND或MyDNS名称服务器,PureFTPd,SpamAssassin, ClamAV等。此设置涵盖Nginx Web服务器,BIND作为DNS服务器以及Dovecot作为IMAP / POP3服务器。
1初步说明
在本教程中,我使用IP地址为192.168.0.100且网关为192.168.0.1的主机名server1.example.com。这些设置可能因您而异,因此您必须在适当的地方进行替换。 在继续进行操作之前,您需要最小安装Debian10。这可能是托管提供商提供的Debian最小映像,或者您使用Minimal Debian Server 教程来设置基本系统。
以下所有命令均以root用户身份运行。直接以root用户身份登录或以普通用户身份登录,然后使用以下命令
su -
在继续之前成为服务器上的root用户。重要信息:您必须使用’su-‘而不是’su’,否则Debian将PATH变量设置为错误。
2安装SSH服务器
如果您在系统安装过程中未安装OpenSSH服务器,则可以立即执行以下操作:
apt-get -y install ssh openssh-server
从现在开始,您可以使用SSH客户端(例如PuTTY)并将其从工作站连接到Debian 10服务器,并按照本教程中的其余步骤进行操作。
3安装外壳文本编辑器(可选)
在本教程中,我将 使用 nano文本编辑器。一些用户更喜欢经典的vi编辑器,因此我将在此处安装这两个编辑器。默认的vi 程序在Debian和Ubuntu上有一些奇怪的行为。为了解决这个问题,我们安装了vim-nox :
apt-get -y install nano vim-nox
(如果您使用其他文本编辑器(如joe),则不必这样做。)
4配置主机名
服务器的主机名应为子域,例如“ server1.example.com”。请勿将没有子域部分的域名(例如“ example.com”)用作主机名,因为这将在以后的邮件设置中引起问题。首先,您应该检查/ etc / hosts中的主机名, 并在必要时进行更改。该行应为:“ IP地址-空间-完整主机名,包括域-空间-子域部分”。E dit / etc / hosts。使它看起来像这样:
nano /etc/hosts
127.0.0.1 localhost.localdomain localhost 192.168.0.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中包含buster / updates存储库(这可确保您始终获得ClamAV病毒扫描程序的最新更新-该项目经常发布发行版本,有时旧版本会停止工作),并且启用了contrib和非自由存储库。
nano /etc/apt/sources.list
deb http://deb.debian.org/debian/ buster main contrib non-free
deb-src http://deb.debian.org/debian/ buster main contrib non-free
deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/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
Use dash as the default system shell (/bin/sh)? <– No
如果不这样做,则ISPConfig安装将失败。
7同步系统时钟
这是一个好主意,系统时钟与NTP(同步ñ etwork 牛逼 IME p通过Internet rotocol)服务器。只需运行
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
您将被询问以下问题:
General type of mail configuration: <– Internet Site
System mail name: <– server1.example.com
要保护MariaDB / MySQL安装并禁用测试数据库,请运行以下命令:
mysql_secure_installation
我们不必更改MariaDB根密码,因为我们在安装过程中仅设置了一个新密码。回答以下问题:
Change the root password? [Y/n] <-- y
New password: <-- Enter a new database root password
Re-enter new password: <-- Repeat the database 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文件看起来完全像下面这样的这个部分。重要提示:删除以smtps开头并提交的行前面的#,而不仅仅是从这些行之后的-o行中删除!
[...]
submission inet n - y - - 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 - y - - 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在所有接口上侦听,而不仅仅是在localhost上,因此我们编辑/etc/mysql/mariadb.conf.d/50-server.cnf 并注释掉bind-address = 127.0.0.1这行:
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 [...]
保存文件。然后将MariaDB中的密码身份验证方法设置为native,这样我们以后就可以使用PHPMyAdmin以root用户身份进行连接:
echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root
编辑文件/etc/mysql/debian.cnf,并在以单词password开头的行中两次设置MYSQL / MariaDB根密码。
nano /etc/mysql/debian.cnf
需要添加的MySQL根密码以红色显示。在此示例中,密码为“ 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设置更高的打开文件限制。
使用编辑器打开文件/etc/security/limits.conf:
nano /etc/security/limits.conf
并将这些行添加到文件末尾。
mysql soft nofile 65535
mysql hard nofile 65535
接下来,使用mkdir命令创建一个新目录/etc/systemd/system/mysql.service.d/。
mkdir -p /etc/systemd/system/mysql.service.d/
并在其中添加一个新文件:
nano /etc/systemd/system/mysql.service.d/limits.conf
将以下行粘贴到该文件中:
[Service]
LimitNOFILE=infinity
保存文件并关闭nano编辑器。
然后,我们重新加载systemd并重新启动MariaDB:
systemctl daemon-reload
systemctl restart mariadb
忽略警告:“ 警告:mariadb.service的单元文件,源配置文件或插件已在磁盘上更改。运行’systemctl daemon-reload’以重新加载单元。 ”。
安装dbconfig-common系统:
apt-get install dbconfig-common dbconfig-mysql
Debian dbconfig-common系统当前存在问题,该问题阻止以后再安装RoundCube,请通过运行以下命令对其进行修复:
sed -i -r 's/_dbc_nodb="yes" dbc_mysql_exec/_dbc_nodb="yes"; dbc_mysql_exec/g' /usr/share/dbconfig-common/internal/mysql
现在检查是否已启用网络连接。跑
netstat -tap | grep mysql
输出应如下所示:
root@server1:~# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 4027/mysqld
root@server1:~#
9安装新的Amavisd,SpamAssassin和ClamAV
要安装amavisd-new,SpamAssassin和ClamAV,我们运行:
apt-get install amavisd-new spamassassin clamav clamav-daemon unzip bzip2 arj nomarch lzop cabextract p7zip p7zip-full unrar lrzip 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 libdbd-mysql-perl postgrey
ISPConfig 3设置使用amavisd在内部加载SpamAssassin筛选器库,因此我们可以停止SpamAssassin释放一些RAM:
systemctl stop spamassassin
systemctl disable spamassassin
10安装Nginx,PHP(PHP-FPM)和Fcgiwrap
Nginx是Debian的软件包,我们可以按以下方式安装:
apt-get install nginx
如果系统上已经安装了Apache2,请立即将其停止…
systemctl stop apache2
消息“ 无法停止apache2.service:未加载单元apache2.service。 ”的信息很好,并不表示错误。
…并删除Apache的系统启动链接:
systemctl disable apache2
然后启动nginx:
systemctl start nginx
(如果同时安装了Apache2和nginx,则ISPConfig 3安装程序将询问您要使用哪一个- 在这种情况下,请回答nginx。如果同时安装了这两者,则ISPConfig将自动进行必要的配置。)
我们可以通过PHP-FPM使PHP 7.3在nginx中工作(PHP-FPM(FastCGI流程管理器)是另一种PHP FastCGI实现,具有一些适用于任何规模的站点(尤其是繁忙站点)的附加功能),我们按如下方式安装:
apt-get install php7.3-fpm
PHP-FPM是一个守护进程,它在/var/run/php/php7.3-fpm.sock套接字上运行FastCGI服务器。
要获得PHP对MySQL的支持,我们可以安装php7.3-mysql 软件包。安装其他一些PHP模块以及您的应用程序可能需要它们是一个好主意。您可以搜索可用的PHP模块,如下所示:
apt-cache search php7
选择所需的组件并按如下所示安装它们:
apt-get install php7.3 php7.3-common php7.3-gd php7.3-mysql php7.3-imap php7.3-cli php7.3-cgi php-pear mcrypt imagemagick libruby php7.3-curl php7.3-intl php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl memcached php-memcache php-imagick php-gettext php7.3-zip php7.3-mbstring memcached php7.3-soap php7.3-fpm php7.3-opcache php-apcu
接下来打开/etc/php/7.3/fpm/php.ini …
nano /etc/php/7.3/fpm/php.ini
…并设置cgi.fix_pathinfo = 0和您的时区:
[...] cgi.fix_pathinfo=0 [...] date.timezone="Europe/Berlin" [...]
(您可以在/ usr / share / zoneinfo目录及其子目录中找到所有可用的时区。)
现在重新加载PHP-FPM:
systemctl restart php7.3-fpm
为了在nginx中获得CGI支持,我们安装Fcgiwrap。
Fcgiwrap是一个CGI包装程序,它也应适用于复杂的CGI脚本,并且可用于共享主机环境,因为它允许每个虚拟主机使用自己的cgi-bin目录。
安装fcgiwrap软件包:
apt-get install fcgiwrap
安装之后,fcgiwrap守护程序应该已经启动;它的套接字是/var/run/fcgiwrap.socket。如果未运行,则可以使用 fservice fcgiwrap脚本启动它。
而已!现在,当您创建nginx虚拟主机时,ISPConfig将照顾正确的虚拟主机配置。
10.1安装phpMyAdmin
从Debian 10开始,PHPMyAdmin不再作为.deb软件包提供。因此,我们将从源代码安装它。
为PHPMyadmin创建文件夹:
mkdir /usr/share/phpmyadmin
mkdir /etc/phpmyadmin
mkdir -p /var/lib/phpmyadmin/tmp
chown -R www-data:www-data /var/lib/phpmyadmin
touch /etc/phpmyadmin/htpasswd.setup
转到/ tmp目录并下载PHPMyAdmin源:
cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz
解压缩下载的存档文件,并将文件移至/ usr / share / phpmyadmin文件夹,并清理/ tmp目录。
tar xfz phpMyAdmin-4.9.0.1-all-languages.tar.gz
mv phpMyAdmin-4.9.0.1-all-languages/* /usr/share/phpmyadmin/
rm phpMyAdmin-4.9.0.1-all-languages.tar.gz
rm -rf phpMyAdmin-4.9.0.1-all-languages
根据提供的示例文件为PHPMyaAdmin创建一个新的配置文件:
cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
使用nano编辑器打开配置文件:
nano /usr/share/phpmyadmin/config.inc.php
设置一个安全密码(河豚密码),该密码必须为32个字符长:
$cfg['blowfish_secret'] = 'bD3e6wva9fnd93jVsb7SDgeiBCd452Dh'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
不要以我的河豚为例,设置您自己的一个!
然后添加一行以设置目录,PHPMyAdmin将使用该目录存储临时文件:
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
在下一步中,我们将配置phpMyadmin配置存储(数据库)。
以root用户身份登录MariaDB:
mysql -u root -p
在MariaDB Shell中,为PHPMyAdmin创建一个新数据库:
MariaDB [(none)]> CREATE DATABASE phpmyadmin;
然后创建一个新用户:
MariaDB [(none)]> CREATE USER 'pma'@'localhost' IDENTIFIED BY 'mypassword';
在上面和下面的命令中,用您选择的安全密码替换单词mypassword,两次都使用相同的密码。然后,授予用户对此数据库的访问权限并重新加载数据库权限。
MariaDB [(none)]> GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT
最后,将SQL表加载到数据库中:
mysql -u root -p phpmyadmin < /usr/share/phpmyadmin/sql/create_tables.sql
根据要求输入MariaDB根密码。
现在我们要做的就是在配置文件中设置phpmyadmin用户详细信息。再次在nano编辑器中打开文件:
nano /usr/share/phpmyadmin/config.inc.php
向下滚动,直到看到下面的行并进行编辑:
/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'localhost';
$cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'mypassword';
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
我已将已编辑的行标记为红色。将mypassword替换为为phpmyadmin用户选择的密码。请注意,行前的//也已删除!
安装ISPConfig 3.1后,可以按以下方式访问phpMyAdmin:
nginx的端口8081上的ISPConfig应用程序虚拟主机带有phpMyAdmin配置,因此您可以使用http://server1.example.com:8081/phpmyadmin或http://server1.example.com:8081/phpMyAdmin访问phpMyAdmin。
如果要使用可从您的网站使用的/ phpmyadmin或/ phpMyAdmin别名,则这比Apache更为复杂,因为nginx没有全局别名(即,可以为所有虚拟主机定义的别名)。因此,您必须为要从中访问phpMyAdmin的每个虚拟主机定义这些别名。
为此,稍后将以下内容粘贴到ISPConfig中网站的“ 选项”选项卡上的nginx指令字段中:
location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include /etc/nginx/fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpMyAdmin { rewrite ^/* /phpmyadmin last; }
如果您使用HTTP 小号,而不是http为你的虚拟主机,你应该添加一行fastcgi_param HTTPS上; 到您的phpMyAdmin配置,如下所示:
location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; fastcgi_param HTTPS on; # <-- add this line fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include /etc/nginx/fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpMyAdmin { rewrite ^/* /phpmyadmin last; }
如果同时使用http和https作为虚拟主机,则可以使用$ https变量。再次转到nginx Directives字段,而不要使用fastcgi_param HTTPS;您将以下行添加为fastcgi_param HTTPS $ https; 这样您就可以将phpMyAdmin用于http和https请求:
location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; fastcgi_param HTTPS $https; # <-- add this line fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include /etc/nginx/fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpMyAdmin { rewrite ^/* /phpmyadmin last; }
11安装让我们加密
ISPConfig 3.1支持免费的SSL证书授权让我们进行加密。通过“加密”功能,您可以从ISPConfig中为网站创建免费的SSL证书。
cd /usr/local/bin
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto --install-only
12安装Mailman
ISPConfig允许您管理(创建/修改/删除)Mailman邮件列表。如果要使用此功能,请按以下步骤安装Mailman:
apt-get install mailman
选择至少一种语言,例如:
Languages to support: <– en (English)
Missing site list <– Ok
在启动Mailman之前,必须创建一个名为mailman的第一个邮件列表:
newlist mailman
root@server1:~# newlist mailman
Enter the email of the person running the list: <– admin email address, e.g. listadmin@example.com
Initial mailman password: <– admin password for the mailman list
To finish creating your mailing list, you must edit your /etc/aliases (or
equivalent) file by adding the following lines, and possibly running the
`newaliases’ program:
## mailman mailing list
mailman: “|/var/lib/mailman/mail/mailman post mailman”
mailman-admin: “|/var/lib/mailman/mail/mailman admin mailman”
mailman-bounces: “|/var/lib/mailman/mail/mailman bounces mailman”
mailman-confirm: “|/var/lib/mailman/mail/mailman confirm mailman”
mailman-join: “|/var/lib/mailman/mail/mailman join mailman”
mailman-leave: “|/var/lib/mailman/mail/mailman leave mailman”
mailman-owner: “|/var/lib/mailman/mail/mailman owner mailman”
mailman-request: “|/var/lib/mailman/mail/mailman request mailman”
mailman-subscribe: “|/var/lib/mailman/mail/mailman subscribe mailman”
mailman-unsubscribe: “|/var/lib/mailman/mail/mailman unsubscribe mailman”
Hit enter to notify mailman owner… <– ENTER
root@server1:~#
然后打开/ etc / aliases …
nano /etc/aliases
…并添加以下行:
[...] ## mailman mailing list mailman: "|/var/lib/mailman/mail/mailman post mailman" mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman" mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman" mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman" mailman-join: "|/var/lib/mailman/mail/mailman join mailman" mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman" mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman" mailman-request: "|/var/lib/mailman/mail/mailman request mailman" mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"
运行
newaliases
然后重启Postfix:
systemctl restart postfix
然后启动Mailman守护程序:
systemctl restart mailman
安装ISPConfig 3后,可以按以下方式访问Mailman:
Nginx的端口8081上的ISPConfig应用程序虚拟主机带有Mailman配置,因此您可以使用
http://server1.example.com:8081/cgi-bin/mailman/admin/<listname> 或者 http://server1.example.com:8081/cgi-bin/mailman/listinfo/<listname>访问Mailman。
如果要从网站上使用Mailman,则这比Apache更为复杂,因为nginx没有全局别名(即,可以为所有虚拟主机定义的别名)。因此,您必须为要从中访问Mailman的每个虚拟主机定义这些别名。
为此,请将以下内容粘贴到ISPConfig中网站“ 选项”选项卡上的nginx指令字段中:
location /cgi-bin/mailman { root /usr/lib/; fastcgi_split_path_info (^/cgi-bin/mailman/[^/]*)(.*)$; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_intercept_errors on; fastcgi_pass unix:/var/run/fcgiwrap.socket; } location /images/mailman { alias /usr/share/images/mailman; } location /pipermail { alias /var/lib/mailman/archives/public; autoindex on; }
这为您的虚拟主机定义了别名/ cgi-bin / mailman /,这意味着您可以访问Mailman管理界面以获取位于http:// <vhost> / cgi-bin / mailman / admin / <listname>的列表。邮件列表用户的网页可以在http:// <vhost> / cgi-bin / mailman / listinfo / <listname>中找到。
在http:// <vhost> / pipermail下,您可以找到邮件列表档案。
13安装PureFTPd和配额
可以使用以下命令安装PureFTPd和quota:
apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool
编辑文件/ etc / default / pure-ftpd-common …
nano /etc/default/pure-ftpd-common
…并确保将启动模式设置为独立模式并设置VIRTUALCHROOT = true:
[...] STANDALONE_OR_INETD=standalone [...] VIRTUALCHROOT=true [...]
现在,我们将PureFTPd配置为允许FTP和TLS会话。FTP是一种非常不安全的协议,因为所有密码和所有数据均以明文形式传输。通过使用TLS,可以加密整个通信,从而使FTP更加安全。
如果要允许FTP和TLS会话,请运行
echo 1 > /etc/pure-ftpd/conf/TLS
为了使用TLS,我们必须创建一个SSL证书。我在/ etc / ssl / private /中创建它,因此我首先创建该目录:
mkdir -p /etc/ssl/private/
之后,我们可以生成SSL证书,如下所示:
openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
Country Name (2 letter code) [AU]: <– Enter your Country Name (e.g., “DE”).
State or Province Name (full name) [Some-State]:<– Enter your State or Province Name.
Locality Name (eg, city) []:<– Enter your City.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:<– Enter your Organization Name (e.g., the name of your company).
Organizational Unit Name (eg, section) []:<– Enter your Organizational Unit Name (e.g. “IT Department”).
Common Name (eg, YOUR name) []:<– Enter the Fully Qualified Domain Name of the system (e.g. “server1.example.com”).
Email Address []:<– Enter your Email Address.
更改SSL证书的权限:
chmod 600 /etc/ssl/private/pure-ftpd.pem
然后重新启动PureFTPd:
systemctl restart pure-ftpd-mysql
编辑/ etc / fstab。我的看起来像这样(我将,usrjquota = quota.user,grpjquota = quota.group,jqfmt = vfsv0添加到了具有挂载点/的分区):
nano /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=45576b38-39e8-4994-b8c1-ea4870e2e614 / ext4 errors=remount-ro,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0 1
# swap was on /dev/sda5 during installation
UUID=8bea0d1e-ec37-4b20-9976-4b7daaa3eb69 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
要启用配额,请运行以下命令:
mount -o remount /
quotacheck -avugm
quotaon -avug
14安装BIND DNS服务器
BIND可以如下安装:
apt-get install bind9 dnsutils
如果您的服务器是虚拟机,则强烈建议安装Haveged守护程序,以提高DNSSEC签名的熵。您也可以在非虚拟服务器上安装Haveged,这不会造成伤害。
apt-get -y install haveged
systemctl enable haveged
systemctl start haveged
关于该主题的说明可以在这里找到。
15安装Webalizer和AWStats
Webalizer和AWStats可以按以下方式安装:
apt-get install webalizer awstats geoip-database libtimedate-perl libclass-dbi-mysql-perl
然后打开/etc/cron.d/awstats …
nano /etc/cron.d/awstats
…并注释掉该文件中的所有内容:
#MAILTO=root #*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh # Generate static reports: #10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh
16安装Jailkit
仅当您想要chroot SSH用户时才需要Jailkit。它可以按以下方式安装(重要:重要:必须在ISPConfig之前安装Jailkit-之后不能再安装!):
apt-get install build-essential autoconf automake libtool flex bison debhelper binutils
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.20.tar.gz
tar xvfz jailkit-2.20.tar.gz
cd jailkit-2.20
echo 5 > debian/compat
./debian/rules binary
现在,您可以按以下方式安装Jailkit .deb软件包:
cd ..
dpkg -i jailkit_2.20-1_*.deb
rm -rf jailkit-2.20*
17安装Fail2ban和UFW防火墙
这是可选的,但建议这样做,因为ISPConfig监视器尝试显示日志:
apt-get install fail2ban
要使fail2ban监视PureFTPd和Dovecot,请创建文件/etc/fail2ban/jail.local:
nano /etc/fail2ban/jail.local
[pure-ftpd]
enabled = true
port = ftp
filter = pure-ftpd
logpath = /var/log/syslog
maxretry = 3
[dovecot]
enabled = true
filter = dovecot
logpath = /var/log/mail.log
maxretry = 5
[postfix-sasl]
enabled = true
port = smtp
filter = postfix[mode=auth]
logpath = /var/log/mail.log
maxretry = 3
之后重新启动fail2ban:
systemctl restart fail2ban
要安装UFW防火墙,请运行以下apt命令:
apt-get install ufw
18安装RoundCube
使用以下命令安装RoundCube:
apt-get install roundcube roundcube-core roundcube-mysql roundcube-plugins
安装程序将询问以下问题:
Configure database for roundcube with dbconfig.common? <-- yes
MySQL application password for roundcube: <-- press enter
Password of the databases administrative user: <-- enter the MySQL root password here.
然后编辑RoundCube /etc/roundcube/config.inc.php文件并调整一些设置:
nano /etc/roundcube/config.inc.php
将default_host和smtp_server设置为localhost。
$config['default_host'] = 'localhost';
$config['smtp_server'] = 'localhost';
ISPConfig在Nginx应用程序vhost中对squirrelmail进行了一些配置,该配置也适用于roundcube。我们通过以下方式激活它:
ln -s /usr/share/roundcube /usr/share/squirrelmail
http://192.168.0.100:8081/webmail
http://server1.example.com:8081/webmail(安装ISPConfig之后,请参见下一章)
19安装ISPConfig 3
在开始ISPConfig安装之前,请确保Apache已停止(如果已安装,则可能是某些已安装的软件包在不知情的情况下已将Apache安装为依赖项)。如果系统上已经安装了Apache2,请立即将其停止…
systemctl stop apache2
…并删除Apache的系统启动链接:
update-rc.d -f apache2 remove
确保nginx正在运行:
systemctl start nginx
(如果同时安装了Apache和nginx,则安装程序会询问您要使用哪一个:检测到Apache和nginx。选择要用于ISPConfig的服务器:(apache,nginx)[apache]:
输入nginx。如果仅安装了Apache或nginx,安装程序会自动检测到它,并且不会出现任何问题。)
要从最新发布的版本安装ISPConfig 3.1,请执行以下操作:
cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install/
下一步是运行
php -q install.php
这将启动ISPConfig 3安装程序。安装程序将为您配置所有服务,如Postfix,Nginx,Dovecot等。
# php -q install.php
--------------------------------------------------------------------------------
_____ ___________ _____ __ _ ____
|_ _/ ___| ___ \ / __ \ / _(_) /__ \
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ /
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/
__/ |
|___/
--------------------------------------------------------------------------------
>> Initial configuration
Operating System: Debian 10.0 (Buster) or compatible
Following will be a few questions for primary configuration so be careful.
Default values are in [brackets] and can be accepted with <ENTER>.
Tap in "quit" (without the quotes) to stop the installer.
Select language (en,de) [en]: <-- Hit Enter
Installation mode (standard,expert) [standard]: <-- Hit Enter
Full qualified hostname (FQDN) of the server, eg server1.domain.tld [server1.canomi.com]: <-- Hit Enter
MySQL server hostname [localhost]: <-- Hit Enter
MySQL server port [3306]: <-- Hit Enter
MySQL root username [root]: <-- Hit Enter
MySQL root password []: <-- Enter your MySQL root password
MySQL database to create [dbispconfig]: <-- Hit Enter
MySQL charset [utf8]: <-- Hit Enter
Apache and nginx detected. Select server to use for ISPConfig: (apache,nginx) [apache]: <-- nginx
Configuring Postgrey
Configuring Postfix
Generating a 4096 bit RSA private key
.......................................................................++
........................................................................................................................................++
writing new private key to 'smtpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: <-- Enter 2 letter country code
State or Province Name (full name) [Some-State]: <-- Enter the name of the state
Locality Name (eg, city) []: <-- Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter company name or press enter
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (e.g. server FQDN or YOUR name) []: <-- Enter the server hostname, in my case: server1.example.com
Email Address []: <-- Hit Enter
Configuring Mailman
Configuring Dovecot
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring BIND
Configuring Jailkit
Configuring Pureftpd
Configuring Nginx
Configuring vlogger
[INFO] service Metronome XMPP Server not detected
Configuring UFW Firewall
Configuring Fail2ban
[INFO] service OpenVZ not detected
Configuring Apps vhost
Installing ISPConfig
ISPConfig Port [8080]:
Admin password [admin]: <-- Enter desired ISPConfig admin user password here
Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]: <-- Hit Enter
Generating RSA private key, 4096 bit long modulus
.......................++
................................................................................................................................++
e is 65537 (0x10001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]: <-- Enter 2 letter country code
State or Province Name (full name) [Some-State]: <-- Enter the name of the state
Locality Name (eg, city) []: <-- Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter company name or press enter
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (e.g. server FQDN or YOUR name) []: <-- Enter the server hostname, in my case: server1.example.com
Email Address []: <-- Hit Enter
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <-- Hit Enter
An optional company name []: <-- Hit Enter
writing RSA key
Configuring DBServer
Installing ISPConfig crontab
no crontab for root
no crontab for getmail
Detect IP addresses
Restarting services ...
Installation completed.
安装程序会自动配置所有基础服务,因此不需要手动配置。
之后,您可以在http(s)://server1.example.com:8080 /或http(s)://192.168.1.100:8080 /下访问ISPConfig 3 (http或https取决于您在安装过程中选择的内容)。使用用户名admin和密码admin登录(您应该在首次登录后更改默认密码):
最后,我们修复了RoundCube安装的一些权限。
chown root:ispapps /etc/roundcube/debian-db.php chmod 640 /etc/roundcube/debian-db.php chown root:ispapps /etc/roundcube/config.inc.php chmod 640 /etc/roundcube/config.inc.php chown -R ispapps:adm /var/log/roundcube chmod -R 750 /var/log/roundcube chown -R ispapps:ispapps /var/lib/roundcube/temp chmod -R 750 /var/lib/roundcube/temp
现在可以使用该系统了。
20.1 ISPConfig 3手册
为了学习如何使用ISPConfig 3,我强烈建议下载 ISPConfig 3手册。
在300多个页面上,它涵盖了ISPConfig(管理员,经销商,客户端)的概念,解释了如何安装和更新ISPConfig 3,包括ISPConfig中所有表单和表单字段的参考以及有效输入的示例,并提供了教程。 ISPConfig 3中最常见的任务。它还列出了如何使服务器更安全,并在最后提供了一个故障排除部分。
本教程的21个虚拟机映像下载
本教程可以立即使用,并且可以使用与VMWare和Virtualbox兼容的ovf / ova格式的虚拟机映像。虚拟机映像使用以下登录详细信息:
SSH / Shell登录
用户名:管理员
密码:howtoforge
用户名:root
密码:howtoforge
ISPConfig登录
用户名:admin
密码:howtoforge
MySQL登录
用户名:root
密码:howtoforge
VM的IP为192.168.0.100,可以在文件/ etc / network / interfaces中进行更改。请更改以上所有密码以保护虚拟机。
22个链接
- Debian:http://www.debian.org/
- ISPConfig:http://www.ispconfig.org/
原文:https://www.howtoforge.com/perfect-server-debian-10-nginx-bind-dovecot-ispconfig-3.1/