Monday, May 14, 2012

วิธีทำ Firewall ป้องกัน Server ที่ใช้ CP ของ Kloxo

Kloxo
Kloxo
วิธีนี้เอามาจากเว็บ lxcenter.org นะครับ แต่เห็นเป็นภาษาอังกษฤครับเลยอยากให้มีไทยบ้างครับหลักการของเค้าก็คือใช้ ปิด IPTABLES ไว้ก่อนครับแล้วทำ firewall rules ขึ้นมาใหม่ครับแล้วทำให้ firewall run ตอน boot ทุกครั้งครับโดยสร้าง script ไว้ที่ /etc/init.d/ ครับ เหมือน service ตัวหนึ่งเลยละครับทำง่ายมากๆ ครับที่อธิบายผมก็พอเข้าใจแบบนี้ครับ เทพที่ผ่านมาเจออย่าว่ากันนะครับ หุๆ มาดูวิธีกันเลยครับ

อย่างแรกสั่ง
ปิด service IPTABLES:
# /etc/init.d/iptables stop
กำหนดให้ service ไม่ต้อง run ตอน boot (เดี่ยวจะมีการสั่งเองในตัว script):
# chkconfig iptables off
จากนั้นท่านจะใช้คำสั่ง touch หรือ vi, vim อะไรก็ได้ครับสร้างไฟล์ชื่อ firewall ที่ตำแหน่ง /etc/init.d/ ครับมาดูที่ผมทำครับ
# vim /etc/init.d/firewall
โปรแกรม Vim มันจะสร้างไฟล์ให้เราเลยครับเพียงแค่กดปุ่ม i เพื่อเขียนข้อความลงไปครับแต่ไม่ต้องเขียนนะครับให้ท่าน Copy Script ด้านล่างนี้ลงไปวางเลยครับเพราะทางทีมงานของ Lxcenter เค้าจัดให้แล้วครับตามนี้เลย
Copy เิอาไปวางในไฟล์ /etc/init.d/firewall จากนั้นก็กด Esc 1 ครั้งที่แป้นพิมกด : และพิม wq และ Enter เพื่อบันทึกครับ
จาดนั้นก็มาสั่งอีกนิดครับทำให้ firewall script มันทำงานได้ก่อนครับโดยสั่ง
# chmod 700 /etc/init.d/firewall
และเพิ่ม Service firewall ของเราเมื่อกี่ครับ … ยังไงว่ะ งง … ดูด้านล่างครับ
# chkconfig –level 2345 firewall on
และสั่ง Start
# /etc/init.d/firewall start
ถ้าเห็นสถานะบอกว่า OK เยอะก็ใช้ได้แล้วครับง่ายๆ ครับแต่จะธิบายเรื่อง script นิดหนึ่งครับคือ เค้ากำหนดให้ปิด port ทุก port ก่อนแล้วมาเปิด port ที่จำเป็นสำหรับ CP Kloxo ครับแค่นั้นครับ
Write By Mr.Pishit

Read more: http://www.pishit.com/%e0%b8%a7%e0%b8%b4%e0%b8%98%e0%b8%b5%e0%b8%97%e0%b8%b3-firewall-%e0%b8%9b%e0%b9%89%e0%b8%ad%e0%b8%87%e0%b8%81%e0%b8%b1%e0%b8%99-server-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%83%e0%b8%8a%e0%b9%89-cp.html#ixzz1uuHtWA2I

Wednesday, November 23, 2011

วิธีการ ติดตั้ง kloxo version ใหม่ 11/2011

 วิธีการ ติดตั้ง kloxo  version ใหม่  11/2011

# su - root

# setenforce 0

# yum install -y wget

# wget http://download.lxcenter.org/download/kloxo/production/kloxo-installer.sh

# chmod 755 kloxo-installer.sh

# sh ./kloxo-installer.sh master



===============================
เมื่อ ก่อน

# su - root

# setenforce 0

# yum install -y wget

# wget http://download.lxcenter.org/download/kloxo/production/kloxo-install-master.sh

# sh ./kloxo-install-master.sh

Friday, September 30, 2011

kloxo Assigning a Dedicated IP address to your Site

Other Useful Features

