Instalacao ISPConfig
Instalacao ISPConfig
Instalacao ISPConfig
com
This tutorial shows how to prepare a Debian 10 server (with Apache2, BIND, Dovecot) for the
installation of ISPConfig 3.1, and how to install ISPConfig. The web hosting control panel
ISPConfig 3 allows you to configure the following services through a web browser: Apache or
nginx web server, Postfix mail server, Courier or Dovecot IMAP/POP3 server, MySQL, BIND or
MyDNS nameserver, PureFTPd, SpamAssassin, ClamAV, and many more. This setup covers
Apache (instead of nginx), BIND, and Dovecot.
1 Preliminary Note
In this tutorial, I will use the hostname server1.example.com with the IP address 192.168.0.100 and
the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where
appropriate. Before proceeding further you need to have a minimal installation of Debian 10. This
might be a Debian minimal image from your Hosting provider or you use the Minimal Debian
Server tutorial to set up the base system.
All commands below are run as root user. Either log in as root user directly or log in as your normal
user and then use the command
su -
to become root user on your server before you proceed. IMPORTANT: You must use 'su -' and not
just 'su', otherwise your PATH variable is set wrong by Debian.
If vi is your favorite editor, then replace nano with vi in the following commands to edit files.
Log in again and check if the hostname is correct now with these commands:
hostname
hostname -f
Run:
apt-get update
Uncomment the submission and smtps sections as follows and add lines where necessary so that
this section of the master.cf file looks exactly like the one below. IMPORTANT: Remove the # in
front of the lines that start with smtps and submission too and not just from the -o lines after these
lines!
[...]
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
[...]
We want MySQL to listen on all interfaces, not just localhost. Therefore, we edit
/etc/mysql/mariadb.conf.d/50-server.cnf and comment out the line bind-address = 127.0.0.1 by
adding a # in front of it.
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
[...]
Set the password authentication method in MariaDB to native so we can use PHPMyAdmin later to
connect as root user:
echo "update mysql.user set plugin = 'mysql_native_password' where user='root';"
| mysql -u root
Edit the file /etc/mysql/debian.cnf and set the MYSQL / MariaDB root password there twice in the
rows that start with the word password.
nano /etc/mysql/debian.cnf
The MySQL root password that needs to be added is shown in red. In this example, the password is
"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
To prevent the error 'Error in accept: Too many open files' we will set higher open file limits for
MariaDB now.
Open the file /etc/security/limits.conf with an editor:
nano /etc/security/limits.conf
The ISPConfig 3 setup uses amavisd which loads the SpamAssassin filter library internally, so we
can stop SpamAssassin to free up some RAM:
systemctl stop spamassassin
systemctl disable spamassassin
Then run the following command to enable the Apache modules suexec, rewrite, ssl, actions, and
include (plus dav, dav_fs, and auth_digest if you want to use WebDAV):
a2enmod suexec rewrite ssl actions include dav_fs dav auth_digest cgi
headers actions proxy_fcgi alias
To ensure that the server cannot be attacked through the HTTPOXY vulnerability, we will disable
the HTTP_PROXY header in apache globally by adding the configuration file /etc/apache2/conf-
available/httpoxy.conf.
Note: The vulnerability is named httpoxy (without 'r') and therefore the file where we add the config
to prevent it is named httpoxy.conf and not httproxy.conf, so there is no 'r' missing in the filename.
nano /etc/apache2/conf-available/httpoxy.conf
Paste the following content to the file:
<IfModule mod_headers.c>
RequestHeader unset Proxy early
</IfModule>
There are no further steps required than installing LE. The website SSL certificates are created by
ISPConfig when you add the web sites.
12 Install Mailman
ISPConfig allows you to manage (create/modify/delete) Mailman mailing lists. If you want to make
use of this feature, install Mailman as follows:
apt-get install mailman
Before we can start Mailman, a first mailing list called mailman must be created:
newlist mailman
Run:
newaliases
This defines the alias /cgi-bin/mailman/ for all Apache vhosts, which means you can access the
Mailman admin interface for a list at http://server1.example.com/cgi-bin/mailman/admin/, and the
web page for users of a mailing list can be found at http://server1.example.com/cgi-
bin/mailman/listinfo/.
Under http://server1.example.com/pipermail you can find the mailing list archives.
Restart Apache afterwards:
systemctl restart apache2
... and make sure that the start mode is set to standalone and set VIRTUALCHROOT=true:
[...]
STANDALONE_OR_INETD=standalone
[...]
VIRTUALCHROOT=true
[...]
Now we configure PureFTPd to allow FTP and TLS sessions. FTP is a very insecure protocol
because all passwords and all data are transferred in clear text. By using TLS, the whole
communication can be encrypted, thus making FTP much more secure.
If you want to allow FTP and TLS sessions, run
echo 1 > /etc/pure-ftpd/conf/TLS
In order to use TLS, we must create an SSL certificate. I create it in /etc/ssl/private/, therefore I
create that directory first:
mkdir -p /etc/ssl/private/
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.
quotacheck -avugm
quotaon -avug
If your server is a virtual machine, then it is highly recommended to install the haveged daemon to
get a higher entropy for DNSSEC signing. You can install haveged on nonvirtual servers as well, it
should not hurt.
apt-get install haveged
16 Install Jailkit
Jailkit is needed only if you want to chroot SSH users. It can be installed as follows:
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
To make fail2ban monitor PureFTPd and Dovecot, create the file /etc/fail2ban/jail.local:
nano /etc/fail2ban/jail.local
Since Debian 10, PHPMyAdmin is not available as .deb package anymore. Therefore we will install
it from source.
Create folders for 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
Unpack the downloaded archive file and move the files to the /usr/share/phpmyadmin folder and
clean up the /tmp directory.
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
Create a new config file for PHPMyaAdmin based on the provided sample file:
cp /usr/share/phpmyadmin/config.sample.inc.php
/usr/share/phpmyadmin/config.inc.php
Next, we create the Apache configuration file for PHPMyAdmin by opening a new file in nano
editor:
nano /etc/apache2/conf-available/phpmyadmin.conf
Paste the following config into the file and save it.
# 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>
In the next step, we will configure the phpMyadmin configuration store (database).
Log into MariaDB as root user:
mysql -u root -p
Replace the word mypassword with a secure password of your choice in the commands above and
below, use the same password both times. Then grant the user access to this database and reload
database permissions.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost'
IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Scroll down until you see the lines below and edit them:
/* 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';
I've marked the lines in red which I've edited. Replace mypassword with the password that you've
chosen for the phpmyadmin user. Note that the // in front of the lines have been removed as well!
Then edit the RoundCube /etc/roundcube/config.inc.php file and adjust a few settings:
nano /etc/roundcube/config.inc.php
20 Download ISPConfig 3
20.1 Download the stable release (recommended)
To install ISPConfig 3 from the latest released version, do this:
cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install/
20.2 Download a pre-release version of the next 3.1 release
If you like to try out the pre-release of an upcoming 3.1 stable version, download it with this
command. This stable branch versions are the last stable release plus the changes for the next stable
version:
cd /tmp
wget -O ISPConfig-3.1-
dev.tar.gz https://git.ispconfig.org/ispconfig/ispconfig3/repository/archive.ta
r.gz?ref=stable-3.1
tar xfz ISPConfig-3.1-dev.tar.gz
cd ispconfig3-stable-3.1*
cd install
21 Install ISPConfig
The next step is to run the ISPConfig installer.
php -q install.php
This will start the ISPConfig 3 installer. The installer will configure all services like Postfix,
Dovecot, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not
necessary.
# php -q install.php
--------------------------------------------------------------------------------
_____ ___________ _____ __ _ ____
|_ _/ ___| ___ \ / __ \ / _(_) /__ \
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ /
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/
__/ |
|___/
--------------------------------------------------------------------------------
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]:
Do you want a secure (SSL) connection to the ISPConfig web interface (y,n)
[y]: <-- Hit Enter
Configuring DBServer
Installing ISPConfig crontab
no crontab for root
no crontab for getmail
Detect IP addresses
Restarting services ...
Installation completed.
23 Links
• Debian: http://www.debian.org/
• ISPConfig: http://www.ispconfig.org/
×
This feature is only available to subscribers. Get your subscription here.