Lamp + Postfix + Dovecot + courier-authlib
Install Lamp
Environment
Yum-y install OpenSSL-devel ncurses-devel libtermcap-devel libxml2-devel
Install Apache
Tar Z/httpd-2.2.26.tar.gz-C/usr/src/
CD/usr/src/httpd-2.2.26/
. /Configure -- prefix =/usr/local/httpd -- enable-so -- enable-Rewrite -- enable-CGI -- enable-charset-lite -- enable-SSL -- enable-suexec --- suexec-caller = daemon -- With-suexec-docroot =/usr/local/httpd/htdocs
Echo $?
Make & make install
Echo $?
\ CP-F/usr/local/httpd/bin/apachectl
Sed-I '1 A # chkconfig: 35 85 15'/etc/init. d/httpd
Sed-I '2 A # Description: Apache is a World Wide Web server'/etc/init. d/httpd
Chmod + x/etc/init. d/httpd
Chkconfig -- add httpd
Install MySQL
Tar Z/mysql-5.15-C/usr/src/
CD/usr/src/mysql-5.15/
Useradd-m-u 49-S/sbin/nologin MySQL
./Configure -- prefix =/usr/local/MySQL -- With-charset = utf8 -- With-collation = utf8_general_ci -- With-extra-charset = GBK, gb2312
Make & make install
Echo $?
# Create the my. CNF configuration file
CP-F/usr/local/MySQL/share/MySQL/my-medium.cnf/etc/My. CNF
Vim/etc/My. CNF
Sed-I's/^ skip-locking/# Skip-locking/'/etc/My. CNF
Sed-I '/# Skip-locking/a skip-external-locking'/etc/My. CNF
# MySQL execution optimization and database adding path
Ln-SF/usr/local/MySQL/bin/*/usr/local/bin/
Echo "/usr/local/MySQL/lib/MySQL">/etc/lD. So. conf. d/mysql-64.conf
Ldconfig
# Create a mysqld service control script
CP-F/usr/local/MySQL/share/MySQL. Server/etc/init. d/mysqld
Chmod + x/etc/init. d/mysqld
Chkconfig -- add mysqld
CD/usr/local/MySQL/bin
Mysql_install_db -- user = MySQL
# Adjusting MySQL Directory Permissions
Chown-r root: MySQL/usr/local/MySQL/
Chown-r MySQL/usr/local/MySQL/var/
Mysqladmin-uroot-P password 1234567
PHP installation
Tar Z/php-5.4.24.tar.gz-C/usr/src/
CD/usr/src/php-5.4.24/
. /Configure -- prefix =/usr/local/PHP -- enable-mbstring -- enable-sockets -- with-apxs2 =/usr/local/httpd/bin/apxs -- With-mysql =/usr/ local/MySQL -- With-config-file-Path =/usr/local/PHP
Make & make install
Echo $?
Confirm HTTP for PHP
Awk '/^ loadmodule/{print}'/usr/local/httpd/CONF/httpd. conf
Sed-I '/directoryindex/S/$/index. php/'/usr/local/httpd/CONF/httpd. conf
Sed-I '/addhandler allows/I \ taddtype application/X-httpd-PHP. php'/usr/local/httpd/CONF/httpd. conf
Start lamp platform and Test
Service mysqld restart
Service httpd restart
Vim/usr/local/httpd/htdocs/test2.php
<? PHP
$ Link = mysql_connect ('localhost', 'root', '123 ');
If ($ link) echo "Success !! ";
Else echo "failure !! ";
Mysql_close ();
?>
Access http: // server address/test2.php from a browser, and "Success!" should be displayed !!"
Install Postfix
Service Sendmail stop
Chkconfig Sendmail off
Yum-y install db4-devel cyrus-sasl-devel
# Running Account
Groupadd-G 1200 postdrop
Groupadd-G 1000 Postfix
Useradd-m-u 1000-G 1000-G 1200-S/sbin/nologin Postfix
# Configure compilation and Installation
Tar zxf Postfix -2.10.2.tar.gz
CD
Make makefiles ccargs = "-duse_sasl_auth-duse_cyrus_sasl-I/usr/include/sasl-dhas_mysql-I/usr/local/MySQL/include/MySQL" auxlibs = "-l/usr/ LIB/sasl2-lsasl2-L/usr/local/MySQL/lib/MySQL-lmysqlclient-LZ-lm"
Make & make install
# Carriage return for 15 times
# Check whether MySQL is supported
Postconf-m
# Set Automatic startup
Sed-I '$ A \/usr \/sbin \/Postfix start'/etc/rc. Local
# Install Dovecot
Yum-y install Pam-devel
# Add an account
Useradd-m-S/sbin/nologin Dovecot
Useradd-m-S/sbin/nologin dovenull
Tar zxf Dovecot -2.2.5.tar.gz-C/usr/src
CD/usr/src/Dovecot-2.2.5/
./Configure -- sysconfdir =/etc -- With-mysql -- With-Pam
Make & make install
Cd doc/
\ CP-RPF example-config/*/etc/Dovecot/
# Disable SSL encryption
# Disable an SSL Certificate
# Disable an SSL Key
Sed-I '0,/^ # SSL/S/yes/no/'/etc/Dovecot/CONF. d/10-ssl.conf
Sed-I '0, S/^ ssl_cert/# ssl_cert/'/etc/Dovecot/CONF. d/10-ssl.conf
Sed-I '0,/^ ssl_cert/S/ssl_cert/# ssl_cert/'/etc/Dovecot/CONF. d/10-ssl.conf
Sed-I '0,/^ ssl_key/S/ssl_key/# ssl_key/'/etc/Dovecot/CONF. d/10-ssl.conf
# Create PAM Authentication Settings
Echo "# % PAM-1.0">/etc/PAM. d/Dovecot
Echo "auth required Pam nologin. So">/etc/PAM. d/Dovecot
Echo "auth include system-auth">/etc/PAM. d/Dovecot
Echo "account include system-auth">/etc/PAM. d/Dovecot
Echo "session include system-auth">/etc/PAM. d/Dovecot
# Add Dovecot Service
CP dovecot-initd.sh/etc/init. d/Dovecot
Chmod + x/etc/init. d/Dovecot
Chkconfig -- add Dovecot
# Install courier-authlib
Yum-y install libtool-ltdl-devel verify CT
Tar jxf courier-authlib-0.63.0.tar.bz2-C/usr/src
CD/usr/src/courier-authlib-0.63.0
. /Configure -- prefix =/usr/local/authd -- without-stdheaderdir -- With-mysql-libs =/usr/local/MySQL/lib/MySQL -- With-mysql-except des =/ usr/local/MySQL/include/MySQL -- With-mailuser = postfix -- With-mailgroup = postfix -- without-authpam -- without-authldap -- without-authpgsql -- without-authcustom --- authpipe -- without-authpwd -- without-authshadow
-- Without-authuserdb # possible problems
Make $ make install-configure
# Update the search box path
Echo "/usr/local/authd/lib/courier-authlib">/etc/lD. So. conf. d/courier-authlib.conf
Ldconfig
# Add a STARTUP script
CP/usr/src/courier-authlib-0.63.0/courier-authlib.sysvinit/etc/init. d/authd
Chmod + x/etc/init. d/authd
Chkconfig -- add authd
Configure virtual user support
# Prepare the MySQL database for the virtual email domain and virtual user
# Import two SQL scripts provided by extman
Tar zxf extman-1.1.tar.gz
Service mysqld restart
Mysql-u root <docs/extmail. SQL
Mysql-u root-p1234567 <docs/extmail. SQL
Mysql-u root-p1234567 <docs/init. SQL
# Database account/password extmail/extmail webman/extman
# Email account/password [email protected]/extmail
# Manage account/password [email protected]/extmail * 123 *
# Create an email Repository
Mkdir-P/mxdir/extmail.org/postmaster/maildir
Chown-r Postfix: Postfix/mxdir/1
# Configure posfix to support virtual users
CD/usr/src/extman-1.1/docs
CP mysql_virtual _ *. Cf/etc/Postfix/
Chown-R: Postfix/etc/Postfix/mysql_virtual _ *. cf
Chmod o-r/etc/Postfix/mysql_virtual _ *. cf
Add virtual user support to enable multi-mail domain support
Sed-I '/# Note:/a inet_interfaces = 192.168.1.254, 127.0.0.1'/etc/Postfix/Main. Cf # Listening address
Sed-I '/other configuration parameters/A myhostname = mail.zongxuan.com'/etc/Postfix/Main. Cf # configure the Host Name
Sed-I '/^ # mydomain/I mydomain = zongxuan.com'/etc/Postfix/Main. Cf # configure the Domain Name
Sed-I's/# home_mailbox = maildir/'/etc/Postfix/Main. cf
Sed-I '/The value on the table right-hand side is not used/A mynetworks = 127.0.0.1'/etc/Postfix/Main. cf
Sed-I '/parallel delivery to the same destination/I smtpd_sasl_auth_enable = Yes'/etc/Postfix/Main. Cf # enable SMTP authentication
Sed-I '/smtpd_sasl_auth_enable = Yes/A smtpd_sasl_security_options = noanonymous'/etc/Postfix/Main. cf
Sed-I '/smtpd_sasl_security_options = noanonymous/A smtpd_recipient_restrictions ='/etc/Postfix/Main. cf
Sed-I '/smtpd_recipient_restrictions =/A permit_mynetworks,'/etc/Postfix/Main. cf
Sed-I '/permit_mynetworks,/a permit_sasl_authenticated,'/etc/Postfix/Main. Cf ***
Sed-I '/permit_sasl_authenticated/A reject_unauth_destination'/etc/Postfix/Main. cf
# Root directory of the mailbox
Echo "######">/etc/Postfix/Main. cf
Echo "virtual_mailbox_base =/mxdir">/etc/Postfix/Main. cf
Echo "virtual_alias_maps = MYSQL:/etc/Postfix/mysql_virtual_alias_maps.cf">/etc/Postfix/Main. cf
Echo "virtual_mailbox_maps = MYSQL:/etc/Postfix/mysql_virtual_mailbox_maps.cf">/etc/Postfix/Main. cf
Echo "virtual_mailbox_domains = MYSQL:/etc/Postfix/mysql_virtual_domains_maps.cf">/etc/Postfix/Main. cf
# Postfix uid
# Uid of the group Postfix
Echo "virtual_uid_maps = static: 1000">/etc/Postfix/Main. cf
Echo "virtual_gid_maps = static: 1000">/etc/Postfix/Main. cf
# Start the Postfix Service
Postfix start
# Configure courier-authlib to support virtual users
# Set authdaemonrc Certification Service
# Make sure that the authentication module only enables authmysql. You can set debug_login to 2 as needed to enable detailed debugging for production 0.
Sed-I '0,/^ authmodulelist/S/authuserdb // '/usr/local/authd/etc/authlib/authdaemonrc
Sed-I '0,/authmodulelistorig =/S/authuserdb // '/usr/local/authd/etc/authlib/authdaemonrc
# Modify SASL authentication method
Echo "pwcheck_method: authdaemond">/etc/sasl2/smtpd. conf
Echo "authdaemond_path:/usr/local/authd/var/spool/authdaemon/socket">/etc/sasl2/smtpd. conf
Chmod + x/etc/sasl2/smtpd. conf
# Configure the authmysqlrc database connection
Sed-I '/^ mysql_server/S/mysql.example.com/localhost/'/usr/local/authd/etc/authlib/authmysqlrc # MySQL server address
Sed-I '/^ mysql_username/S/admin/extmail/'/usr/local/authd/etc/authlib/authmysqlrc # MySQL Username
Sed-I '/^ mysql_password/S/admin/extmail/'/usr/local/authd/etc/authlib/authmysqlrc # MySQL connection password
# Sed-I '/mysql_socket/S/var/tmp/'/usr/local/authd/etc/authlib/authmysqlrc # interface file of mysqld service
# Sed-I '/MySQL. Sock/S/# //'/usr/local/authd/etc/authlib/authmysqlrc # interface file of mysqld service
Sed-I '/^ mysql_socket/var/MySQL. Sock/d'
Sed-I '/^ mysql_socket/A mysql_socket \/tmp \/MySQL. Sock'/usr/local/authd/etc/authlib/authmysqlrc
Sed-I '/^ mysql_database/S/MySQL/extmail/'/usr/local/authd/etc/authlib/authmysqlrc # library to be accessed
Sed-I '/^ mysql_user_table/S/passwd/mailbox/'/usr/local/authd/etc/authlib/authmysqlrc # store virtual user tables
Sed-I '/^ mysql_crypt_pwfield/S/crypt/password/'/usr/local/authd/etc/authlib/authmysqlrc # Password Field
Sed-I '/^ mysql_uid_field/S/UID/uidnumber/'/usr/local/authd/etc/authlib/authmysqlrc # user uid Field
Sed-I '/^ mysql_gid_field/S/GID/gidnumber/'/usr/local/authd/etc/authlib/authmysqlrc # group GID Field
Sed-I '/^ mysql_login_field/S/ID/username/'/usr/local/authd/etc/authlib/authmysqlrc # Username Field
Sed-I "/^ mysql_home_field/S/home/Concat ('\/mxdir \/', homedir) /"/usr/local/authd/etc/authlib/authmysqlrc # main directory of the user
Sed-I "/# mysql_maildir_field/S/maildir/Concat ('\/mxdir \/', maildir) /"/usr/local/authd/etc/authlib/authmysqlrc # email directory
Sed-I '/# mysql_maildir_field/S/# //'/usr/local/authd/etc/authlib/authmysqlrc
# Enable the authd System Service
Service authd start
# Configure Dovecot to support virtual users
# Modifying mailbox path settings
Sed-I '/# mail_location/S/= maildir: \/mxdir \/% d \/% N \/maildir/'/etc/Dovecot/CONF. d/10-mail.conf
Sed-I's/^ # mail_location/'/etc/Dovecot/CONF. d/10-mail.conf
# Enabling SQL authentication file query settings for user passwords is provided by an independent file specified by ARGs
CP/etc/Dovecot/CONF. d/auth-sql.conf.ext/etc/Dovecot/CONF. d/10-auth-sql.conf
# Set the SQL driver type and query statement to use the SQL statement to query the user name and password from the database
Sed-I '/# driver/A driver = MySQL'/etc/Dovecot/dovecot-sql.conf.ext
Sed-I '/# connect/a connect = host = localhost dbname = extmail user = extmail Password = extmail'/etc/Dovecot/dovecot-sql.conf.ext
Sed-I '/# default_pass_scheme/A default_pass_scheme = crypt'/etc/Dovecot/dovecot-sql.conf.ext
Sed-I "/# password_query/A select username, password from mailbox where username = '% U'"/etc/Dovecot/dovecot-sql.conf.ext
Sed-I "/# password_query/A password_query = select username, password from mailbox where username = '% U'"/etc/Dovecot/dovecot-sql.conf.ext
Sed-I "/# user_query/A user_query = select maildir, uidnumber, gidnumber from mailbox where username = '% U'"/etc/Dovecot/dovecot-sql.conf.ext
# Restart the Dovecot Service
Service Dovecot restart
Chown daemon: daemon/usr/local/authd/var/spool/authdaemon/socket
Deploy extmail Mailbox System
Install the Perl required by extmail
Tar zxf Unix-Syslog-1.1.tar.gz
Tar zxf DBI-1.607.tar.gz
Tar zxf DBD-mysql-4.011.tar.gz
CD Unix-Syslog-1.1
Perl makefile. pl
Make & make install
CD./DBI-1.607
Perl makefile. pl
Make & make install
CD./DBD-mysql-4.011
Perl makefile. pl
Make & make install
# Installing the extmail Mail System
Tar zxf extmail-1.2.tar.gz
MV extmail-1.2/usr/local/httpd/htdocs/extmail
Chown-r Postfix: Postfix/usr/local/httpd/htdocs/extmail/cgi/
# Create a webmail. cf configuration file
CP webmail. Cf. Default webmail. cf
Vim webmail. cf
Sys_config =/usr/local/httpd/htdocs/extmail/
Sys_langdir =/usr/local/httpd/htdocs/extmail/lang
Sys_templdir =/usr/local/httpd/htdocs/extmail/html
Sys_maildir_base =/mxdir
Sys_mysql_user = extmail
Sys_mysql_pass = extmail
Sys_mysql_db = extmail
Sys_mysql_host = localhost
Sys_mysql_socket =/tmp/MySQL. Sock
Sys_authlib_socket =/usr/local/authd/var/spool/authdaemon/socket
Sys_g_rjk_file_path =/usr/local/httpd/htdocs/extmail/globabook. cf
Adjust HTTPd service configuration
Add a VM mail.zongxuan.com
Vim/usr/local/httpd/CONF/extra/httpd-vhosts.conf
<Virtualhost *: 80>
Servername mail.zongxuan.com
DocumentRoot "/usr/local/httpd/htdocs/extmail/html"
ScriptAlias/extmail/cgi/usr/local/httpd/htdocs/extmail/cgi/
Alias/extmail/usr/local/httpd/htdocs/extmail/html/
Suexecusergroup Postfix
</Virtualhost>
Vim/usr/local/httpd/CONF/httpd. conf
Add support for PHP
Index. php
Enable Configuration
# Virtual Hosts
Include CONF/extra/httpd-vhosts.conf
Insert a row
Charsetdefault utf8
Test extmail System
127.0.0.1
Postmaster password extmail extmail.org
Deploy extman Mail System Management Platform
Rpm-IVH rrdtool-1.2.27-4.el5.x86_64.rpm
Rpm-IVH rrdtool-perl-1.2.27-4.el5.x86_64.rpm
Yum-y install Gd-devel
Tar zxf GD-2.41.tar.gz
Tar zxf File-Tail-0.99.3.tar.gz
CD GD-2.41
Perl makefile. pl
Make & make install
CD file-tail
Perl makefile. pl
Make & make install
Install and configure the extman Management System
Tar zxf extman-1.1.tar.gz
MV extman-1.1/usr/local/httpd/htdocs/extman
Chown-r Postfix: Postfix/usr/local/httpd/htdocs/extman/cgi/
CD/usr/local/httpd/htdocs/extman/
CP webman. Cf. Default webman. cf
Vim webman. cf
Sys_config =/usr/local/httpd/htdocs/extman/
Sys_langdir =/usr/local/httpd/htdocs/extman/lang
Sys_templdir =/usr/local/httpd/htdocs/extman/html
Sys_maildir_base =/mxdir
Sys_sess_dir =/tmp/extman/
Sys_captcha_on = 0
Sys_mysql_user = webman
Sys_mysql_pass = webman
Sys_mysql_db = extmail
Sys_mysql_host = localhost
Sys_mysql_socket =/tmp/MySQL. Sock
Create a working directory/tmp/extman
Mkdir/tmp/extman
Chown-r Postfix: Postfix/tmp/extman
Adjust HTTPd service configuration
Modify the virtual host mail.zongxuan.com configuration and add the alias settings for extman/directory for access from http://mail.zongxuan.com/extman/
Add
ScriptAlias/extman/cgi/usr/local/httpd/htdocs/extman/cgi/
Alias/extman/usr/local/httpd/htdocs/extman/html/
Service httpd restart
Enable mailgraph graphics plug-in
Graphical Analysis of email communication/var/log/maillog
The extman source code package contains the mailgraph plug-in program to be deployed under/usr/local /.
CP-RF addon/mailgraph_ext // usr/local/
CD/usr/local/mailgraph_ext/
CP mailgraph-init/etc/init. d/mailgraphd
Chkconfig -- add mailgraphd
Service mailgraphd start
Start the worker server process to provide privileged Interfaces
/Usr/local/httpd/htdocs/extman/daemon/cmdserver-d
Vim/etc/rc. Local
/Usr/local/httpd/htdocs/extman/daemon/cmdserver-d
Access extman System
Http://mail.zongxuan.com/extman/
Account [email protected]
Password extmail x 123 *
Add domain
OK
Install lamp + extmail + extman in source code