Install and configure Email Server

xiaoxiao2026-04-22  0

To install and configure Email server, there are two things need to be done.The first things is to install and configure the DNS servr. The second is to install and configure Email server. We usually use the BIND for the DNS server on the Redhat server and use the James and sendmail for the email server. Step 1, install the DNS server on Redhat. 1. Get the bind from the website, www.bind.com. 2. upload the installation file to the server Redhat and use tar -zxvf *.gz to extract the file. 3. The file was needed to make install. ./configure --prefix=/usr/local/named # this tell the system the path to install make #precompile make install # make install. 4.Since now, the installation were finished and the configure can be started. 5.Add the user and group bind. groupadd bind useradd -g bind -d /usr/local/named -s /sbin/nologin bind 6.configure the DNS cd /usr/local/named/etc /usr/local/named/sbin/rndc-confgen > rndc.conf cat rndc.conf > rndc.key chmod 777 /usr/local/named/var tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf vi named.conf 添加下面内容( ################# options { directory "/usr/local/named/var"; pid-file "named.pid"; }; zone "." IN { type hint; file "named.root"; }; zone "localhost" IN { type master; file "localhost.zone"; allow-update { none; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "named.local"; allow-update { none; }; }; zone "test.com" IN { type master; file "test.com.zone"; allow-update { none; }; }; zone "1.168.192.in-addr.arpa" in { type master; file "test.com.rev"; allow-update { none; }; }; ######################## cd /usr/local/named/var 1:named.root dig @a.root-servers.net . ns > named.root 2:localhost.zone ########## $TTL 86400 $ORIGIN localhost. @ 1D IN SOA @ root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS @ 1D IN A 127.0.0.1 ############# 3:named.local ############### $TTL 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS localhost. 1 IN PTR localhost. #################### 4:test.com.zone ############ $TTL 86400 ; 1 day @ IN SOA ns1.test.com. root.test.com. ( 2008050122 ; serial 28800 ; refresh (8 hours) 7200 ; retry (2 hours) 604800 ; expire (1 week) 86400 ; minimum (1 day) ) NS ns1.test.com. A 192.168.1.168 MX 10 mail.test.com. www A 192.168.1.168 mail A 192.168.1.168 ns1 A 192.168.1.168 ######################### 5:test.com.rev ############# $TTL 86400 @ IN SOA ns1.test.com. root.test.com.( 20031001; 7200; 3600; 43200; 86400); @ IN NS ns1.test.com. 168 IN PTR ns1.test.com. ############## 7 create the service vi /etc/rc.d/init.d/named #!/bin/bash # named a network name service. # chkconfig: 345 35 75 # description: a name server if [ `id -u` -ne 0 ] then echo "ERROR:For bind to port 53,must run as root." exit 1 fi case "$1" in start) if [ -x /usr/local/named/sbin/named ]; then /usr/local/named/sbin/named -c /usr/local/named/etc/named.conf -u bind && echo . && echo 'BIND9 server started' fi ;; stop) kill `cat /usr/local/named/var/named.pid` && echo . && echo 'BIND9 server stopped' ;; restart) echo . echo "Restart BIND9 server" $0 stop sleep 10 $0 start ;; reload) /usr/local/named/sbin/rndc reload ;; status) /usr/local/named/sbin/rndc status ;; *) echo "$0 start | stop | restart |reload |status" ;; esac ->chmod 755 /etc/rc.d/init.d/named ->chkconfig --add named ->service named start 8 test the service /usr/local/named/sbin/named -g You can use the script to test the server and it will print the start log. start the server /usr/local/named/sbin/named -c /usr/local/named/etc/named.conf -u bind & view the status of the server /usr/local/named/sbin/rndc status start teh server service named restart edit /etc/resolv.conf change the dns server to local pc. we can nslookup to test the dns server. eg: nslookup www.polisy.com.sg Step 2, Install and configure the james. James is very easy to install. 1. After upload the installation file,we can use tar -zxvf .gz to extract the tar file. eg: tar -zxvf *.gz -C james #extract the gz file to james. 2. Add the JAVA_HOME to the script $JAMES_HOME/bin/run.sh # add JAVA_HOME JAVA_HOME=/opt/jdk1.6.0_13 export JAVA_HOME 3. Will start the james. When start the james ,it will check if there is another mail server started on the redhat,so we need to close other email server ->service sendmail stop ->sh run.sh If there is no problem, we can see the message below. # sh run.sh Using PHOENIX_HOME: /opt/james/james-2.3.1 Using PHOENIX_TMPDIR: /opt/james/james-2.3.1/temp Using JAVA_HOME: /opt/jdk1.6.0_13 Running Phoenix: Phoenix 4.2 James Mail Server 2.3.1 Remote Manager Service started plain:4555 POP3 Service started plain:110 SMTP Service started plain:25 NNTP Service started plain:119 FetchMail Disabled 4 modify the /SAR-INF/config <postmaster>Postmaster@test.com</postmaster> <servernames autodetect="false" autodetectIP="true"> <!-- CONFIRM? --> <servername>test.com</servername> </servernames> 5. restart the serer sh run.sh 6. add user and password telnet 127.0.0.1 4555 adduser usr pwd Step 3. create the start and stop server script for DNS and james server. vi startEmailserver #! /bin/sh service sendmail stop service named start sh /opt/james/james-2.3.1/bin/run.sh & vi stop Email server #! /bin/sh # kill james pid pidlist=`ps -ef|grep jame | grep -v "grep"|awk '{print $2}'` #ps -u $USER|grep "java"|grep -v "grep" echo "email server Id list :$pidlist" if [ "$pidlist" = "" ] then echo "no email server pid alive" else for pid in ${pidlist} { kill -9 $pid echo "KILL $pid:" echo "service stop success" } fi #stop DNS server pidlist=`ps -ef|grep named | grep -v "grep"|awk '{print $2}'` #ps -u $USER|grep "java"|grep -v "grep" echo "DNS server Id list :$pidlist" if [ "$pidlist" = "" ] then echo "no DNS server pid alive" else for pid in ${pidlist} { kill -9 $pid echo "KILL $pid:" echo "service stop success" } fi
转载请注明原文地址: https://www.6miu.com/read-5047781.html

最新回复(0)