完璧なサーバー – Apache、Postfix、Dovecot、Pure-FTPD、BIND、および ISPConfig 3.2 を備えた CentOS 8
Apache、PHP、Postfix、Dovecot、Pure-FTPD、BIND および ISPConfig 3.2を含む、完璧なサーバー CentOS 8
このチュートリアルでは、CentOS 8(64ビット)サーバーにISPConfig 3.2をインストールする手順を示します。ISPConfigは、ウェブブラウザを通じて次のサービスを構成できるウェブホスティングコントロールパネルです:Apacheウェブサーバー、PHP、Postfixメールサーバー、MySQL、BINDネームサーバー、PureFTPd、SpamAssassin、ClamAV、Mailmanなど多数。
1 要件
このようなシステムをインストールするには、以下が必要です:
- CentOS 8のミニマルサーバーシステム。これは、私たちのCentOS 8ミニマルサーバーチュートリアルに記載されているように、一からインストールされたサーバーか、ミニマルなCentOS 8セットアップがインストールされたホスティング会社のバーチャルサーバーやルートサーバーになります。
- 高速インターネット接続。
予備的注意2
このチュートリアルでは、ホスト名 server1.example.com と IP アドレス 192.168.0.100、ゲートウェイ 192.168.0.1 を使用します。これらの設定はあなたの環境によって異なる場合があるので、適切な箇所で置き換える必要があります。
サーバーを準備する
キーボードレイアウトを設定する
サーバーのキーボードレイアウトがあなたのキーボードと一致しない場合、適切なキーボードに切り替えることができます(私の場合は「de」でドイツのキーボードレイアウト、localectlコマンドを使って:
localectl set-keymap de
すべての利用可能なキーマップのリストを取得するには、次のコマンドを実行してください:
localectl list-keymapsこのチュートリアルの最後にISPConfigをインストールしたいと思います。ISPConfigには、私がファイアウォールとして使用するBastilleファイアウォールスクリプトが付属しています。そのため、今はCentOSのデフォルトのファイアウォールを無効にします。もちろん、CentOSのファイアウォールを有効のままにしておき、自分のニーズに合わせて設定することもできます(ただし、その場合は他のファイアウォールを使用しない方が良いでしょう。おそらくCentOSのファイアウォールに干渉してしまうためです)。
走って...
dnf -y install net-tools wget rsyslog curl
systemctl stop firewalld.service
systemctl disable firewalld.serviceCentOSファイアウォールを停止して無効にすることです。ここでエラーが出ても大丈夫です。これは単にファイアウォールがインストールされていないことを示しています。
それなら、ファイアウォールが本当に無効になっているかどうかを確認する必要があります。そのためには、次のコマンドを実行してください:
iptables -L出力はこのように見えるべきです:
[root@server1 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destinationChain FORWARD (policy ACCEPT)
target prot opt source destinationChain OUTPUT (policy ACCEPT)
target prot opt source destinationまたは、firewall-cmdコマンドを使用します:
firewall-cmd --state[root@server1 ~]# firewall-cmd --state
not running
[root@server1 ~]#今からネットワーク設定エディタと、次のステップで設定ファイルを編集するために使用するシェルベースのエディタ「nano」をインストールします。
dnf -y install nano wget NetworkManager-tui yum-utilsインストール中にネットワークカードを設定しなかった場合は、今設定できます。実行して...
nmtui... 接続を編集するために行ってください:
ネットワークインターフェースを選択してください:
次に、ネットワークの詳細を入力します - DHCPを無効にして、静的IPアドレス、ネットマスク、ゲートウェイ、1つまたは2つのネームサーバーを入力し、OKをクリックします:
次に、ネットワーク設定で行った変更を確認するために「OK」を選択します。
nmtuiネットワーク設定ツールを閉じるには、終了します。
あなたは走るべきです
ifconfig
今、インストーラーがあなたのIPアドレスを正しく取得したか確認します:
[root@server1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:feee:b665 prefixlen 64 scopeid 0x20<link>
inet6 2003:e1:bf22:1b00:20c:29ff:feee:b665 prefixlen 64 scopeid 0x0<global>
ether 00:0c:29:ee:b6:65 txqueuelen 1000 (Ethernet)
RX packets 2874 bytes 1369892 (1.3 MiB)
RX errors 0 dropped 546 overruns 0 frame 0
TX packets 968 bytes 160901 (157.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0もしネットワークカードがそこに表示されない場合、それはブート時に有効になっていない可能性があります。この場合、ファイル /etc/sysconfig/network-scripts/ifcfg-eth0 を開いてください。
nano /etc/sysconfig/network-scripts/ifcfg-ens33ONBOOTをyesに設定します:
[...]
ONBOOT=yes
[...]サーバーを再起動します。
/etc/resolv.conf をチェックして、以前に設定したすべてのネームサーバーがリストされているか確認してください:
cat /etc/resolv.confネームサーバーが欠けている場合は、実行してください
nmtuiそして、欠落しているネームサーバーを再度追加してください。
さて、設定に移りましょう…
/etc/hosts と /etc/hostname の調整
次に、/etc/hostsを編集します。これのように見えるようにします:
nano /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.0.100 server1.example.com server1
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6/etc/hostnameファイルにホスト名を設定します。このファイルには、完全修飾ドメイン名(私の場合、server1.example.comなど)を含める必要があり、「server1」のような短い名前だけではありません。nanoエディタでファイルを開きます:
nano /etc/hostnameそしてファイルにホスト名を設定します。
server1.example.comファイルを保存してnanoを終了します。
SELinuxを許可モードに設定する
SELinuxはCentOSのセキュリティ拡張で、拡張されたセキュリティを提供するはずです。ISPConfigはSELinuxのルールセットを付属していないため、私はそれを許可モードに設定しました(後でISPConfigをインストールしたい場合は必須です)。
/etc/selinux/config を編集し、SELINUX=permissive に設定してください。
nano /etc/selinux/configThis file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=permissive
SELINUXTYPE= can take one of these two values:
targeted - Targeted processes are protected,
mls - Multi Level Security protection.
SELINUXTYPE=targeted
その後、システムを再起動しなければなりません。
reboot4 追加のリポジトリを有効にし、いくつかのソフトウェアをインストールする
まず、ソフトウェアパッケージのためにGPGキーをインポートします:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*次に、CentOSシステムでEPELリポジトリを有効にします。このチュートリアルの過程でインストールするパッケージの多くは、公式のCentOS 8リポジトリでは利用できません。
dnf -y install epel-releaseパワーツールをアクティブにする:
dnf config-manager --set-enabled powertools次に、システム上の既存のパッケージを更新します:
dnf -y updateこれから後で必要になるソフトウェアパッケージをいくつかインストールします:
dnf -y groupinstall 'Development Tools'5 クォータ
(もし私とは異なるパーティショニング方式を選択した場合は、この章を調整して、必要なパーティションに割り当てが適用されるようにしてください。)
クォータをインストールするには、このコマンドを実行します:
dnf -y install quota今、ウェブサイト(/var/www)およびMaildirデータ(/var/vmail)が保存されているファイルシステムで、クォータがすでに有効になっているかを確認します。この例の設定では、私は大きなルートパーティションを持っているので、‘/’を検索します:
mount | grep ' / '[root@server1 ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
[root@server1 ~]#別の /var パーティションがある場合は、次のようにします:
mount | grep ' /var '代わりに。その行に単語「noquota」が含まれている場合は、次の手順に従ってクォータを有効にします。
/(ルート)パーティションでのクォータの有効化
通常、/etc/fstab ファイルでクォータを有効にしますが、ファイルシステムがルートファイルシステム「/」の場合、クォータはLinuxカーネルのブートパラメータによって有効にする必要があります。
grub設定ファイルを編集します:
nano /etc/default/grubGRUB_CMDLINE_LINUX で始まる行を検索し、コマンドラインパラメータに rootflags=uquota,gquota を追加してください。結果として得られる行は次のようになります:
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rootflags=uquota,gquota"そして、次のコマンドを実行して変更を適用します。
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg_bak
grub2-mkconfig -o /boot/grub2/grub.cfgサーバーを再起動します。
reboot今、クォータが有効になっているか確認してください:
mount | grep ' / '[root@server1 ~]# mount | grep ' / '
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
[root@server1 ~]#クォータがアクティブな場合、マウントオプションリストに「usrquota,grpquota」が表示されます。
別の /var パーティションでのクォータの有効化
別の /var パーティションがある場合は、/etc/fstab を編集して/パーティション (/dev/mapper/centos-var) に ,uquota,gquota を追加してください。
nano /etc/fstab#
/etc/fstab
Created by anaconda on Sun Sep 21 16:33:45 2014
#
Accessible filesystems, by reference, are maintained under '/dev/disk'
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 1 1
/dev/mapper/centos-var /var xfs defaults,uquota,gquota 1 2
UUID=9ac06939-7e43-4efd-957a-486775edd7b4 /boot xfs defaults 1 3
/dev/mapper/centos-swap swap swap defaults 0 0
それから走ってください
mount -o remount /varquotacheck -avugm
quotaon -avugクォータを有効にするために。クォータが有効なパーティションがないというエラーが表示された場合は、続行する前にサーバーを再起動してください。
Apache、PHP、MySQL、およびphpMyAdminをインストールする
新しいPHPバージョン(現在はPHP 7.4)を取得するためにRemiリポジトリを有効にしてください。
dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf -y install yum-utils
dnf -y module reset php
dnf -y module install php:remi-7.4
dnf update必要なパッケージを1つのコマンドでインストールできます:
dnf -y install httpd mod_ssl mariadb-server php php-mysqlnd php-mbstringサーバーがHTTPOXYの脆弱性を通じて攻撃されることがないように、ApacheでHTTP_PROXYヘッダーをグローバルに無効にします。
httpd.confファイルの最後にApacheヘッダーのルールを追加してください:
echo "RequestHeader unset Proxy early" >> /etc/httpd/conf/httpd.confそして、設定変更を適用するためにhttpdを再起動します。
service httpd restartphpMyAdminをインストールする:
cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.tar.gz
tar xzvf phpMyAdmin-5.0.2-all-languages.tar.gz
mkdir /usr/share/phpmyadmin
mv phpMyAdmin-5.0.2-all-languages/* /usr/share/phpmyadmin/
mkdir /usr/share/phpmyadmin/tmp
chown -R apache:apache /usr/share/phpmyadmin
chmod 777 /usr/share/phpmyadmin/tmpオプション: Apache MPMモジュールを変更する
CentOS 8はデフォルトでApache MPM Eventモジュールを使用しています。これはHTTP/2プロトコルを使用できるため、良い点もあります。一方で、apache mod_phpモジュールを使用することはできません。一般的に、今日ではデフォルトでPHP-FPMを使用すべきであり、ISPConfigはそれをサポートしています。互換性の理由から古いmod_phpモードが必要な場合は、次のようにApache MPMを切り替えることができます。
nano /etc/httpd/conf.modules.d/00-mpm.confMPM イベント行の前に # を追加して、次のようにします:
LoadModule mpm_event_module modules/mod_mpm_event.so次に、MPM Prefork行の前にある#を削除して、次のようにします:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so次に、設定変更を適用するためにhttpdを再起動します。
service httpd restart7 Dovecotをインストールする
Dovecot は次のようにインストールできます:
dnf -y install dovecot dovecot-mysql dovecot-pigeonhole空の dovecot-sql.conf ファイルを作成し、シンボリックリンクを作成します:
touch /etc/dovecot/dovecot-sql.conf
ln -s /etc/dovecot/dovecot-sql.conf /etc/dovecot-sql.conf
ln -s /etc/dovecot/dovecot.conf /etc/dovecot.confシステム起動リンクを作成し、Dovecotを起動してください。
systemctl enable dovecot
systemctl start dovecot8 Postfixをインストールする
Postfixは次のようにインストールできます。
dnf -y install postfix postfix-mysql次に、PostfixでTLS/SSLおよび送信ポートを開きます:
nano /etc/postfix/master.cfsubmission および smtps セクションのコメントを外し、必要に応じて行を追加して、master.cf ファイルのこのセクションが以下のものとまったく同じになるようにします。重要: smtps および submission で始まる行の前にある # を削除してください。そして、これらの行の後の -o 行だけではありません!
[...]
submission inet n - 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 - 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
[...]それからSendmailを停止し、PostfixとMariaDB(MySQL)を起動します。
systemctl enable mariadb.service
systemctl start mariadb.servicesystemctl enable postfix.service
systemctl restart postfix.servicesendmailがサーバーにインストールされている場合に備えて、sendmailを無効にします。そのため、「メソッド呼び出しの発行に失敗しました: ユニットsendmail.serviceが読み込まれていません。」というエラーメッセージは無視しても構いません。
古い/時代遅れのデバイスのサポートを有効にするには、このコマンドを実行してください(オプションであり、古いメールデバイスが接続する必要があるときのみ使用してください。これは、より安全でない暗号を許可することにより、SSL/TLS設定を弱めるためです)。
update-crypto-policies --set LEGACY9 Getmailをインストールする
Getmailは次のようにインストールできます。
dnf install python2
cd /tmp
wget http://pyropus.ca/software/getmail/old-versions/getmail-5.14.tar.gz
tar xvfz getmail-5.14.tar.gz
cd getmail-5.14
python2 setup.py build
python2 setup.py install10個のMySQLパスワードを設定し、phpMyAdminを構成する
MySQLのrootアカウントのパスワードを設定します:
mysql_secure_installation[root@server1 tmp]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] <-- ENTER
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <-- ENTER
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] <-- ENTER
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <-- ENTER
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
[root@server1 tmp]#次に、phpMyAdminを構成します。このphpMyAdmin構成ファイルを作成してください。
nano /etc/httpd/conf.d/phpmyadmin.confこの内容をファイルに追加してください:
phpMyAdmin - Web based MySQL browser written in php
#
Allows only localhost by default
#
But allowing phpMyAdmin to anyone other than localhost should be considered
dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
次に、phpMyAdminの認証方式をクッキーからHTTPに変更します。
cp -pf /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
nano /usr/share/phpmyadmin/config.inc.php[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]次に、Apacheのシステム起動リンクを作成し、起動します。
systemctl enable httpd
systemctl restart httpd今、ブラウザを http://server1.example.com/phpmyadmin/ または http://192.168.0.100/phpmyadmin/ に向けて、ユーザー名 root と新しい root MySQL パスワードでログインできます。
11 Amavisd-new、SpamAssassin、ClamAV、Postgreyをインストールする
amavisd-new、SpamAssassin、ClamAVをインストールするには、次のコマンドを実行してください。
dnf -y install amavisd-new spamassassin clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd unzip bzip2 perl-DBD-mysql postgrey re2c次にfreshclam、amavisd、およびclamd.amavisdを起動します。
sa-update
freshclam
systemctl enable amavisd.service
systemctl start amavisd.service
systemctl start clamd@amavisd.service
systemctl enable postgrey.service
systemctl start postgrey.service次のステップでは、postgreyを設定します。エディタでファイル/etc/sysconfig/postgreyを開いてください。
nano /etc/sysconfig/postgreyそしてその行を変更します:
POSTGREY_TYPE="--unix=/var/spool/postfix/postgrey/socket"トゥ
POSTGREY_TYPE="--inet=10023"ファイルを保存してpostgreyを再起動します:
service postgrey restartamavisdを設定するには、/etc/clamd.d/amavisd.confファイルを編集します:
nano /etc/clamd.d/amavisd.confそしてその行を変更します:
LocalSocket /run/clamd.amavisd/clamd.sockトゥ
LocalSocket /var/spool/amavisd/clamd.sock変更された設定ファイルを保存してClamAVを再起動してください。
systemctl restart clamd@amavisd.service今、freshclamサービス用のシステムユニットを作成する必要があります。新しいファイル /usr/lib/systemd/system/freshclam.service を作成してください:
nano /usr/lib/systemd/system/freshclam.serviceそのファイルに次の内容を入力してください:
[Unit]
Description = ClamAV Scanner
After = network.target
[Service]
Type = forking
if you want to scan more than one in a day change the number 1 with your desired number in below line.
ExecStart = /usr/bin/freshclam -d -c 1
Restart = on-failure
PrivateTmp =true
[Install]
WantedBy=multi-user.targetファイルを保存し、その後サービスを有効にして開始します。
systemctl enable freshclam.service
systemctl start freshclam.service
systemctl status freshclam.service12 Apacheのインストール(mod_php、mod_fcgi/PHP、PHP-FPMを使用)
ISPConfig 3は、ウェブサイトごとにmod_php、mod_fcgi/PHP、cgi/PHP、およびPHP-FPMを使用することを許可します。
Apache2をmod_php、mod_fcgid、およびPHPでインストールするには、次のようにします:
dnf -y install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-mbstring php-mcrypt php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel mod_fcgid php-cli httpd-devel php-fpm php-intl php-imagick php-pspell wget次に、/etc/php.iniを開きます...
nano /etc/php.ini... とエラーレポートを変更し(通知が表示されないように)、タイムゾーンを設定し、cgi.fix_pathinfo=1のコメントを外します:
[...]
;error_reporting = E_ALL & ~E_DEPRECATED
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PAppp.tldTH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=1
[...]
date.timezone = 'Europe/Berlin'
[...]ブート時に httpd と PHP-FPM を有効にして、PHP-FPM サービスを開始します。
systemctl start php-fpm.service
systemctl enable php-fpm.service
systemctl enable httpd.serviceついに、Apacheを再起動します。
systemctl restart httpd.serviceこれから、Let's Encryptのサポートを追加します。ISPConfigは現在、Let's Encryptクライアントとしてacme.shを使用しています。次のコマンドを使用してacme.shをインストールしてください。
curl https://get.acme.sh | sh -s13 mod_pythonのインストール
Apacheモジュールmod_pythonはRPMパッケージとして利用できないため、ソースからコンパイルします。最初のステップは、Pythonの開発ファイルをインストールし、現在のmod_pythonのバージョンを.tar.gzファイルとしてダウンロードすることです。
dnf -y install python3-develcd /usr/local/src/
wget http://dist.modpython.org/dist/mod_python-3.5.0.tgz
tar xfz mod_python-3.5.0.tgz
cd mod_python-3.5.0そしてモジュールを設定してコンパイルします。
./configure --with-python=/usr/bin/python3
makeコンパイルされたモジュールにエラーがあり、インストールが次のエラーで失敗します「version="fatal: Not a git repository (or any of the parent directories): .git"」。これを修正するには、このsedコマンドを実行してください(コマンドは1行です!)。
sed -e 's/(git describe --always)/(git describe --always 2>\/dev\/null)/g' -e 's/`git describe --always`/`git describe --always 2>\/dev\/null`/g' -i $( find . -type f -name Makefile\* -o -name version.sh )次に、このコマンドでモジュールをインストールします。
make installそしてApacheでモジュールを有効にします:
echo 'LoadModule python_module modules/mod_python.so' > /etc/httpd/conf.modules.d/10-python.conf
systemctl restart httpd.service14 PureFTPdをインストールする
PureFTPdは、次のコマンドでインストールできます:
dnf -y install pure-ftpd次に、システムのスタートアップリンクを作成し、PureFTPdを起動します:
systemctl enable pure-ftpd.service
systemctl start pure-ftpd.service現在、PureFTPdを設定してFTPおよびTLSセッションを許可します。FTPは非常に安全でないプロトコルであり、すべてのパスワードとデータが平文で転送されます。TLSを使用することで、通信全体を暗号化できるため、FTPははるかに安全になります。
TLSにはOpenSSLが必要です。OpenSSLをインストールするには、単に以下のコマンドを実行します:
dnf install openssl/etc/pure-ftpd/pure-ftpd.confを開きます...
nano /etc/pure-ftpd/pure-ftpd.confFTPとTLSセッションを許可したい場合は、TLSの行の前にある#を削除してTLSを1に設定します。TLSを有効にすることを強く推奨します。
[...]
This option can accept three values :
0 : disable SSL/TLS encryption layer (default).
1 : accept both traditional and encrypted sessions.
2 : refuse connections that don't use SSL/TLS security mechanisms,
including anonymous sessions.
Do _not_ uncomment this blindly. Be sure that :
1) Your server has been compiled with SSL/TLS support (--with-tls),
2) A valid certificate is in place,
3) Only compatible clients will log in.
TLS 1
[...]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国名 (2文字コード) [XX]: <-- 国名を入力してください (例: "DE").
州または省名 (フルネーム) []: <-- 州または省名を入力してください.
地方名 (例: 市) [デフォルトの市]: <-- 市名を入力してください.
組織名 (例: 会社) [デフォルトの会社名株式会社]: <-- 組織名を入力してください (例: 会社名のこと).
組織単位名 (例: 部門) []: <-- 組織単位名を入力してください (例: "IT部門").
一般名 (例: あなたの名前やサーバーのホスト名) []: <-- システムの完全修飾ドメイン名を入力してください (例: "server1.example.com").
メールアドレス []: <-- メールアドレスを入力してください.
SSL証明書の権限を変更します:
chmod 600 /etc/ssl/private/pure-ftpd.pemDHParamファイルを作成してください:
openssl dhparam -out /etc/ssl/private/pure-ftpd-dhparams.pem 2048最後に、PureFTPdを再起動します:
systemctl restart pure-ftpd.serviceそれで終わりです。今、FTPクライアントを使用して接続を試みることができますが、FTPクライアントをTLSを使用するように設定する必要があります。
15 BINDをインストールする
BINDを次のようにインストールできます:
dnf -y install bind bind-utils haveged既存の /etc/named.conf ファイルのバックアップを作成し、次のように新しいものを作成してください:
cp /etc/named.conf /etc/named.conf_bak
cat /dev/null > /etc/named.conf
nano /etc/named.conf//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { any; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
allow-recursion {"none";};
recursion no;
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.conf.local";/etc/named.conf.localというファイルを作成します。これは/etc/named.confの最後に含まれます(/etc/named.conf.localは、ISPConfigでDNSゾーンを作成すると、後でISPConfigによって自動的に設定されます)。
touch /etc/named.conf.localそれから、スタートアップリンクを作成し、BINDを開始します:
systemctl enable named.service
systemctl start named.service
systemctl enable haveged.service
systemctl start haveged.service16 AWStatsをインストールする
AWStatsは次のようにインストールできます。
dnf -y install awstats perl-DateTime-Format-HTTP perl-DateTime-Format-Builder代替のウェブ統計アプリケーション「webalizer」はCentOS 8ではもはや利用できないため、AWStatsのみを使用することができます。
17 Jailkitをインストールする
JailkitはSSHユーザーとcronジョブをchrootするために使用されます。以下のようにインストールできます:
ln -s /usr/bin/python2 /usr/bin/python
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.21.tar.gz
tar xvfz jailkit-2.21.tar.gz
cd jailkit-2.21
./configure
make
make install
cd ..
rm -rf jailkit-2.21*18 Fail2Banをインストールする
これはオプションですが推奨されます。なぜなら、ISPConfigモニターがログを表示しようとするからです。
dnf -y install iptables-services fail2ban fail2ban-systemd
systemctl stop firewalld.service
systemctl mask firewalld.service
systemctl disable firewalld.service次に、/etc/fail2ban/jail.localファイルを作成し、ssh、メール、ftpサービスの監視を有効にします。
nano /etc/fail2ban/jail.local次の内容を jail.local ファイルに追加してください:
[sshd]
enabled = true
action = iptables[name=sshd, port=ssh, protocol=tcp]
[pure-ftpd]
enabled = true
action = iptables[name=FTP, port=ftp, protocol=tcp]
maxretry = 3
[dovecot]
enabled = true
action = iptables-multiport[name=dovecot, port="pop3,pop3s,imap,imaps", protocol=tcp]
maxretry = 5
[postfix-sasl]
enabled = true
action = iptables-multiport[name=postfix-sasl, port="smtp,smtps,submission", protocol=tcp]
maxretry = 3次に、fail2banのシステムスタートアップリンクを作成し、起動します。
systemctl enable fail2ban.service
systemctl start fail2ban.service19 rkhunterをインストールする
rkhunter は次のようにインストールできます:
dnf -y install rkhunter20 メールマンをインストールする
サーバー上でMailmanを使用してメーリングリストを管理するのが好きな場合は、今すぐMailmanをインストールしてください。MailmanはISPConfigによってサポートされているため、後でISPConfigを通じて新しいメーリングリストを作成できるようになります。
dnf -y install mailmanMailmanを開始する前に、最初のメーリングリストとして「mailman」を作成する必要があります:
touch /var/lib/mailman/data/aliases
postmap /var/lib/mailman/data/aliases
/usr/lib/mailman/bin/newlist mailman
ln -s /usr/lib/mailman/mail/mailman /usr/bin/mailman .. <-- ENTER
[root@server1 tmp]#
その後、/etc/aliases を開いてください...
nano /etc/aliases...を追加してください:
[...]
mailman: "|/usr/lib/mailman/mail/mailman post mailman"
mailman-admin: "|/usr/lib/mailman/mail/mailman admin mailman"
mailman-bounces: "|/usr/lib/mailman/mail/mailman bounces mailman"
mailman-confirm: "|/usr/lib/mailman/mail/mailman confirm mailman"
mailman-join: "|/usr/lib/mailman/mail/mailman join mailman"
mailman-leave: "|/usr/lib/mailman/mail/mailman leave mailman"
mailman-owner: "|/usr/lib/mailman/mail/mailman owner mailman"
mailman-request: "|/usr/lib/mailman/mail/mailman request mailman"
mailman-subscribe: "|/usr/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe: "|/usr/lib/mailman/mail/mailman unsubscribe mailman"走る
newaliasesその後、Postfixを再起動します:
systemctl restart postfix.service現在、MailmanのApache設定ファイル /etc/httpd/conf.d/mailman.conf を開いてください...
nano /etc/httpd/conf.d/mailman.conf... と行を追加します ScriptAlias /cgi-bin/mailman/ /usr/lib/mailman/cgi-bin/. 行をコメントアウトします Alias /pipermail/ /var/lib/mailman/archives/public/ と行を追加します Alias /pipermail /var/lib/mailman/archives/public/:.
#
httpd configuration settings for use with mailman.
#
ScriptAlias /mailman/ /usr/lib/mailman/cgi-bin/
ScriptAlias /cgi-bin/mailman/ /usr/lib/mailman/cgi-bin/
<Directory /usr/lib/mailman/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
#Alias /pipermail/ /var/lib/mailman/archives/public/
Alias /pipermail /var/lib/mailman/archives/public/
<Directory /var/lib/mailman/archives/public>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AddDefaultCharset Off
</Directory>
Uncomment the following line, to redirect queries to /mailman to the
listinfo page (recommended).
RedirectMatch ^/mailman[/]*$ /mailman/listinfoApacheを再起動する:
systemctl restart httpd.serviceMailmanのシステムスタートアップリンクを作成し、起動します:
systemctl enable mailman.service
systemctl start mailman.serviceISPConfig 3をインストールした後、次のようにしてMailmanにアクセスできます:
すべてのApache仮想ホストに対してエイリアス/cgi-bin/mailmanを使用できます(Mailmanにアクセスしたいすべての仮想ホストでsuExecとCGIが無効になっていることに注意してください!)。つまり、リストのMailman管理インターフェースにはhttp://
http://
21 ラウンドキューブウェブメールをインストールする
RoundCubeウェブメールクライアントをインストールするには、最新バージョンをwgetを使って/tmpフォルダーにダウンロードします:
cd /tmp
wget https://github.com/roundcube/roundcubemail/releases/download/1.4.3/roundcubemail-1.4.3-complete.tar.gztar.gzアーカイブを展開し、RoundCubeのソースを/usr/share/roundcubemailに移動します。
tar xfz roundcubemail-1.4.3-complete.tar.gz
mkdir /usr/share/roundcubemail
mv /tmp/roundcubemail-1.4.3/* /usr/share/roundcubemail/
chown -R root:root /usr/share/roundcubemail
chown apache /usr/share/roundcubemail/temp
chown apache /usr/share/roundcubemail/logsnanoエディタでroundcubemail.conf設定ファイルを作成します:
nano /etc/httpd/conf.d/roundcubemail.confそのファイルに次の内容を追加してください。
#
Round Cube Webmail is a browser-based multilingual IMAP client
#
Alias /roundcubemail /usr/share/roundcubemail
Alias /webmail /usr/share/roundcubemail
Define who can access the Webmail
You can enlarge permissions once configured
<Directory /usr/share/roundcubemail/>
Options none
AllowOverride Limit
Require all granted
</Directory>
Define who can access the installer
keep this secured once configured
<Directory /usr/share/roundcubemail/installer>
Options none
AllowOverride Limit
Require all granted
</Directory>
Those directories should not be viewed by Web clients.
<Directory /usr/share/roundcubemail/bin/>
Order Allow,Deny
Deny from all
</Directory>
<Directory /usr/share/roundcubemail/plugins/enigma/home/>
Order Allow,Deny
Deny from all
</Directory>Apacheを再起動する:
systemctl restart httpd.serviceさて、RoundCubeメールのためのデータベースが必要です。次のように初期化します:
mysql -u root -pMariaDBのプロンプトで次のように入力します:
CREATE DATABASE roundcubedb;
CREATE USER roundcubeuser@localhost IDENTIFIED BY 'roundcubepassword';
GRANT ALL PRIVILEGES on roundcubedb.* to roundcubeuser@localhost ;
FLUSH PRIVILEGES;
exit私は例としてRoundCubeデータベースの詳細を使用していますので、セキュリティ上の理由から値をお好みで置き換えてください。
それでは、ブラウザで http://192.168.0.100/roundcubemail/installer に RoundCube をインストールします。
次に、config.inc.phpファイルを作成します:
nano /usr/share/roundcubemail/config/config.inc.php<?php
/* Local configuration for Roundcube Webmail */
// ----------------------------------
// SQL DATABASE
// ----------------------------------
// Database connection string (DSN) for read+write operations
// Format (compatible with PEAR MDB2): db_provider://user:password@host/database
// Currently supported db_providers: mysql, pgsql, sqlite, mssql, sqlsrv, oracle
// For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
// NOTE: for SQLite use absolute path (Linux): 'sqlite:////full/path/to/sqlite.db?mode=0646'
// or (Windows): 'sqlite:///C:/full/path/to/sqlite.db'
$config['db_dsnw'] = 'mysql://roundcubeuser:roundcubepassword@localhost/roundcubedb';
// ----------------------------------
// IMAP
// ----------------------------------
// The IMAP host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
// required to match old user data records with the new host.
$config['default_host'] = 'localhost';
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;
// provide an URL where a user can get support for this Roundcube installation
// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
$config['support_url'] = '';
// This key is used for encrypting purposes, like storing of imap password
// in the session. For historical reasons it's called DES_key, but it's used
// with any configured cipher_method (see below).
$config['des_key'] = 'pb0UucO0eqjgvhrqYlFTBVjE';
// ----------------------------------
// PLUGINS
// ----------------------------------
// List of active plugins (in plugins/ directory)
$config['plugins'] = array();
// Set the spell checking engine. Possible values:
// - 'googie' - the default (also used for connecting to Nox Spell Server, see 'spellcheck_uri' setting)
// - 'pspell' - requires the PHP Pspell module and aspell installed
// - 'enchant' - requires the PHP Enchant module
// - 'atd' - install your own After the Deadline server or check with the people at http://www.afterthedeadline.com before using their API
// Since Google shut down their public spell checking service, the default settings
// connect to http://spell.roundcube.net which is a hosted service provided by Roundcube.
// You can connect to any other googie-compliant service by setting 'spellcheck_uri' accordingly.
$config['spellcheck_engine'] = 'pspell';
$config['enable_installer'] = true;次に、ウェブインストーラーで「続ける」を押してください。次のページでは、「データベースを初期化」ボタンを押してください。
最後に、Roundecubemailインストーラーを無効にします。RoundCubeのconfig.inc.php設定ファイルを変更してください。
nano /usr/share/roundcubemail/config/config.inc.phpそしてその行を変更します:
$config['enable_installer'] = true;へ:
$config['enable_installer'] = false;Roundcubeは現在、あなたのサーバー上で/webmailおよび/roundcubemailというエイリアスで利用可能です。
http://192.168.0.100/webmail
RoundCubeのログインは、ISPConfigで後で作成するメールアカウントのメールアドレスとパスワードです。
ISPConfig 3.2のインストール 22
ISPConfigのインストーラーは、PostfixやDovecotなどのすべてのサービスを自動的に設定します。
今、ISPConfigコントロールパネル用にインストーラーがSSL vhostを作成する機能もありますので、ISPConfigにhttp://の代わりにhttps://を使用してアクセスできるようになります。これを実現するには、この質問が表示されたときにENTERを押してください:ISPConfigウェブインターフェースへの安全な(SSL)接続を望みますか(y,n) [y]:
ISPConfig 3.2 のナイトリービルドをインストールするには、次のようにします:
cd /tmp
wget -O ispconfig.tar.gz https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ispconfig.tar.gz
cd ispconfig3*/install/次のステップは実行することです:
php -q install.phpこれにより、ISPConfig 3 インストーラーが開始されます。インストーラーは、Postfix や Dovecot などのすべてのサービスを自動的に構成します。
[root@server1 install]# php install.php--------------------------------------------------------------------------------
_____ ___________ _____ __ _ ____
|_ _/ ___| ___ \ / __ \ / _(_) /__ \
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ /
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/
__/ |
|___/
-------------------------------------------------------------------------------->> Initial configurationOperating System: CentOS 8.2Following 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 EnterInstallation mode (standard,expert) [standard]: <-- Hit EnterFull qualified hostname (FQDN) of the server, eg server1.domain.tld [server1.example.com]: <-- Hit EnterMySQL server hostname [localhost]: <-- Hit EnterMySQL server port [3306]: <-- Hit EnterMySQL root username [root]: <-- Hit EnterMySQL root password []: <-- Ente the MySQL root password hereMySQL database to create [dbispconfig]: <-- Hit EnterMySQL charset [utf8]: <-- Hit EnterConfiguring 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) [XX]: <-- Enter 2 Letter country code, e.g. US
State or Province Name (full name) []: <-- Enter anme of State or Province
Locality Name (eg, city) [Default City]: <-- Name of city
Organization Name (eg, company) [Default Company Ltd]: <-- Company name
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (eg, your name or your server's hostname) []: <-- Enter server hostname here, in my case: server1.example.com
Email Address []: <-- Enter Email address
Configuring mailman
Configuring Dovecot
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring Jailkit
Configuring Pureftpd
Configuring BIND
Configuring Apache
Configuring vlogger
[INFO] service OpenVZ not detected
Configuring Bastille Firewall
[INFO] service Metronome XMPP Server not detected
Configuring Fail2ban
Configuring Apps vhost
Installing ISPConfig
ISPConfig Port [8080]: <-- Hit EnterAdmin password [fad579a6]: <-- Enter new password for ISPConfig admin userRe-enter admin password []: <-- Repeat the passwordDo you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]: <-- Hit EnterGenerating 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) [XX]: <-- Enter 2 Letter country code, e.g. US
State or Province Name (full name) []: <-- Enter anme of State or Province
Locality Name (eg, city) [Default City]: <-- Name of city
Organization Name (eg, company) [Default Company Ltd]: <-- Company name
Organizational Unit Name (eg, section) []: <-- Hit Enter
Common Name (eg, your name or your server's hostname) []: <-- Enter server hostname here, in my case: server1.example.com
Email Address []: <-- Enter Email addressPlease 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 keyConfiguring DBServer
Installing ISPConfig crontab
Installing ISPConfig crontab
no crontab for root
no crontab for getmail
Detect IP addresses
Restarting services ...
Installation completed.インストーラーはすべての基盤となるサービスを自動的に設定するため、手動での設定は必要ありません。
23 最初のISPConfigログイン
その後、ISPConfig 3には http(s)://server1.example.com:8080/ または http(s)://192.168.0.100:8080/ でアクセスできます(http または https はインストール時に選択したものによります)。
ユーザー名adminとパスワードadminでログインします(初回ログイン後にデフォルトパスワードを変更する必要があります):
23.1 ISPConfig 3 マニュアル
ISPConfig 3の使い方を学ぶために、ISPConfig 3マニュアルをダウンロードすることを強くお勧めします。
300ページ以上にわたって、ISPConfigの背後にある概念(管理者、リセラー、クライアント)をカバーし、ISPConfig 3のインストールとアップデート方法を説明し、ISPConfig内のすべてのフォームおよびフォームフィールドのリファレンスを有効な入力例と共に含み、ISPConfig 3の最も一般的なタスクに関するチュートリアルを提供します。また、サーバーをより安全にする方法を示し、最後にトラブルシューティングセクションを設けています。
24 仮想マシンとしてダウンロード
このセットアップは、howtoforgeのサブスクライバー向けに、OVM/OVF形式の仮想マシンダウンロードとして利用可能です(VMWareとVirtualboxと互換性があります)。
VMのログイン詳細
- ルートパスワードは: howtoforge
- ISPConfigの「admin」ユーザーのパスワードは:howtoforge
- "howtoforge"という名前の別のシェルユーザーがいて、パスワードは: howtoforgeです。
最初のログイン時に両方のパスワードを変更してください。
- VMのIPアドレスは192.168.0.100です。
25リンク
- CentOS: http://www.centos.org/
- ISPConfig: http://www.ispconfig.org/






