# 安装 PHP 存储库 $ sudo apt install software-properties-common # 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman # 2. If you are using apache2, you are advised to add ppa:ondrej/apache2 # 3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline or ppa:ondrej/nginx # 添加 PPA $ sudo add-apt-repository ppa:ondrej/php $ sudo apt update $ sudo apt upgrade $ sudo apt install \ libapache2-mod-php7.2 \ php7.2 \ php7.2-cli \ php7.2-common \ php7.2-curl \ php7.2-fpm \ php7.2-imagick \ php7.2-json \ php7.2-mbstring \ php7.2-mcrypt \ php7.2-sqlite3 \ php7.2-xml \ php7.2-zip \ php7.2-mysqli \ php7.2-gd
# 安装postfix $ apt install postfix postfix-mysql postfix-doc mailutils # General type of mail configuration 输入数字 2 (Internet Site) # System Mail Name 输入 postfix.local # Geographic area 时区输入数字 6 (Asia) # Time Zone 输入数字 70 (Shanghai)
修改配置
虚拟domain配置文件
1
$ vim /etc/postfix/mysql-virtual-domains.cf
内容:
1 2 3 4 5
user = postfix password = postfix dbname = postfix query = SELECT domain AS virtual FROM domains WHERE domain = '%s' hosts = 172.18.0.136
虚拟forwarding配置文件
1 2
$ vim /etc/postfix/mysql-virtual-forwardings.cf
内容
1 2 3 4 5
user = postfix password = postfix dbname = postfix query = SELECT destination FROM forwardings WHERE source='%s' hosts = 172.18.0.136
虚拟mailbox配置文件
1
$ vim /etc/postfix/mysql-virtual-mailboxes.cf
内容
1 2 3 4 5
user = postfix password = postfix dbname = postfix query = SELECT CONCAT(SUBSTRING_INDEX (email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s' hosts = 172.18.0.136
虚拟email2email配置文件
1
vim /etc/postfix/mysql-virtual-email2email.cf
内容
1 2 3 4 5
user = postfix password = postfix dbname = postfix query = SELECT email FROM users WHERE email='%s' hosts = 172.18.0.136