New: installation/install.iredmail.with.remote.mysql.server.md.

This commit is contained in:
Zhang Huangbin 2015-02-05 15:27:55 +08:00
parent afe09f3c82
commit 1c0286ba1e
4 changed files with 272 additions and 0 deletions

View File

@ -6,6 +6,7 @@
* How to enable DNSBL in Postfix.
* How to install and configure mlmmj (mailing list management tool)
* http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/MySQL/install.iredmail.with.remote.mysql.server
* http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Backup
* http://www.iredmail.org/wiki/index.php?title=IRedMail/FAQ/Send.out.email.from.specified.IP.address
* http://www.iredmail.org/forum/topic1968-enabling-ipv6-for-your-iredmail-postfixdovecot.html

View File

@ -16,6 +16,7 @@
<li><a href="install.iredmail.on.freebsd.html">Install iRedMail on FreeBSD</a></li>
<li><a href="install.iredmail.on.freebsd.with.jail.html">Install iRedMail on FreeBSD inside Jail (with ezjail)</a></li>
<li><a href="install.iredmail.on.openbsd.html">Install iRedMail on OpenBSD</a></li>
<li><a href="install.iredmail.with.remote.mysql.server.html">Install iRedMail with a remote MySQL server</a></li>
<li><a href="setup.dns.html">Setup DNS records for your iRedMail server</a></li>
<li><a href="unattended.iredmail.installation.html">Perform silent/unattended iRedMail installation</a></li>
</ul>

View File

