จูน apache + mysql

มิถุนายน 16th, 2010

คำแนะนำเบื่องต้นนะครับ ไม่รู้ว่าจะดีหรือเปล่าไม่เคยลอง แต่จากประสบการณ์ก็โอเคดีครับ

1. CPU ดีแล้ว แต่ RAM ควรเพิ่มให้มากที่สุดเท่าที่จะสามารถทำได้
2. ปรับแต่ง my.cnf อันนี้ของผมสำหรับ RAM GB ของคุณอาจจะปรับแต่งตามความเหมาะสม

[mysqld]
init-connect='SET collation_connection = tis620_thai_ci'
init-connect='SET NAMES tis620'
default-character-set=tis620
character-set-server=tis620
collation-server=tis620_thai_ci
skip-name-resolve
#skip-networking
#skip-bdb
innodb_data_file_path = ../../ibdata/ibdata1:10M:autoextend
max_connections = 500
key_buffer = 384M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 2M
sort_buffer_size = 4M
table_cache = 1536
thread_cache = 8
thread_concurrency = 4
thread_cache_size = 256
wait_timeout = 600
connect_timeout = 10
max_tmp_tables = 256
tmp_table_size = 64M
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 32M
query_cache_type = 1
query_prealloc_size = 16384
query_alloc_block_size = 16384
max_heap_table_size = 256M
#datadir=/usr/local/mysql
#socket=/var/lib/mysql/mysql.sock
#innodb_data_file_path=ibdata1:10M:autoextend
#log_slow_queries
log_queries_not_using_indexes

3. เปลี่ยนการทำงานของ apache เป็น mpm-workers (compile ใหม่ได้เลย) เพราะว่า apache จะใช้งาน RAM น้อยลงมาก RAM ที่เหลือจะได้ใช้ไปกับ mysql

4. ติดตั้งพวก Cache ให้กับมัน ได้แก่ APC หรือ X-cache

5. ตรวจสอบการใส่ index ให้กับ Database แก้ในไฟล์ my.cnf ที่ผมให้ไป เอาเครื่องหมาย # ออกจาก ตรง #log_slow_queries จากนั้นให้อ่านไฟล์ log โโยใช้คำสั่ง tail -f hostname-slow.log ซึ่งจะอยู่ใน folder mysql นั้นเอง เมื่อเจอว่าตารางไหนไม่ใส่ index ก็ไปใส่ซ่ะนะ

ุ6. ลดปริมาณการเรียกไปยัง apache โดยเฉพาะไฟรูปภาพด้วย squid คือก่อนที่จะเข้าสู่ apache ให้มันผ่าน squid ก่อน เพราะว่า squid เปรียบเสมือน cache ที่ทำหน้าที่เอาไฟล์ที่ถูกเรียกซ้ำๆ ส่งให้ และยังมีข้อดีอีคือสามารถป้องกันการโจมตีเช่นการถูกยิงเว็บได้เป็นอย่างดี ด้วย ทำให้ traffic ที่ผ่านไปถึง apache เป็น traffic ที่บริสุทธิ์

7. อาจจะลองติดตั้ง php fast-cgi เพิ่มเติมด้วยเพื่อให้เราสามารถจำกัดการทำงานของแต่ละ user ที่ run web ได้ การติดตั้งดูที่บล็อกของคุณ icez http://www.icez.net/blog/389/directadmin-mod_fcgid-php-fastcgi

แก้ encoding ของ template เป็น utf-8 ครับ

มิถุนายน 15th, 2010

แก้ encoding ของ template เป็น utf-8 ครับ

nano -w /usr/local/directadmin/data/skins/enhanced/lang/en/lf_standard.html

แก้ ตรง

LANG_ENCODING

เปลี่ยนเจ้าของไฟล์ทั้งโฟลเดอร์

พฤษภาคม 5th, 2010

chown -R user:user /path

Change hostname in Linux

พฤษภาคม 4th, 2010

http://www.scriptinstallation.in/linux_change_hostname.html

First you need to find out your hostname, you can do this with

$ hostname
localhost.localdomain
$

Edit /etc/hosts

You need to edit /etc/hosts and add a line for your host name

$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
$

My new server IP is 72.232.196.90, i need to assign it hostname server12.hosthat.com, to do this, i have edited /etc/hosts as follows.

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
72.232.196.90           server12.hosthat.com server12

Edit /etc/sysconfig/network

First lets see what is in the file

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
$

To change servers hostname to server12.hosthat.com, change the file as follows.

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server12.hosthat.com
$

Now you need to reboot the server to change the hostname.