Kloxo has many other features that are very useful. Some of the more common and frequently used features are explained below and include assigning a site a dedicated IP address, setting up and SSL certificate, using the "Files" tab and a brief discussion of clients and resellers you can create on your VPS.
NOTE: Your VPS has one IP address assigned to it by default. This is the IP address referenced in your welcome e-mail. If your VPS plan includes more than one IP address you can request additional IP addresses through our ticket system: http://my.a2hosting.com
Please provide the reason for needing the additional IP address in your ticket. We keep documentation on all IP requests to prevent usage that is against our Terms of Service. If you have used all of your available IP you can request additional IP address through the ticket system. Current pricing is $3 per IP per month but is subject to change.

Assigning a Dedicated IP address to your Site

To assign a dedicated IP address to your site, log into Kloxo. From the Home screen click the "Ipaddresses" icon in the "Resources" box.

After clicking on the icon you will be taken to a screen that lists all IP addresses assigned to your VPS. Click on the IP address you wish to assign to a particular domain. You will then be taken to the options screen for that IP address.

Click the "Configure Domain" tab at the top of the page. You will then be presented with something like the following:

Use the drop-down menu to select the domain you wish to assign to the IP address listed in the box above then click "Update".
NOTE: If you have not yet updated DNS for your domain you will receive an error message like the following:
Alert: To map an IP to a domain, the domain must ping to the same IP, otherwise, the domain will stop working. The domain you are trying to map this IP to, doesn't resolve back to the IP, and so it cannot be set as the default domain for the IP.
If you would like to assign your site a dedicated IP BEFORE you update DNS you can do so by adding the following line to /etc/hosts
'192.168.1.1 domain.tld'
You can either edit the file directly or issue a command such as the following:
'echo "192.168.1.1 domain.tld" >> /etc/hosts'
(make sure you use two ">>" or you will overwrite the file.)
In both examples remove the single quotes around the outside and replace the '192.168.1.1' with the IP address you want to assign and "domain.tld" with your domain name.
After you have made this change you can go back and follow the steps for adding the dedicated IP address listed above and you should not receive the error. You cannot assign a dedicated IP address to more than one site. If you do not assign a site a dedicated IP address it will "share" the main IP address on the server by means of virtual hosts in your webserver software (apache/lighttpd). These will be configured automatically by Kloxo.

Installing an SSL Certificate

Through Kloxo you can install an SSL certificate you have already purchased, create a self- signed certificate for personal use or generate a "CSR" (certificate signing request) for ordering a new certificate.
NOTE: In order to install an SSL certificate on a domain it MUST have a dedicated IP address. Only one SSL certificate can be installed per IP address.
Log into Kloxo and go to the Home screen. In the "Resources" box click the SSL Certificates icon.

  1. Uploading a Current SSL Certificate
    1. If you already have an SSL certificate you would like to use click the "Add Upload File" tab. Give the SSL certificate a name; this can be anything you like. Click the "Browse" buttons and upload the Key, Certificate, and CA file (if applicable) then click "Add"
    2. Now click the "SSL Certificates" tab and you should see the SSL certificate you just uploaded in the list.
    3. Assign the domain you wish to configure a dedicated IP address (see instructions above)
    4. Click the "Home" tab then click the "Ipaddresses" icon in the 'Resources' box.
    5. Click the IP address you assigned to the domain you are installing the SSL certificate on then click the "SSL Configuration Home" tab.
    6. Using the drop-down menu select the name of the SSL certificate you uploaded previously then click "Update"
    7. Kloxo should restart Apache (or lighttpd) automatically but if https:// isn't working properly you may need to restart it manually.
  2. Generating a self-signed SSL certificate
    1. Log into Kloxo and go to the Home screen. In the "Resources" box click the SSL Certificates icon.
    2. Click the "Add SSL Certificate" tab
    3. Give the SSL certificate a name and fill in the appropriate information in the boxes. Please keep in mind that an ssl certificate for "www.domain.com" is different from just "domain.com" so be sure to specify version of your domain you want the SSL certificate on. Click the "Add" button once you have filled in the appropriate information.
    4. Assign the domain you wish to configure a dedicated IP address (see instructions above)
    5. Click the "Home" tab then click the "Ipaddresses" icon in the 'Resources' box.
    6. Click the IP address you assigned to the domain you are installing the SSL certificate on then click the "SSL Configuration Home" tab.
    7. Using the drop-down menu select the name of the SSL certificate you uploaded previously then click "Update"
    8. Kloxo should restart Apache (or lighttpd) automatically but if https:// isn't working properly you may need to restart it manually.
  3. Generating a CSR to order a new SSL certificate from a certificate authority
    1. You can purchase SSL certificates through A2 Hosting. To view current offerings please see http://www.a2hosting.com/services/ssl-hosting You can submit a ticket to our billing department to order an SSL certificate.
    2. If you just need a CSR for use with an outside provider, log into Kloxo and go to the Home screen. In the "Resources" box click the SSL Certificates icon.
    3. Click the "Add SSL Certificate" tab
    4. Give the SSL certificate a name and fill in the appropriate information in the boxes. Please keep in mind that an ssl certificate for "www.domain.com" is different from just "domain.com" so be sure to specify version of your domain you want the SSL certificate on. Click the "Add" button once you have filled in the appropriate information.
    5. Click on the "SSL Certificates" tab then click on the name of the SSL certificate you just created.
    6. The CSR will be listed in the middle of the screen. You can copy and paste the CSR (be sure to include the ----- BEGIN ----- and -----END----- lines) into your outside providers request form.

