De Perfecte Server – Debian 10 (Buster) met Apache, BIND, Dovecot, PureFTPD en ISPConfig 3.2.
Deze handleiding laat zien hoe je een Debian 10 server (met Apache2, BIND, Dovecot) voorbereidt voor de installatie van ISPConfig 3.2, en hoe je ISPConfig installeert. Met het webhosting controlepaneel ISPConfig 3 kun je via een webbrowser de volgende diensten instellen: Apache of nginx webserver, Postfix mailserver, Courier of Dovecot IMAP/POP3 server, MySQL, BIND of MyDNS nameserver, PureFTPd, SpamAssassin, ClamAV, en nog veel meer. Deze opzet behandelt Apache (in plaats van nginx), BIND, en Dovecot.
1 Opmerking vooraf
In deze handleiding gebruik ik de hostnaam server1.example.com met het IP adres 192.168.0.100 en de gateway 192.168.0.1. Deze instellingen kunnen voor jou anders zijn, dus moet je ze waar nodig vervangen. Voordat je verder gaat moet je een minimale installatie van Debian 10 hebben. Dit kan een Debian minimal image van je Hosting provider zijn of je gebruikt de Minimal Debian Server tutorial om het basissysteem op te zetten.
Alle onderstaande commando’s worden als root gebruiker uitgevoerd. Ofwel log je direct in als root gebruiker, ofwel log je in als je gewone gebruiker en gebruik dan het commando
su -
om root gebruiker op je server te worden voordat je verder gaat. BELANGRIJK: Je moet ‘su -‘ gebruiken en niet gewoon ‘su’, anders wordt je PATH variabele door Debian verkeerd ingesteld.
2 Installeer de SSH server (Optioneel)
Als je tijdens de systeeminstallatie de OpenSSH server niet installeerde, kun je dat nu doen:
apt-get install ssh openssh-server
Van nu af aan kun je een SSH client zoals PuTTY gebruiken en vanaf je werkstation verbinding maken met je Debian 9 server en de overige stappen van deze handleiding volgen.
3 Installeer een shell teksteditor (Optioneel)
We zullen een nano teksteditor gebruiken in deze handleiding. Sommige gebruikers geven de voorkeur aan de klassieke vi editor, daarom installeren we hier beide editors. Het standaard vi programma vertoont wat vreemd gedrag op Debian en Ubuntu; om dit te verhelpen installeren we vim-nox:
apt-get install nano vim-nox
Als vi je favoriete editor is, vervang dan nano door vi in de volgende commando’s om bestanden te bewerken.
4 Configureer de hostnaam
De hostname van je server moet een subdomein zijn zoals “server1.example.com”. Gebruik geen domeinnaam zonder subdomeindeel zoals “example.com” als hostname, want dat zal later problemen geven met je mail setup. Controleer eerst de hostname in/etc/hosts en verander hem indien nodig. De regel zou moeten zijn: “IP adres – spatie – volledige hostname incl. domein – spatie – subdomein deel”. Voor onze hostname server1.example.com moet het bestand er zo uitzien:
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
Bewerk dan het bestand /etc/hostname:
nano /etc/hostname
Het moet alleen het subdomein gedeelte bevatten, in ons geval:
server1
Herstart tenslotte de server om de verandering toe te passen:
systemctl reboot
Log opnieuw in en controleer of de hostname nu juist is met deze commando’s:
hostname
hostname -f
De uitvoer moet er zo uitzien:
[email protected]:/tmp# hostname
server1
[email protected]:/tmp# hostname -f
server1.example.com
5 Werk je Debian installatie bij
Zorg er eerst voor dat je /etc/apt/sources.list de buster/updates repository bevat (dit zorgt ervoor dat je altijd de nieuwste beveiligingsupdates krijgt), en dat de contrib en non-free repositories ingeschakeld zijn omdat sommige vereiste pakketten niet in de hoofdrepository zitten.
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
Voer uit:
apt-get update
Om de apt pakketdatabase bij te werken
apt-get upgrade
en om de nieuwste updates te installeren (als die er zijn).
6. Verander de standaard shell
/bin/sh is een symlink naar /bin/dash, maar we hebben /bin/bash nodig, niet /bin/dash. Daarom doen we het volgende:
dpkg-reconfigure dash
Gebruik je dash als de standaard systeemshell (/bin/sh)? <- Nee
Als je dit niet doet, mislukt de installatie van ISPConfig.
7 Synchroniseer de systeemklok
Het is een goed idee om de systeemklok te synchroniseren met een NTP(network time protocol) server via het Internet. Voer eenvoudig
apt-get -y install ntp
en je systeemtijd zal altijd synchroon lopen.
8 Installeer Postfix, Dovecot, MariaDB, rkhunter, en Binutils
We kunnen Postfix, Dovecot, MariaDB als MySQL alternatief, rkhunter, en Binutils installeren met een enkel commando:
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 curl
Je krijgt de volgende vragen:
Algemeen type mail configuratie: <– Internet Site
Systeem mail naam: <– server1.example.com
Om de MariaDB installatie te beveiligen en de testdatabase uit te schakelen, voer je dit commando uit:
mysql_secure_installation
Beantwoord de vragen als volgt:
Change the root password? [Y/n] <-- y
New password: <-- Enter a new MariaDB root password
Re-enter new password: <-- Repeat the MariaDB 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
Open vervolgens de TLS/SSL en inzendpoorten in Postfix:
nano /etc/postfix/master.cf
Haal het volgende commentaar uit de gedeelten submission en smtps en voeg regels toe waar nodig, zodat dit gedeelte van het master.cf bestand er precies zo uitziet als hieronder. BELANGRIJK: Verwijder de # vóór de regels die met smtps en submission beginnen ook en niet alleen uit de -o regels na deze regels!
[...] 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 [...]
Herstart daarna Postfix:
systemctl restart postfix
We willen dat MySQL op alle interfaces luistert, niet alleen op localhost. Daarom bewerken we /etc/mysql/mariadb.conf.d/50-server.cnf en becommentariëren de regel bind-address = 127.0.0.1 door er een # voor te zetten.
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
[...]
Zet de wachtwoord authenticatie methode in MariaDB op native zodat we later PHPMyAdmin kunnen gebruiken om als root gebruiker te verbinden:
echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root
Bewerk het bestand /etc/mysql/debian.cnf en stel daar tweemaal het MYSQL / MariaDB root wachtwoord in, in de rijen die beginnen met het woord password.
nano /etc/mysql/debian.cnf
Het MySQL root wachtwoord dat toegevoegd moet worden staat in rood. In dit voorbeeld is het wachtwoord “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
Om de foutmelding ‘Fout in accepteren: Te veel geopende bestanden‘ te voorkomen, stellen we nu hogere open bestandslimieten in voor MariaDB.
Open het bestand /etc/security/limits.conf met een editor:
nano /etc/security/limits.conf
en voeg deze regels aan het eind van het bestand toe.
mysql soft nofile 65535
mysql hard nofile 65535
Maak vervolgens een nieuwe directory /etc/systemd/mysql.service.d/ met het commando mkdir.
mkdir -p /etc/systemd/system/mysql.service.d/
en voeg daarin een nieuw bestand toe:
nano /etc/systemd/system/mysql.service.d/limits.conf
plak de volgende regels in dat bestand:
[Service]
LimitNOFILE=infinity
Sla het bestand op en sluit de nano editor.
Dan herladen we systemd en herstarten we MariaDB:
systemctl daemon-reload
systemctl restart mariadb
Controleer nu of netwerken ingeschakeld is. Voer uit.
netstat -tap | grep mysql
De uitvoer zou er als volgt uit moeten zien:
[email protected]:/home/administrator# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 16623/mysqld
9 Installeer amavisd-new, SpamAssassin, en ClamAV
Om amavisd-new, SpamAssassin en ClamAV te installeren, voeren we uit
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
De ISPConfig 3 setup gebruikt amavisd die de SpamAssassin filterbibliotheek intern laadt, dus kunnen we SpamAssassin stoppen om wat RAM vrij te maken:
systemctl stop spamassassin
systemctl disable spamassassin
10 Installeer Apache Web Server en PHP
Apache2, PHP, FCGI, suExec, Peer, en mcrypt kunnen als volgt geïnstalleerd worden:
apt-get -y install apache2 apache2-doc apache2-utils libapache2-mod-php php7.3 php7.3-common php7.3-gd php7.3-mysql php7.3-imap php7.3-cli php7.3-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python 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 libapache2-mod-passenger php7.3-soap php7.3-fpm php7.3-opcache php-apcu libapache2-reload-perl
Voer dan het volgende commando uit om de Apache modules suexec, rewrite, ssl, actions, en include in te schakelen (plus dav, dav_fs, en auth_digest als je WebDAV wilt gebruiken):
a2enmod suexec rewrite ssl actions include dav_fs dav auth_digest cgi headers actions proxy_fcgi alias
Om te zorgen dat de server niet via de HTTPOXY kwetsbaarheid kan worden aangevallen, schakelen we de HTTP_PROXY header in apache globaal uit door het configuratiebestand /etc/apache2/conf-available/httpoxy.conf toe te voegen.
Opmerking: De kwetsbaarheid heet httpoxy (zonder ‘r’) en daarom heet het bestand waar we de config toevoegen om het te voorkomen httpoxy.conf en niet httproxy.conf, dus er ontbreekt geen ‘r’ in de bestandsnaam.
nano /etc/apache2/conf-available/httpoxy.conf
Plak de volgende inhoud in het bestand:
<IfModule mod_headers.c> RequestHeader unset Proxy early </IfModule>
En schakel de module in door te draaien:
a2enconf httpoxy
systemctl restart apache2
11 Installeer Let’s Encrypt
ISPConfig gebruikt nu acme.sh als Let’s Encrypt cliënt. Installeer acme.sh met het volgende commando:
curl https://get.acme.sh | sh -s
12 Installeer Mailman
Met ISPConfig kun je Mailman mailinglijsten beheren (aanmaken/wijzigen/verwijderen). Als je van deze functie gebruik wilt maken, installeer dan Mailman als volgt:
apt-get install mailman
Kies ten minste één taal, bv:
Languages to support: <-- en (English)
Missing site list <-- Ok
Voordat we Mailman kunnen starten, moet een eerste mailinglijst met de naam mailman aangemaakt worden:
newlist mailman
[email protected]:~# newlist mailman
Enter the email of the person running the list: <-- admin email address, e.g. [email protected]
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
[email protected]:~#
Open daarna /etc/aliassen…
nano /etc/aliases
… en voeg de volgende regels toe:
[...] ## 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"
Voer uit:
newaliases
en herstart Postfix:
systemctl restart postfix
Tenslotte moeten we de Mailman Apache configuratie inschakelen:
ln -s /etc/mailman/apache.conf /etc/apache2/conf-enabled/mailman.conf
Dit bepaalt de alias /cgi-bin/mailman/ voor alle Apache vhosts, wat betekent dat je de Mailman admin interface voor een mailinglijst kunt bereiken op http://server1.example.com/cgi-bin/mailman/admin/, en de webpagina voor gebruikers van een mailinglijst kun je vinden op http://server1.example.com/cgi-bin/mailman/listinfo/.
Onder http://server1.example.com/pipermail vind je de archieven van de mailinglijst.
Herstart daarna Apache:
systemctl restart apache2
Start dan de Mailman daemon:
systemctl restart mailman
13 Installeer PureFTPd en Quota
PureFTPd en quota kunnen geïnstalleerd worden met het volgende commando:
apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool
Maak het dhparam bestand voor pure-ftpd:
openssl dhparam -out /etc/ssl/private/pure-ftpd-dhparams.pem 2048
Bewerk het bestand /etc/default/pure-ftpd-common…
nano /etc/default/pure-ftpd-common
… en zorg ervoor dat de startmodus op standalone staat en stel VIRTUALCHROOT=true in:
[...] STANDALONE_OR_INETD=standalone [...] VIRTUALCHROOT=true [...]
Nu stellen we PureFTPd in om FTP en TLS sessies toe te staan. FTP is een erg onveilig protocol omdat alle wachtwoorden en alle gegevens in klare tekst worden overgebracht. Door TLS te gebruiken kan de hele communicatie versleuteld worden, waardoor FTP veel veiliger wordt.
Als je FTP en TLS sessies wilt toestaan, voer dan
echo 1 > /etc/pure-ftpd/conf/TLS
Om TLS te gebruiken, moeten we een SSL certificaat maken. Ik maak het aan in /etc/ssl/private/, daarom maak ik eerst die directory aan:
mkdir -p /etc/ssl/private/
Daarna kunnen we het SSL certificaat als volgt genereren:
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.
Verander de rechten van het SSL certificaat:
chmod 600 /etc/ssl/private/pure-ftpd.pem
Herstart dan PureFTPd:
systemctl restart pure-ftpd-mysql
Bewerk /etc/fstab. De mijne ziet er zo uit (ik voegde ,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 toe aan de partitie met het koppelpunt /):
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
Om quota in te schakelen, voer je deze commando’s uit:
mount -o remount /
quotacheck -avugm
quotaon -avug
14 Installeer BIND DNS Server
BIND kan als volgt geïnstalleerd worden:
apt-get install bind9 dnsutils
Is je server een virtuele machine, dan is het zeer aan te bevelen de haveged daemon te installeren om een hogere entropie te krijgen voor DNSSEC ondertekening. Je kunt haveged ook op niet-virtuele servers installeren, het zou geen kwaad moeten kunnen.
apt-get install haveged
Een uitleg over dat onderwerp kun je hier vinden.
15 Installeer Webalizer, AWStats en GoAccess
Webalizer en AWStats kunnen als volgt geïnstalleerd worden:
apt-get install webalizer awstats geoip-database libclass-dbi-mysql-perl libtimedate-perl
Open daarna /etc/cron.d/awstats…
nano /etc/cron.d/awstats
… en commentarieer alles in dat bestand:
#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
Installeer de nieuwste GoAccess versie rechtstreeks uit de GoAccess repository:
echo "deb https://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add -
apt-get update
apt-get install goaccess
16 Installeer Jailkit
Jailkit is alleen nodig als je SSH gebruikers wilt chrooten. Het kan als volgt geïnstalleerd worden:
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
Je kunt nu het Jailkit .deb pakket als volgt installeren:
cd ..
dpkg -i jailkit_2.20-1_*.deb
rm -rf jailkit-2.20*
17 Installeer fail2ban en UFW Firewall
Dit is optioneel maar aanbevolen, omdat de ISPConfig monitor probeert de log te tonen:
apt-get install fail2ban
Om fail2ban PureFTPd en Dovecot te laten monitoren, maak je het bestand /etc/fail2ban/jail.local aan:
nano /etc/fail2ban/jail.local
En voeg er de volgende configuratie aan toe.
[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
Herstart fail2ban daarna:
systemctl restart fail2ban
Om de UFW firewall te installeren, voer je dit apt commando uit:
apt-get install ufw
18 Installeer PHPMyAdmin Database Beheer Hulpmiddel
Sinds Debian 10 is PHPMyAdmin niet meer als .deb pakket beschikbaar. Daarom zullen we het vanaf broncode installeren.
Maak mappen voor 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
Ga naar de /tmp directory en download de PHPMyAdmin broncode:
cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz
Pak het gedownloade archiefbestand uit en verplaats de bestanden naar de /usr/share/phpmyadmin map en ruim de /tmp map op.
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
Maak een nieuw config-bestand voor PHPMyaAdmin op basis van het bijgeleverde voorbeeldbestand:
cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
Open het config bestand met nano editor:
nano /usr/share/phpmyadmin/config.inc.php
Stel een veilig wachtwoord in (blowfish secret) dat 32 tekens lang moet zijn:
$cfg['blowfish_secret'] = 'bD3e6wva9fnd93jVsb7SDgeiBCd452Dh'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Gebruik niet mijn voorbeeld blowfish secret, maar stel er zelf een in!
Voeg dan een regel toe om de directory in te stellen die PHPMyAdmin moet gebruiken om tijdelijke bestanden op te slaan:
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
Vervolgens maken we het Apache configuratiebestand voor PHPMyAdmin door een nieuw bestand te openen in nano editor:
nano /etc/apache2/conf-available/phpmyadmin.conf
Plak de volgende config in het bestand en sla het op.
# phpMyAdmin default Apache configuration
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php7.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
</Directory>
# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>
Activeer de configuratie en herstart Apache.
a2enconf phpmyadmin
systemctl restart apache2
In de volgende stap configureren we de phpMyadmin configuratieopslag (database).
Log in MariaDB in als root gebruiker:
mysql -u root -p
Maak in de MariaDB shell een nieuwe databank aan voor PHPMyAdmin:
MariaDB [(none)]> CREATE DATABASE phpmyadmin;
Maak dan een nieuwe gebruiker aan:
MariaDB [(none)]> CREATE USER 'pma'@'localhost' IDENTIFIED BY 'mypassword';
Vervang het woord mypassword door een veilig wachtwoord naar keuze in de commando’s hierboven en hieronder, gebruik beide keren hetzelfde wachtwoord. Verleen de gebruiker dan toegang tot deze database en laad de databasemachtigingen opnieuw.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Laad tenslotte de SQL tabellen in de database:
mysql -u root -p phpmyadmin < /usr/share/phpmyadmin/sql/create_tables.sql
Geef op verzoek het MariaDB root wachtwoord op.
We hoeven nu alleen nog maar de phpmyadmin gebruikersgegevens in het configuratiebestand in te stellen. Open het bestand weer in nano editor:
nano /usr/share/phpmyadmin/config.inc.php
Scroll naar beneden tot je de regels hieronder ziet en bewerk ze:
/* 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';
Ik heb de regels die ik bewerkt heb rood gemarkeerd. Vervang mypassword door het wachtwoord dat je voor de phpmyadmin gebruiker gekozen hebt. Merk op dat de // voor de regels ook verwijderd zijn!
19 Installeer RoundCube Webmail (optioneel)
In dit hoofdstuk installeren we het RoundCube webmail programma. Eerst moeten we de database voor Roundcube handmatig aanmaken, want er is momenteel een probleem in het RoundCube Debian installatieprogramma waardoor het er niet in slaagt de database automatisch aan te maken. Voer dit commando uit om de database aan te maken:
echo "CREATE DATABASE roundcube;" | mysql --defaults-file=/etc/mysql/debian.cnf
Installeer dan RoundCube met dit commando:
apt-get install roundcube roundcube-core roundcube-mysql roundcube-plugins
Het installatieprogramma zal de volgende vragen stellen:
Configure database for roundcube with dbconfig.common? <-- yes
MySQL application password for roundcube: <-- press enter
Bewerk dan het RoundCube /etc/roundcube/config.inc.php bestand en pas een paar instellingen aan:
nano /etc/roundcube/config.inc.php
Stel de default_host in op localhost en de smtp_server.
$config['default_host'] = 'localhost';
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;
Bewerk dan het Apache RoundCube configuratiebestand /etc/apache2/conf-enabled/roundcube.conf:
nano /etc/apache2/conf-enabled/roundcube.conf
En voeg een aliasregel toe voor de apache /webmail alias en een voor /roundcube, je kunt de regel helemaal aan het begin van het bestand toevoegen. OPMERKING: Gebruik niet /mail als alias anders werkt de ispconfig email module niet meer!
Alias /roundcube /var/lib/roundcube
Alias /webmail /var/lib/roundcube
Herlaad dan Apache:
systemctl reload apache2
Nu kun je RoundCube als volgt benaderen:
http://192.168.0.100/webmail
http://www.example.com/webmail
http://server1.example.com:8080/webmail (nadat je ISPConfig geïnstalleerd hebt, zie het volgende hoofdstuk)
Er bestaan enkele plugins om RoundCube Webmail met ISPConfig te integreren, kijk hier voor de ISPConfig RoundCube plugin installatie instructies.
20 Download ISPConfig 3
20 Download de stabiele versie van ISPConfig (aanbevolen)
Om ISPConfig 3 te installeren van de laatst uitgebrachte versie, doe je dit:
cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install/
21 Installeer ISPConfig
De volgende stap is het uitvoeren van de ISPConfig installer.
php -q install.php
Dit start de ISPConfig 3 installer. Het installatieprogramma zal alle diensten zoals Postfix, Dovecot, enz. voor je configureren. Een handmatige setup zoals nodig voor ISPConfig 2 (perfecte setup gidsen) is niet nodig.
# 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.example.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
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 Apache
Configuring vlogger
[INFO] service Metronome XMPP Server not detected
Configuring Ubuntu Firewall
Configuring Fail2ban
[INFO] service OpenVZ not detected
Configuring Apps vhost
Installing ISPConfig
ISPConfig Port [8080]:
Admin password [admin]:
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.
Het installatieprogramma configureert automatisch alle onderliggende diensten, dus er is geen handmatige configuratie nodig.
Daarna kun je ISPConfig 3 benaderen onder http(s)://server1.example.com:8080/ of http(s)://192.168.0.100:8080/ ( http of https hangt af van wat je tijdens de installatie koos). Log in met de gebruikersnaam admin en het wachtwoord admin (je moet het standaard wachtwoord veranderen na de eerste keer inloggen):
Het systeem is nu klaar om gebruikt te worden.
21.1 Handleiding ISPConfig 3
Om te leren hoe je ISPConfig 3 gebruikt, raad ik je sterk aan hetISPConfig 3 Handboek te downloaden.
Op meer dan 300 bladzijden behandelt het het concept achter ISPConfig (admin, resellers, clients), legt uit hoe je ISPConfig 3 installeert en bijwerkt, bevat een referentie voor alle formulieren en formuliervelden in ISPConfig, samen met voorbeelden van geldige invoer, en geeft handleidingen voor de meest voorkomende taken in ISPConfig 3. Het geeft ook aan hoe je je server veiliger kunt maken en bevat aan het eind een hoofdstuk over het oplossen van problemen.
22 Virtuele Machine afbeelding downloaden van deze handleiding
Deze handleiding is beschikbaar als gebruiksklaar virtueel machine image in ovf/ova formaat dat compatibel is met VMWare en Virtualbox. Het virtuele machine image gebruikt de volgende inloggegevens:
SSH / Shell Inloggen
Gebruikersnaam: administrator
Wachtwoord: howtoforge
Gebruikersnaam: root
Wachtwoord: howtoforge
ISPConfig Inloggen
Gebruikersnaam: admin
Wachtwoord: admin
MySQL Inloggen
Gebruikersnaam: root
Wachtwoord: howtoforge
Het IP van de VM is 192.168.0.100, het kan veranderd worden in het bestand /etc/network/interfaces. Verander a.u.b. alle bovenstaande wachtwoorden om de virtuele machine te beveiligen.
23 Links
- Debian: http://www.debian.org/
- ISPConfig: http://www.ispconfig.org/