รหัสผ่านเริ่มแรกของ Admin เมื่อติดตั้ง DirectAdmin เสร็จ

พฤษภาคม 4th, 2010

/usr/local/directadmin/scripts/setup.txt

ส่วนรหัสผ่าน admin หากเปลี่ยนไป จำไม่ได้ ก็เข้าเป็น root แล้วก็
passwd admin  ได้เลยครับ

เปลี่ยน Hostname

พฤษภาคม 4th, 2010

แก้ /etc/hosts และ /etc/sysconfig/network

แล้ว reboot ซักรอบ

ตัวอย่าง

nano /etc/hosts 192.168.1.1 server.domain.com server

nano /etc/sysconfig/network HOSTNAME=server.domain.com

เปลี่ยน password root ใน linux

พฤษภาคม 4th, 2010

passwd root

copy file ข้าม Server ที่เป็น Linux ด้วยกันทั้งคู่ หรือไปยังที่อื่น

เมษายน 30th, 2010

copy file ข้าม Server ที่เป็น Linux ด้วยกันทั้งคู่ หรือไปยังที่อื่น

ลอง คำสั่ง rsync หรือ rpc ดูนะครับ

ถามจากคุณพี่ google

1. scp (secure copy)

รูปแบบที่แนะนำ

scp filename username@my.privateip.addr:/path/

เช่น scp id_rsa.pub dumper@my.server.ip.addr:/home/dumper/ เป็นต้น

สำหรับ กรณีที่ต้องการ copy เป็น folder ให้ zip folder ก่อน โดยการใช้

2. คำสั่ง tar

เช่น tar -cvf bk20080823.tar 20080823

c คือ สร้างไฟล์ tar ขึ้นมา

v คือ ให้แสดงชื่อไฟล์ที่กำลัง zip

f คือ ตำแหน่งที่ต้องการสร้างไฟล์ tar

bk20080523.tar คือ ชื่อไฟล์ที่เกิดจากการ zip ด้วยคำสั่ง tar

แค่นีก็ได้ไฟล์ที่ zip แล้ว พร้อมจะส่งไปยังที่อื่นได้แล้วค่ะ และใครที่ต้องการ backup files ก็สามารถนำไปประยุกต์ใช้ได้ด้วย

เพิ่มเติมการใช้งาน scp อย่างง่ายอีกหน่อย

ถ้าคุณใช้ linux ก็ดู manual แบบเต็มๆ เลยด้วยคำสั่ง man scp หรือถ้าขี้เกียจดู ก็เดี๋ยวจะยกตัวอย่างไว้สัก 3 อัน ง่ายๆ ไม่ซับซ้อน ที่ผมใช้บ่อย

[1] scp /path/to/file/myLocalFile.tgz dumper@my.server.ip.addr:/home/dumper/myBackUpDir/
จะเป็นการ upload ไฟล์จาก local ขึ้นไปเก็บไว้ที่ server ด้วยชื่อเดียวกัน

[2] scp dumper@my.server.ip.addr:/home/dumper/myTmpBackUpDir/myServerFile.tgz /path/to/file/myServerFile.tgz
จะเป็นการดาวน์โหลดไฟล์จาก server ลงมาไว้ที่ local ด้วยชื่อเดียวกัน

[3] scp dumper@my.server.ip.addr:/home/dumper/myTmpBackUpDir/file1.tgz /path/to/file/file2.tgz
จะเป็นการดาวน์โหลดไฟล์จาก server ลงมาไว้ที่ local โดยเปลี่ยนชื่อไฟล์ด้วย สามารถใช้ได้กับทั้งข้อ [1] และ [2]

copyy ทั้งโฟลเดอร์

scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/

เปิดใช้งาน http://xxx.xxx.xxx.xxx/server-status

เมษายน 30th, 2010

แก้ไข /ect/httpd/conf/httpd.conf
เพิ่ม Mod status ลงไป ล่างสุดเลย

<Location /server-status>
SetHandler server-status
Order Deny,Allow
#Deny from all
Allow from all
</Location>
ExtendedStatus On

เซฟไฟล์ แล้ว รีสตาร์ท httpd  จากนั้นเข้าดูผลที่ http://xxx.xxx.xxx.xxx/server-status

ใน da จะมี conf ไฟล์ให้แล้วที่ /etc/httpd/conf/extra/httpd-info.conf

DA เข้า File Manager ไม่ได้

เมษายน 18th, 2010

DA เข้า File Manager ไม่ได้

เพิ่ม…
filemanager_du=0
ลงใน /usr/local/directdamin/conf/directadmin.conf

อ้างอิง: http://www.directadmin.com/features.php?id=678