The "Files" Tab

You can use the "Files" tab as an alternative to FTP or SFTP to upload or download files to/from your site. You can also zip files or folders for smaller download, upload files from your home computer, a remote URL, or remote FTP server (the last 2 are great for transferring your data from your old hosting account).
The files tab does not require much explanation. Just click on the "Files" tab and use the File Manager tab to navigate your files then view/download current files or use the Upload tab to add files to your site. All uploaded files will be placed in "/home/admin"

Clients and Resellers

There are two types of clients; Resellers and customers. The main difference is Resellers can have customers under them. The smallest unit of authorization in Kloxo is a customer, who can have multiple domains under them.
In order to setup a Reseller or Client you will need to create a Resource Plan. A resource plan determines how many clients a reseller can have, how many domains can be hosted, traffic allowed, disk space allowed and much more.
If you are hosing multiple sites for different clients and wish to give them access to their content you can add a client login so they can modify their web content but no one else's.
The home directory of a customer is '/home/clientname', and his domain's document root is /home/clientname/domain.com'. He can also login through ftp using his clientname as the id and the password.

Tuesday, September 13, 2011

วิธีการใช้งาน date selector ด้วย PopCalendarXP เพื่อรองรับกับวันที่ MySQL


PopCalendarXP เป็นของฟรีอีกแล้วครับ ผมเอามาใช้กับโค้ด php ซึ่งเปลี่ยนให้เป็นภาษาไทยเรียบร้อยแล้ว เหลือแต่ปีที่ยังเป็นคริสศักราช อยู่ ทำเป็นปีไทยไม่เป็นแต่ก็พอใช้งานได้ครับ ใครสนใจรายละเอียดเพิ่มเติมก็เวปนี้เลย www.calendarxp.net/

