Golfreeze.packetlove.com: Life style of Golfreeze Canon400D Family kammtan.com Jazz Freebsd Unix Linux System Admin guitar Music
All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server => all application on unix knowledges by golfreeze => Topic started by: golfreeze on มกราคม 23, 2011, 12:28:20 am
-
วันนี้ พอดีมีเครื่อง R200 มาให้เล่นก็เลย ลองลงเป็น debian 4.0 R3 64 bit
กับ vhcs2 ครับ
ลองมาดูขั้นตอนกันเด้อ ซู
ก่อนอื่นลง OS ตั้ง ip เสร็จ ก็มาแก้ไข sources.list ให้โหลด package ในไทยตามนี้เด้อ
#vi /etc/sources.list
deb http://ftp.thaios.net/debian/etch main
deb-src http://ftp.thaios.net/debian/etch main
ทำการ update และ upgrade package
#apt-get update
#apt-get upgrade
แล้วทำการลง ssh ก่อนโดย
#apt-get install ssh
แล้วทำการลง package ต่างๆ ที่จำเป็นที่จะใช้ดังนี้
ลง MySQL server (MySQL5):
#apt-get install mysql-server mysql-client libmysqlclient15-dev phpmyadmin
แก้ไขให้ client connect ไปที่ mysql server ได้ทุกแบบไม่ใช่แค่ "localhost"
#vi /etc/mysql/my.cnf
หาบันทัด bind-address = 127.0.0.1 แล้วใส่ # ไปซะ
# bind-address = 127.0.0.1
ทำการ restart MySQL:
#/etc/init.d/mysql restart
ใส่ค่า password ของ mysql
#mysqladmin -u root password yourpassword
ต่อไปทำการ install Apache 2(.2) with PHP5
#apt-get install apache2 apache2-doc apache2-mpm-prefork apache2.2-common apache2-utils libexpat1 ssl-cert
และต่อไป install php5
#apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear
php5-imagick php5-imap php5-json php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-ps
php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
จะขึ้น Pop-up ถามว่า
Continue installing libc-client without Maildir support?
ตอบไปว่า yes
แก้ไข config apache ดังนี้
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml
แก้ไขไฟล์ /etc/apache2/ports.conf
โดยเพิ่ม Listen 443:
#vi /etc/apache2/ports.conf
Listen 80
Listen 443
ทำการเปิด module ต่างๆ ที่จะใช้ใน apache
#a2enmod ssl
#a2enmod rewrite
#a2enmod suexec
#a2enmod include
ทำการ reload config apache
#/etc/init.d/apache2 force-reload
ต่อไปทำการลง mail server
#apt-get install postfix postfix-tls
จะถามค่า hostname
ใส่ให้ตรงกับ ตอนที่ install os
เช่น server1.example.com
#apt-get install proftpd proftpd-mysql
เลือกเป็นแบบ "Stand alone"
#apt-get install courier-authdaemon courier-base courier-imap courier-maildrop courier-pop
libberkeleydb-perl libcrypt-blowfish-perl libcrypt-cbc-perl libcrypt-passwdmd5-perl libdate-calc-perl libdate-manip-perl libdbd-mysql-perl libdbi-perl libio-stringy-perl libmail-sendmail-perl libmailtools-perl libmd5-perl libmime-base64-perl libmime-perl libnet-dns-perl
libnet-netmask-perl libnet-perl libnet-smtp-server-perl
libperl5.8 libsnmp-session-perl libterm-readkey-perl libtimedate-perl perl perl-base perl-modules
bind9 diff gzip iptables libmcrypt4 patch procmail tar original-awk libterm-readpassword-perl
libsasl2-modules libsasl2 sasl2-bin bzip2 gcc make libc6-dev
แก้ไขไฟล์ /etc/proftpd/proftp.conf ดังนี้
#vi /etc/proftpd/proftpd.conf
UseIPv6 off
เพิ่ม config นี้ลงไป
DefaultRoot ~
IdentLookups off
ServerIdent on "FTP Server Ready"
ทำการ save แล้วออกไป.
ต่อไปทำการ download package vhcs2 มาคับตัวนี้ สามารถ support ได้ทั้งแบบ 64 bit กับ 32 bit น่ะครับ
#cd /usr/src
#wget http://downloads.sourceforge.net/vhcs/vhcs2-2.4.7.1.tar.bz2
แตกไฟล์:
#tar -xjf vhcs2-2.4.7.1.tar.bz2
เข้าไปยัง
#cd vhcs2-2.4.7.1
สั่งรัน เพิ่มให้สร้างตัว install :
#make install
หลังจากนั้นเข้าไปที่
#cd /tmp/vhcs-2.4.7.1
ทำการ copy file ไปยังปลายทาง:
#cp -R * /
##แก้ path fix error ftp ผ่านเว็บครับ
แก้ bug เรื่อง filemanager
Edit files:
/etc/vhcs2/apache/parts/als_entry.tpl
/etc/vhcs2/apache/parts/als_php2_entry.tpl
/etc/vhcs2/apache/parts/dmn_entry.tpl
/etc/vhcs2/apache/parts/dmn_php2_entry.tpl
/etc/vhcs2/apache/parts/sub_entry.tpl
/etc/vhcs2/apache/parts/sub_php2_entry.tpl
แล้วแก้ไขไฟล์ โดยลบ / หลัง /tmp/ ออกครับให้เหลือแค่
/tmp ในไฟล์เหล่านี้
เช่น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp/"
แก้เป็น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp"
แล้วเข้าไปที่ :
#cd /var/www/vhcs2/engine/
ทำการแก้ไข file vhcs2_common_code.pl
#vi vhcs2_common_code.pl
ใช้ vi เข้าไปแก้ บันทัดที่ "1408" หาคำว่า:
'key'=>$main::db_pass_key,
เพิ่มบันทัดนี้เข้าไปก่อนหน้า นั้น
'keysize'=>32,
ระวังเครื่องหมายด้วยน่ะครับ
แก้ที่บันทัด ประมาณ 1446 ให้ใส่ตามข้างบนนั้น
save แล้วออกมา.
เริ่มทำการ install vhcs ครับ
#cd /var/www/vhcs2/engine/setup
#./vhcs2-setup
-
วันนี้ลองใช้งาน mail Client ใน VHCS ดูครับซึ่งเป็นตัวของ UebiMiau ที่ลงมากับตัว VHCS พอลองสร้าง
account ดูก็ไม่มีปัญหาอะไรแต่พอ login เข้าใช้งานก็เจอ message นี้ครับ
ERROR (2): Header may not contain more than a single header, new line detected.
(/var/www/vhcs2/gui/tools/webmail/inc/inc.php:155)
พอลอง search ใน google ดูก็พอเจอ แนวๆว่าให้เข้าไปแก้ไฟส์ inc.php นั้นซะซึ่งโหลดมาแก้ดังนี้คือ จาก
บันทัดที่ 155
Change :
Header("Expires: Wed, 11 Nov 1998 11:11:11 GMTrn".
"Cache-Control: no-cachern".
"Cache-Control: must-revalidate");
to
Header("Expires: Wed, 11 Nov 1998 11:11:11 GMT");
Header("Cache-Control: no-cache");
Header("Cache-Control: must-revalidate");
Save, and exit. แล้ว copy ไปไว้ที่เดิมคราวนี้ก็ลอง refresh ดูแล้ว login เข้าใช้งาน mail client
ก็สามารถใช้งานได้ปกติครับ อิอิเมลล์ใหม่คือ golfreeze@packetlove.com ครับ
-
แก้ ให้ ftp ได้ดังนี้
Step 1: Backups
nano /etc/proftpd.conf
the do a ^X (Ctrl + X) and save it as /etc/proftpd2.conf
Step 2: Delete BS Config
nano /etc/proftpd.conf
Remove everything above the "#VHCS2 Management;" Line.
Save the Doc and Exit (Ctrl + O, Ctrl + M, Ctrl + X).
Step 3: Include the VHCS FTP File
nano /etc/proftpd/proftpd.conf
Find the line
#<IfModule mod_sql.c>
# SQLBackend mysql
#</IfModule>
And make it look like this
<IfModule mod_sql.c>
SQLBackend mysql
Include /etc/proftpd.conf
</IfModule>
Save and exit the document.
Step 4: Disable PostgresSQL Module
nano /etc/proftpd/modules.conf
Comment out the following line
LoadModule mod_sql_postgres.c
Save and Exit
Step 5: Restart ProFTP
/etc/init.d/proftpd restart
You may also want to reboot your machine, but thats
completely optional. However that is all that needs to be
done.
-
แก้ไข ไฟล์ /etc/php5/cli/php.ini
แล้วแก้ไข ไฟล์
vi /etc/apache2/sites-enabled/vhcs2.conf
จาก
php_admin_value open_basedir
'/var/www/vhcs2/gui/tools/filemanager/:/tmp/:/usr/share/php/'
เปลี่ยนเป็น
php_admin_value open_basedir
'/var/www/vhcs2/gui/tools/filemanager/:/tmp:/usr/share/php/'
-
http://www.webhostingtalk.com/showthread.php?p=5070700
แก้ bug
แก้ bug เรื่อง filemanager
Edit files:
/etc/vhcs2/apache/parts/als_entry.tpl
/etc/vhcs2/apache/parts/als_php2_entry.tpl
/etc/vhcs2/apache/parts/dmn_entry.tpl
/etc/vhcs2/apache/parts/dmn_php2_entry.tpl
/etc/vhcs2/apache/parts/sub_entry.tpl
/etc/vhcs2/apache/parts/sub_php2_entry.tpl
แล้วแก้ไขไฟล์ โดยลบ / หลัง /tmp/ ออกครับให้เหลือแค่
/tmp ในไฟล์เหล่านี้
เช่น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp/"
แก้เป็น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp"
ถ้าทำเสร็จหมดแล้วทำการ อัฟเดท vhcs2.conf ใหม่ดังนี้ ครับ
/etc/init.d/vhcs2_daemon stop
mysql -u root -p<password>
USE vhcs2
UPDATE `domain` SET `domain_status` = 'change' WHERE `domain_status` = 'ok';
UPDATE `domain_aliasses` SET `alias_status` = 'change' WHERE `alias_status` = 'ok';
UPDATE `subdomain` SET `subdomain_status` = 'change' WHERE `subdomain_status` = 'ok';
quit
/var/www/vhcs2/engine/vhcs2-rqst-mngr
/etc/init.d/vhcs2_daemon start
มีปัญหาก็สอบถามไว้ได้ น่ะครับ
##ปรับ timezone ของ debian ให้เป็นเวลา malaysia
cp /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime
-
##mail gateway in debian + vhcs
สำหรับ vhcs เองจะไม่ได้ทำ config เกี่ยวกับ mail gateway ที่มีตัว clamav spamassasin amavisd
มาให้น่ะครับ เราต้องทำการ modify เองเล็กน้อย แต่เพื่อมาตรฐานที่ดี ของเรา ควรทำไว้ครับ
เพื่อจะได้ใช้งาน email ได้อย่างไม่มีปัญหามารบกวน อิอิ
### INSTALL ###
### Postfix
apt-get install postfix
dpkg-reconfigure postfix
#postfix re-configuration, if needed
configuration files:
/etc/postfix/main.cf
/etc/postfix/master.cf
(logs to syslog by default)
### Amavis
apt-get install amavisd-new
configuration files:
/etc/amavis/conf.d/01-debian
/etc/amavis/conf.d/05-domain_id
/etc/amavis/conf.d/05-node_id
/etc/amavis/conf.d/15-av_scanners
/etc/amavis/conf.d/15-content_filter_mode
/etc/amavis/conf.d/20-debian_defaults
/etc/amavis/conf.d/25-amavis_helpers
/etc/amavis/conf.d/30-template_localization
/etc/amavis/conf.d/50-user
amavisd-new might complaint about hostname during install, when trying to start amavisd-new
type: hostname
if it returns only your hostname (like debian), but not your fully qualified domain name (like
debian.myhosting.com) you have found the problem.
check your /etc/hosts file, it should contain the following two lines: (if not, fix it!)
127.0.0.1 localhost.localdomain localhost
your_ip your_hostname your_hostname.your_domain_name
check by typing: hostname
if it returns this format, it will be OK: your_hostname.your_domain_name
### Clamav
apt-get install clamav-daemon clamav-freshclam
configuration files:
/etc/clamav/clamav.conf
(logs to /var/log/clamav.log and freshclam.log)
### Spamassassin
apt-get install spamassassin spamc
configuration files:
/etc/spamassassin/init.pre
/etc/spamassassin/init.pre.dpkg-dist
/etc/spamassassin/local.cf
/etc/spamassassin/plugintest.cf
/etc/spamassassin/sa-update-keys
/etc/spamassassin/v310.pre
/etc/spamassassin/v312.pre
(no logging by default)
### CONFIGURATION ###
### Setting up Postfix for using amavisd-new:
Add the following line to end of /etc/postfix/main.cf
content_filter = smtp-amavis:[127.0.0.1]:10024
Add the following lines to end of /etc/postfix/master.cf
smtp-amavis unix - - n - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookup=yes
localhost:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
Restart both damons to load the modified config files:
/etc/init.d/postfix restart
/etc/init.d/amavis restart
If should work, without even touching any of amavis's conf files.
By default, both of them log to: /var/log/syslog
You can track mail processing by typing: tail -f /var/log/syslog
When a mail arrives, postfix will call amavisd-new, to process mails.
### Setting up amavisd-new to call clamav-daemon
A default clamav.conf should look like this somehow:
LocalSocket /var/run/clamav/clamd.ctl
FixStaleSocket
User clamav
AllowSupplementaryGroups
ScanMail
ScanArchive
ArchiveMaxRecursion 5
ArchiveMaxFiles 1000
ArchiveMaxFileSize 10M
ArchiveMaxCompressionRatio 250
ReadTimeout 180
MaxThreads 12
MaxConnectionQueueLength 15
LogFile /var/log/clamav/clamav.log
LogSyslog
LogTime
LogFileMaxSize 0
PidFile /var/run/clamav/clamd.pid
DatabaseDirectory /var/lib/clamav
SelfCheck 3600
ScanOLE2
ScanPE
DetectBrokenExecutables
ScanHTML
ArchiveBlockMax
LogVerbose
Add user clamav to group amavis:
adduser clamav amavis
start freshclam-daemon: (updates virus signiture database 24 times a day by default)
/etc/init.d/clamav-freshclam start
by default you don't need to touch clamav's conf files.
/etc/amavis/conf.d/15-av_scanners contains every necessary setting for amavis to communicate with
clamav-daemon
simply restart clamav-daemon:
/etc/init.d/clamav-daemon start
When a mail arrives, postfix will call amavisd-new, that calls clamav-daemon to process mails for
viruses.
### Spamassassin + spamc
After searching for days, how to call spamassassin from amavisd-new + reading some documentation,
where it was suggested to use spamc, i have decided not to call spamassassin from amavisd-new
spamc is a client for spamd, the daemon of spamassassin
as it it is claimed, "Spamc has extremely low overhead in loading, so it should be much
faster to load than the whole spamassassin program"
speed, CPU and memory usage might be an issue when processing thousends of mails per hour
create a user, called spamd:
adduser --shell=/bin/false --disabled-password --gecos=,,, spamd
at /etc/default/spamassassin set ENABLED=1 (if needed)
add some logging capability:
OPTIONS="--create-prefs --max-children 5 --helper-home-dir -s /var/log/spamd.log"
at /etc/postfix/master.cf modify at the beginning of the file
from:
smtp inet n - - - - smtpd
to:
smtp inet n - - - - smtpd
-o content_filter=spamassassin
add the follwing lines to the end of the file:
spamassassin unix - n n - - pipe
user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
restart postfix to the modifications take effect:
/etc/init.d/postfix restart
-
ถ้าจะทำการลงกับ debian6 (squeeze)
ต้องเปลี่ยน default shell ด้วยนะครับผม
/bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. Therefore we do this:
#dpkg-reconfigure dash
Use dash as the default system shell (/bin/sh)? <-- No
เรียบร้อยครับผม