@ -0,0 +1,143 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Install iRedMail with a remote MySQL server</title>
<link href="./css/markdown.css" rel="stylesheet"></head>
</head>
<body>
<div id="navigation">
<a href="http://www.iredmail.org" target="_blank">iRedMail web site</a>
// <a href="./index.html">Document Index</a>
</div><h1 id="install-iredmail-with-a-remote-mysql-server">Install iRedMail with a remote MySQL server</h1>
<div class="toc">
<ul>
<li><a href="#install-iredmail-with-a-remote-mysql-server">Install iRedMail with a remote MySQL server</a><ul>
<li><a href="#summary">Summary</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#install-iredmail">Install iRedMail</a></li>
<li><a href="#after-iredmail-installation">After iRedMail installation</a></li>
</ul>
</li>
</ul>
</div>
<h2 id="summary">Summary</h2>
<p>This article describes how to install iRedMail (iRedMail-0.8.6 or later
releases) with a remote MySQL server, and you must choose MySQL backend in
iRedMail installation wizard.</p>
<p>We use below server IP addresses in our example:</p>
<ul>
<li><code>192.168.1.100</code>: Remote MySQL server.</li>
<li><code>192.168.1.200</code>: iRedMail server. We're going to install the latest iRedMail
on this server.</li>
</ul>
<p>iRedMail won't install MySQL server (RPM/DEB package) on localhost with remote
MySQL server, but MySQL client tools are still required for remote connection.</p>
<h2 id="requirements">Requirements</h2>
<p>In our case, remote MySQL server runs on server <code>192.168.1.100</code>. It must accept
remote connection from iRedMail server <strong>BEFORE</strong> installing iRedMail, and we
must create a new SQL user with password and proper privileges for remote login
from iRedMail server (<code>192.168.1.200</code> in our case).</p>
<ul>
<li>Make sure your remote MySQL server accepts remote connection from iRedMail
server. For example, you can check it with command <code>netstat</code>:</li>
</ul>
<pre><code># netstat -ntlp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2479/mysqld
</code></pre>
<p>If MySQL server is listening on only 127.0.0.1, you should comment out
<code>bind-address</code> parameter in MySQL config file <code>my.cnf</code> to make it listen on all
available network interfaces, and restart MySQL service.</p>
<ul>
<li>On Red Hat Enterprise Linux, CentOS, openSUSE, OpenBSD, it's <code>/etc/my.cnf</code>.</li>
<li>On Debian, Ubuntu, it's <code>/etc/mysql/my.cnf</code>.</li>
<li>On FreeBSD, it's <code>/var/db/mysql/my.cnf</code>.</li>
</ul>
<pre><code>#bind-address = 127.0.0.1
</code></pre>
<ul>
<li>
<p>Make sure remote MySQL request will not be blocked by network firewall like
iptables (Linux), ipfw (FreeBSD) or PF (OpenBSD).</p>
</li>
<li>
<p>Create a new SQL user (<code>admin_iredmail</code>) with new password (<code>admin_password</code>)
and all privileges on remote MySQL server (of course you must choose another
strong password):</p>
</li>
</ul>
<pre><code>mysql&gt; GRANT ALL PRIVILEGES ON *.* TO 'admin_iredmail'@'192.168.1.200' IDENTIFIED BY 'admin_password' WITH GRANT OPTION;
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; FLUSH HOSTS;
</code></pre>
<p>With above commands, MySQL user <code>admin_iredmail</code> is allowed to connect from IP
address <code>192.168.1.200</code> with password <code>admin_password</code>.</p>
<p><strong>Notes</strong>:</p>
<ul>
<li><code>WITH GRANT OPTION</code> in above SQL command is required.</li>
<li>Of course you can use <code>root</code> or other MySQL user as remote MySQL user name
in above SQL command, but a custom user name should be better to help you
understand what it's used for, and less confuse with default <code>root</code> user.</li>
<li>You must replace <code>192.168.1.200</code> by the real IP address of your iRedMail
server in above command.</li>
<li>It's recommended to delete this user AFTER iRedMail installation, it won't
be used anymore. We will give you SQL command to delete it later.</li>
</ul>
<p>If you tried to install iRedMail with this remote MySQL server before, please
drop existing databases and MySQL users which will be created by iRedMail on
remote MySQL server:</p>
<pre><code>mysql&gt; DROP DATABASE amavisd;
mysql&gt; DROP DATABASE cluebringer;
mysql&gt; DROP DATABASE iredadmin;
mysql&gt; DROP DATABASE roundcubemail;
mysql&gt; DROP DATABASE vmail;
mysql&gt; DROP USER 'amavisd'@'192.168.1.200';
mysql&gt; DROP USER 'cluebringer'@'192.168.1.200';
mysql&gt; DROP USER 'iredadmin'@'192.168.1.200';
mysql&gt; DROP USER 'roundcube'@'192.168.1.200';
mysql&gt; DROP USER 'vmail'@'192.168.1.200';
mysql&gt; DROP USER 'vmailadmin'@'192.168.1.200';
</code></pre>
<h2 id="install-iredmail">Install iRedMail</h2>
<p>Please follow iRedMail installation guide strictly, but start iRedMail
installer with below command instead of the original one (<code>bash iRedMail.sh</code>):</p>
<pre><code># MYSQL_SERVER='192.168.1.100' MYSQL_ROOT_USER='admin_iredmail' MYSQL_GRANT_HOST='192.168.1.200' bash iRedMail.sh
</code></pre>
<p>It will launch iRedMail installation wizard as usual. When it asks MySQL root
password, please input the password (<code>admin_password</code> in our case) we created
on remote MySQL server.</p>
<p>Parameters we used in above command line:</p>
<ul>
<li><code>MYSQL_SERVER</code>: Remote MySQL server address.</li>
<li><code>MYSQL_ROOT_USER</code>: MySQL user name we created on remote MySQL server before installing iRedMail.</li>
<li><code>MYSQL_GRANT_HOST</code>: Hostname or IP address of iRedMail server.</li>
</ul>
<p>iRedMail will create new SQL users for applications like Postfix, Amavisd,
Roundcube webmail, etc, and grant proper privileges to them which will connect
from iRedMail server.</p>
<p>One more optional parameter is <code>MYSQL_SERVER_PORT</code>. it specifies listen port
of remote MySQL server. Default one is <code>3306</code>, you can change it if remote
MySQL server is running on a different port.</p>
<h2 id="after-iredmail-installation">After iRedMail installation</h2>
<p>As mentioned above, it's now ok to delete the new MySQL user <code>admin_iredmail</code>
on remote MySQL server. It will not be used anymore.</p>
<pre><code>mysql&gt; DROP USER 'admin_iredmail'@'192.168.1.200';
</code></pre><p style="text-align: center; color: grey;">Document published under a <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">CC BY-ND 3.0</a> license. If you found something wrong, please do <a href="http://www.iredmail.org/contact.html">contact us</a> to fix it.<!-- Google Analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3293801-14");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body></html>

View File