วิธีใช้น่ะครับ
  • unzip ไฟล์ออกมาแล้วไปวางในเวปpath ของ server เช่น ของผมวางไว้ที่
    C:\AppServ\www\date1\

  • ใน โฟลเดอร์ date1 ผมจะสร้างไว้ สองไฟล์ไว้ test น่ะครับคือ date01.php และ date02.php ซึ่งสองไฟล์นี้ก็ใช้ dreamweaver สร้างมาครับง่ายดีและจะมีโฟลเดอร์ PopCalendarXP ซึ่งเป็นไฟล์ที่ผมโหลดมาและแก้เป็นภาษาไทยเรียบร้อยแล้ว
  • ลองรันตามนี้น่ะครับ http://localhost/date1/date01.php
  • ซึ่งวิธีการ install ผมขอสรุปคร่าวๆดังนี้น่ะครับ
  1. สร้าง form ขึ้นมาและสมมุติตั้งชื่อ form เป็น testform
  2. สร้าง text field ขึ้นมาและสมมุติตั้งชื่อว่า dc
  3. ให้นำโค้ดนี้วางไว้หลังคำสั่ง text field
    <a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(document.testform.dc);return false;" ><img class="PopcalTrigger" align="absmiddle" src="PopCalendarXP/calbtn.gif" width="34" height="22" border="0" alt=""></a> 
    
    

  4. สังเกตในโค้ดตรง (document.testform.dc) จะเห็นว่า form_name.textfield_name จะต้องเหมือนกันกับที่เราตั้งไว้น่ะครับซึ่งหากเราต้องการใช้งาน selector หลายตัวใน form เดียวกันเราก็แค่เปลี่ยนเฉพาะชื่อ text field ให้ต่างกันก็พอครับซึ่งในโค้ด date01.php ผมจะใช้เป็น (document.testform.dc)และ (document.testform.dc1)เพื่อใช้ตัว selector สองตัว
  5. ลืมขั้นตอนสุดท้ายก็ต้องเอาโค้ดข้างล่างนี้น่ะครับไปวางไว้ก่อนtag </body> นะครับ
    <!--  PopCalendar(tag name and id must match) Tags should not be enclosed in tags other than the html body tag. -->
    <iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="PopCalendarXP/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;">
    </iframe>
    

ซึ่งเท่านี้เราก็จะได้การส่งค่าวันที่ไปเก็บลงในฐานข้อมูลแบบdefault ของMySQL เรียบร้อยครับ
โหลดโค้ดทั้งหมดได้ที่นี่ครับ date1.zip

Fusionchart+PHP+MySQL แบบทีละ Step คับ

วิธีการแสดงกราฟ Fusionchart v.3 โดยดึงข้อมูลมาจากฐานข้อมูล MySQL โดยใช้ภาษา PHP ครับ

step1. เริ่มจากสร้างฐานข้อมูลที่ชื่อ fusion-test [Download] และสร้างตารางที่ชื่อ data1 และเพิ่มข้อมูลลงไปตามรูปครับ


step2. โหลดกราฟ [download] และ unzip ไว้ในเวป root โดยของผมจะเก็บไว้ที่นี่ C:\AppServ\www\FusionCharts_Evaluation\ จากนั้นก็ลองเรียกดูเลยครับตาม path นี้
http://localhost/FusionCharts_Evaluation/Code/PHP/DBExample/Default.php
ถ้ารันได้แบบนี้ก็โอเคแล้วครับ


หมาย เหตุ กราฟที่ผมให้โหลดเป็นตัวที่ผมตัดบางส่วนออกเอาเฉพาะไฟล์ที่เกี่ยวข้องเท่า นั้นและแก้ไขเรียบร้อยแล้วน่ะครับโดยใครอยากโหลดเอาไฟล์ทั้งหมดทุกภาษา สามารถโหลดได้ที่เวปนี้ www.fusioncharts.com

โดยกราฟที่ผมต้องการแสดงคือ แสดงจำนวนที่เหลือของสินค้าแต่ละประเภท
ไฟล์ที่ผมแก้ไขมีตามนี้ครับ
1.ไปที่ C:\AppServ\www\FusionCharts_Evaluation\Code\PHP\Includes แก้ไฟล์ DBConn.php ตามนี้
$hostdb = 'localhost';   // MySQl host
    $userdb = 'root';    // MySQL username
    $passdb = 'Your-Password';    // MySQL password ถ้าไม่มีก็ใส่ ''
    $namedb = 'fusion-test'; // MySQL database name


2.ไปที่ C:\AppServ\www\FusionCharts_Evaluation\Code\PHP\DBExample แก้ไฟล์ Default.php ตามนี้
$strQuery = "select distinct(type) as type_name , sum(amount) as count_amt from data1 group by type_name";

            $strXML .= "<set label='" . $ors2['type_name'] . "' value='" . $ors2['count_amt'] . "' />";


และหากต้องการเปลี่ยนกราฟแท่งก็แค่แก้ตรงคำสั่ง เปลี่ยนจาก Pie3D.swf เป็น Column3D.swf ตามนี้
echo renderChart("../../FusionCharts/Column3D.swf", "", $strXML, "FactorySum", 600, 300, false, false);



ที่ต้องแก้หลักๆก็มีแค่นี้ครับ คือ query คำสั่งใหม่ แล้วก็ set ค่า label เพื่อส่งค่า xml ให้ตรงกับ query ไปยังตัวกราฟ
เสร็จแล้วค๊าบ ง่ายป่าว อิอิ

Kloxo error "Some of Horde's configuration files are missing or unreadable conf.php"

Kloxo error "Some of Horde's configuration files are missing or unreadable conf.php"

วันนี้ติดตั้ง kloxo ใหม่ ปรากฏว่า webmail ทั้ง Horde และ RoundCube ใช้ไม่ได้ ขึ้น error ทั้งคู่

Error ของ Horde
"Some of Horde's configuration files are missing or unreadable conf.php"

ลองค้นหาวิธีแก้ไขใน LxCenter พบทางแก้ที่ได้ผลคือใช้คำสั่ง

chmod 644 /home/kloxo/httpd/webmail/horde/config/conf.php

ปัญหาคือไฟล์ conf.php ได้เปลี่ยน Permission เป็น 600 ทำให้ใช้งานไม่ได้

Error ของ RoundCube
Roundcube had "Configuration Error: db.inc.php"

ปัญหาเกิดขึ้นอย่างเดียวกันคือ Permission ของ db.inc.php เป็น 600
ทางแก้ก็ใช้ putty เข้าไปใช้คำสั่ง

chmod 644 /home/kloxo/httpd/webmail/roundcube/config/db.inc.php

วิธีติดตั้ง MTRG บน Kloxo

เป็นหนึ่งในเทคนิคที่ผมนำมาเพิ่มความสามารถให้แก่ VPS(Linux) ที่ใช้ Control Panel Kloxo Lxadmin
ซึ่ง ถ้า VPS ที่เราเช่ามาเป็นแบบไม่มี Control Panel สำหรับดู Status ต่างๆของ VPS  มันก็เป็นเรื่องลำบากพอสมควร ที่เราจะเช็คว่า VPS หรือ Server ของเรา ใช้งาน CPU, RAM, Traffic , Connections ไปมากน้อยแค่ไหน

จริงแล้วๆ มีโปรแกรมอื่นๆที่นิยมใช้กันอีกนอกจาก MRTG อย่าง Munin ก็แสดงผลได้ละเอียดดีเหมือนกัน

ก่อนอื่นก็เข้า Shell ก่อนนะครับ แล้วก๊อบคำสั่งไปใช้งานได้เลยครับ

- ติดตั้ง mrtg ก่อน
yum -y install net-snmp net-snmp-utils mrtg
cd /etc/snmp/
mv snmpd.conf snmpd.conf.bak
nano snmpd.conf


- แก้ไข Config โดยการก๊อบข้างล่างไปวางใน text editor เลยครับ
syslocation  Thailand
syscontact  admin
sysservices 79
rocommunity  snmp 127.0.0.1
agentaddress  127.0.0.1


chkconfig snmpd on
/etc/init.d/snmpd start


- สร้าง Directory ที่ใช้ในการทำงานของ mrtg
mkdir -p /home/kloxo/httpd/default/mrtg
cd /etc/mrtg/


- แก้ไข Config ของ mrtg
mv mrtg.cfg mrtg.cfg.bak
nano mrtg.cfg


- คำโค้ดไฟล์การตั้งค่าไปใส่ใน text editor
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt,/usr/share/snmp/mibs/UDP-MIB.txt
WorkDir: /home/kloxo/httpd/default/mrtg
Options[_]: growright
EnableIPv6: no
Target[server.traffic]: 2:snmp@127.0.0.1:::::2
SetEnv[server.traffic]: MRTG_INT_IP="eth0" MRTG_INT_DESCR="eth0"
MaxBytes[server.traffic]: 125000000
Title[server.traffic]: Traffic Load
PageTop[server.traffic]: <h1>Traffic Load</h1>
Options[server.traffic]: growright, bits