@ -0,0 +1,127 @@
# Install iRedMail with a remote MySQL server
[TOC]
## Summary
This article describes how to install iRedMail (iRedMail-0.8.6 or later
releases) with a remote MySQL server, and you must choose MySQL backend in
iRedMail installation wizard.
We use below server IP addresses in our example:
* `192.168.1.100`: Remote MySQL server.
* `192.168.1.200`: iRedMail server. We're going to install the latest iRedMail
on this server.
iRedMail won't install MySQL server (RPM/DEB package) on localhost with remote
MySQL server, but MySQL client tools are still required for remote connection.
## Requirements
In our case, remote MySQL server runs on server `192.168.1.100`. It must accept
remote connection from iRedMail server __BEFORE__ installing iRedMail, and we
must create a new SQL user with password and proper privileges for remote login
from iRedMail server (`192.168.1.200` in our case).
* Make sure your remote MySQL server accepts remote connection from iRedMail
server. For example, you can check it with command `netstat`:
```
# netstat -ntlp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2479/mysqld
```
If MySQL server is listening on only 127.0.0.1, you should comment out
`bind-address` parameter in MySQL config file `my.cnf` to make it listen on all
available network interfaces, and restart MySQL service.
* On Red Hat Enterprise Linux, CentOS, openSUSE, OpenBSD, it's `/etc/my.cnf`.
* On Debian, Ubuntu, it's `/etc/mysql/my.cnf`.
* On FreeBSD, it's `/var/db/mysql/my.cnf`.
```
#bind-address = 127.0.0.1
```
* Make sure remote MySQL request will not be blocked by network firewall like
iptables (Linux), ipfw (FreeBSD) or PF (OpenBSD).
* Create a new SQL user (`admin_iredmail`) with new password (`admin_password`)
and all privileges on remote MySQL server (of course you must choose another
strong password):
```
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin_iredmail'@'192.168.1.200' IDENTIFIED BY 'admin_password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> FLUSH HOSTS;
```
With above commands, MySQL user `admin_iredmail` is allowed to connect from IP
address `192.168.1.200` with password `admin_password`.
__Notes__:
* `WITH GRANT OPTION` in above SQL command is required.
* Of course you can use `root` or other MySQL user as remote MySQL user name
in above SQL command, but a custom user name should be better to help you
understand what it's used for, and less confuse with default `root` user.
* You must replace `192.168.1.200` by the real IP address of your iRedMail
server in above command.
* It's recommended to delete this user AFTER iRedMail installation, it won't
be used anymore. We will give you SQL command to delete it later.
If you tried to install iRedMail with this remote MySQL server before, please
drop existing databases and MySQL users which will be created by iRedMail on
remote MySQL server:
```
mysql> DROP DATABASE amavisd;
mysql> DROP DATABASE cluebringer;
mysql> DROP DATABASE iredadmin;
mysql> DROP DATABASE roundcubemail;
mysql> DROP DATABASE vmail;
mysql> DROP USER 'amavisd'@'192.168.1.200';
mysql> DROP USER 'cluebringer'@'192.168.1.200';
mysql> DROP USER 'iredadmin'@'192.168.1.200';
mysql> DROP USER 'roundcube'@'192.168.1.200';
mysql> DROP USER 'vmail'@'192.168.1.200';
mysql> DROP USER 'vmailadmin'@'192.168.1.200';
```
## Install iRedMail
Please follow iRedMail installation guide strictly, but start iRedMail
installer with below command instead of the original one (`bash iRedMail.sh`):
```
# MYSQL_SERVER='192.168.1.100' MYSQL_ROOT_USER='admin_iredmail' MYSQL_GRANT_HOST='192.168.1.200' bash iRedMail.sh
```
It will launch iRedMail installation wizard as usual. When it asks MySQL root
password, please input the password (`admin_password` in our case) we created
on remote MySQL server.
Parameters we used in above command line:
* `MYSQL_SERVER`: Remote MySQL server address.
* `MYSQL_ROOT_USER`: MySQL user name we created on remote MySQL server before installing iRedMail.
* `MYSQL_GRANT_HOST`: Hostname or IP address of iRedMail server.
iRedMail will create new SQL users for applications like Postfix, Amavisd,
Roundcube webmail, etc, and grant proper privileges to them which will connect
from iRedMail server.
One more optional parameter is `MYSQL_SERVER_PORT`. it specifies listen port
of remote MySQL server. Default one is `3306`, you can change it if remote
MySQL server is running on a different port.
## After iRedMail installation
As mentioned above, it's now ok to delete the new MySQL user `admin_iredmail`
on remote MySQL server. It will not be used anymore.
```
mysql> DROP USER 'admin_iredmail'@'192.168.1.200';
```