#
# Memory Monitoring (Free with Buffer,/Cache/Total)
#
Target[server.memory]: memTotalSwap.0&memAvailReal.0:snmp@127.0.0.1 + PseudoZero&memBuffer.0:snmp@127.0.0.1 - memAvailSwap.0&PseudoZero:snmp@127.0.0.1
Title[server.memory]: Free Memory
PageTop[server.memory]: <H1>Free Memory</H1>
MaxBytes[server.memory]: 1044480000
ShortLegend[server.memory]: KBytes
YLegend[server.memory]: KBytes
LegendI[server.memory]: Swap inused
LegendO[server.memory]: Free Memory
Legend1[server.memory]: Swap inused
Legend2[server.memory]: Free memory inc Buffer
Options[server.memory]: growright,gauge,nopercent
#kMG[server.memory]: k,M,G

#
# CPU Monitoring
# (Scaled so that the sum of all three values doesn't exceed 100)
#
 
Target[server.cpu]: ssCpuRawUser.0&ssCpuUser.0:snmp@127.0.0.1 + ssCpuRawSystem.0&ssCpuSystem.0:snmp@127.0.0.1
Title[server.cpu]: Server CPU Load
PageTop[server.cpu]: <H1>CPU Utilization</H1>
MaxBytes[server.cpu]: 100
ShortLegend[server.cpu]: %
YLegend[server.cpu]: % CPU#Legend1[server.cpu]: Current CPU Idle
Legend1[server.cpu]: Accurate CPU Load
Legend2[server.cpu]: Current CPU Load
#LegendI[server.cpu]: Percentage CPU Idle
LegendI[server.cpu]: Accurate CPU Load
LegendO[server.cpu]: Current CPU Load
Options[server.cpu]: growright,nopercent,gaugeUnscaled[server.cpu]: ymwd
 #
# Load Average 1 & 15 min
# (Scaled so that the sum of all three values doesn't exceed 100)
#
Target[server.load]: laLoadInt.3&laLoadInt.1:snmp@127.0.0.1
Title[server.load]: Load Average at 15 and 1 Min
PageTop[server.load]: <H1>Load Average</H1>
MaxBytes[server.load]: 10000
ShortLegend[server.load]: #
YLegend[server.load]: #Load
Legend1[server.load]: Current CPU load (15 Mins)
Legend2[server.load]: Current CPU load (1 Mins)
LegendI[server.load]: Load 15 Mins
LegendO[server.load]: Load 1 Mins
Options[server.load]: growright,nopercent,gauge

#
# New TCP Connection Monitoring (per minute)
#
 
Target[server.newconns]: tcpPassiveOpens.0&tcpActiveOpens.0:snmp@127.0.0.1
Title[server.newconns]: Newly Created TCP Connections
PageTop[server.newconns]: <H1>New TCP Connections</H1>
MaxBytes[server.newconns]: 65536
ShortLegend[server.newconns]: c/sYLegend[server.newconns]: Conns / Min
LegendI[server.newconns]: In
LegendO[server.newconns]: Out
Legend1[server.newconns]: New inbound connectionsLegend2[server.newconns]: New outbound connectionsOptions[server.newconns]: growright,nopercent,perminute#Unscaled[server.newconns]: ymwd
#kMG[server.newconns]: k,M,G,T,P,X  
 #
# Established TCP Connections
#
 Target[server.estabcons]: tcpCurrEstab.0&tcpCurrEstab.0:snmp@127.0.0.1
Title[server.estabcons]: Currently Established TCP Connections
PageTop[server.estabcons]: <H1>Established TCP Connections</H1>
MaxBytes[server.estabcons]: 65536
ShortLegend[server.estabcons]: #
YLegend[server.estabcons]: Connections
LegendI[server.estabcons]: In/Out
LegendO[server.estabcons]: Legend1[server.estabcons]: Established connectionsLegend2[server.estabcons]: Options[server.estabcons]: growright,nopercent,gauge


- สุดท้าย
indexmaker --columns=2 --output=/home/kloxo/httpd/default/mrtg/index.html /etc/mrtg/mrtg.cfg


การเรียกใช้งาน เรียกผ่าน ip server/vps ของคุณ http://xxx.xxx.xxx.xxx/mrtg

Posted Image


หวังว่าคงเป็นประโยชน์ครับ

 
Design by Laikeng | Bloggerized by Storesu - sutoday | Court