Category: Linux

forget mySQL root password

By สุดเดช, 19 กรกฎาคม 2010 15:31

หายหน้าไปน๊านนาน หลายท่านคงนึกว่าคนเขียน ม่องไปล่ะ
ป่าวครับไปเตรียมตัวกับหุ้นส่วน(เพื่อนกาก) เตรียมเปิด กิจการที่ถนัด กันอยู่
ซักพักคงได้เห็นกันวันนี้ก็มีปัญหา แล้วก็หาข้อมูลจนทำได้เลยนำมาให้เพื่อน ๆ ดูน่ะครับ
เป็นปัญหาของตัว mysql ที่มีคนแย่งไป (ได้ยังไงไม่รู้) เลยต้องไปเอาคืนมาเพื่อให้มันทำงานได้ปกติสุข
วันนี้เลยเป็นวันที่ แจ่มอุราอีกวัน ทำงานได้อย่างฟลุ๊ก ๆ  :D จัดไปลุ๊ยยย
เพิ่ม ลงไปในไฟล์ my.cnf ตามตัวอย่าง

[mysqld]
skip-grant-table 

จากนั้นให้ restart service mysql
ต่อด้วยคำสั่ง

mysqladmin -u root flush-privileges password "$password"

จากนั้นเข้าไปที่ mysql โดยการพิมพ์

mysql 

พอเข้ามาใน mysql แล้ว
ให้เลือก database mysql โดยคำสั่ง

use mysql

ตามด้วยสองคำสั่งนี้

UPDATE user SET password='$password' WHERE user='root';
GRANT ALL PRIVILEGES ON mysql TO root @'%' IDENTIFIED BY 'localhost';

จากนั้นก็ออกจากโปรแกรม แล้ว ลบ skip-grant-table ออกจาก ไฟล์ my.cnf
แล้วสั่ง restart mysql

จากนั้นก็ จัดได้เลยครับแจ่ม

หมายเหตุ : ต้องใช้สิทธิ์ su , root ทำงานเท่านั้น OS ที่ทำการทดสอบ คือ debian-linux-gnu
$password = รหัสผ่านของคุณ

Bookmark and Share

วิทยุออนไลน์ – ShoutCast

By สุดเดช, 24 กรกฎาคม 2009 15:17

วันนี้ก็โดดงานมานั่งหาข้อมูลทำ วิทยุออนไลน์
และแล้วก็พบหนทางที่จะจัดตั้งสถานีแล้ว
ก็ไม่รอช้าคับ จัดเพลงทันที แต่ตอนนี้ยังอยู่ในช่วง ปรับปรุงระบบครับ
เอา Bit rate กันสูง ๆ ไปเลย ฮิ้ว ๆ
ฟังได้จาก ลิงค์นี้คับ

http://202.44.52.82:8000/listen.pls

ให้เครดิตเว็บ ผู้ที่ค้นผบก่อน

นี่คับ http://sorawee.bangpreang.com/?p=379
ลงค์ อื่น ๆ ตามกันเองน่ะคับ ผมตามหาไม่เจอต้นฉบับขอรับ

แล้วนี้ก็เนื้อหาที่ทำคับ เพื่อทำครั้งต่อไป ก็จะได้ไม่ลืมขอรับ เอามาเก็บไว้ในเว็บผม เหอะ ๆ

มาทำสถานีวิทยุออนไลน์กัน

ช่วงที่ podcast กำลังฮิตๆ และ winamp กำลังบูม (ทุกวันนี้ผมไม่ได้ใช้ winamp แล้วใช้แต่ Amarok) NullSoft ปล่อยตัว streaming server มาตัวหนึ่งชื่อ Shoutcast ซึ่งการทำงานของเจ้าตัวนี้มีหน้าที่กระจายข้อมูลเพลงที่ส่งจากตัว broadcaster ซึ่งอาจจะเป็น winamp หรือโปรแกรม streamer ในเครื่องเซิร์ฟเวอร์เองก้อได้ Shoutcast มีคนนิยมใช้กันมากเพราะโปรแกรมมีขนาดเพียงแค่ 133k เท่านั้น แถมยังใช้บน Windows, Linux, Mac ได้อีกด้วย

หลักการทำงานของการทำ streaming broadcast เราจะต้องมีตัวกระจายสัญญาณ (broadcaster) ตัวส่งสัญญาณ (streamer) อ้อที่ลืมไม่ได้คือ คนฟัง (client) ที่ใช้โปรแกรมเล่นเพลงที่สามารถฟัง streaming broadcast ได้ เจ้าตัว SHOUTcast เป็นของค่าย Nullsoft ถูกออกแบบมาให้ใช้กับ Winamp และยังใช้โปรแกรมฟังเพลงอื่นๆ ได้เช่นกัน อย่าง Amarok, Kaffeine ก้อฟังได้ เพราะข้อมูลที่ส่งมาจาก Shoutcast นั้นเป็นเนื้อหาไฟล์ MP3 นอกจากความสามารถในการกระจายสัญญาณแล้ว ยังสามารถปรับคุณภาพของสัญญาณเสียงได้ เช่น broadcast ที่ 16k,48k เป็นต้น มาพูดถึงตัวส่งสัญญาณหรือ stremer กันบ้าง สาวก Winamp ก้อไม่ต้องเป็นกังวลไปเพราะ Nullsoft ได้ออกโปรแกรม DSP Plug-in สำหรับทำเป็นตัวแปลสัญญาณและส่ง stream ไปยัง broadcaster ได้ทำให้การทำวิทยุออนไลน์ของเราง่ายขึ้น ถ้า client เป็น Linux หรือ Mac จะทำยังไงล่ะ? ไม่ต้องตกใจไปครับ Nullsoft ได้ออกโปรแกรมมาให้ใช้เช่นเดียวกัน เป็นโปรแกรมเล็กๆ เล่นบน command line

เตรียมตัวกันก่อน หากคุณใช้ Windows และต้องการให้ Windows ของคุณเป็น broadcaster ให้ดาวน์โหลด SHOUTcast สำหรับ Windows มาติดตั้ง ผมไม่ขอพูดถึง Windows นะครับ สำหรับ Linux ก้อดาวน์โหลดเวอร์ชั่นสำหรับ Linux มาครับ ที่ http://www.shoutcast.com/downloads/sc1-9-8/sc_serv_1.9.8_Linux.tar.gz เมื่อได้ไฟล์มาแล้วให้คลี่ไฟล์ sc_serv_1.9.8_Linux.tar.gz ออกมาด้วยคำสั่ง

#mkdir /opt/sc_serv
#tar zxvf sc_serv_1.9.8_Linux.tar.gz -C /opt/sc_serv

จากนั้นแก้ไขข้อมูลใน sc_serv.conf ในส่วน Requirement ได้แก่

MaxUser เป็นการกำหนดจำนวนผู้ฟังมากที่สุดกี่คน มีวิธีการคำนวณง่ายๆ คือ ถ้าคุณใช้ ADSL 256kbps และ broadcast เพลงที่ 24kbps ให้กำหนดจำนวน MaxUser = 256kbps/24kbps = 10 คน ที่ต้องกำหนดเช่นนี้เพราะต้องการไม่ให้ช่องสัญญาณ busy เกินไปและให้จำนวนคนฟังเหมาะสมกับขนาดของข้อมูลที่ส่งไปด้วย

Password ในส่วนนี้เป็นการกำหนดรัสผ่านสำหรับ streamer ที่ต้องการส่ง stream มายัง broadcaster นี้
PortBase กำหนด port ที่จะใช้ในการสื่อสารค่าปริยายคือ 8000 หากต้องการเปลี่ยนให้กำหนดตัวเลขสูงกว่า 1024 ครับ

เมื่อพร้อมแล้วก้อ start broadcaster ของเราได้แล้วโดยใช้คำสั่ง

#/opt/sc_serv/sc_serv &

กลับมาเตรียมโปรแกรมส่ง stream ของเราครับ หาท่านใช้ Winamp บน Windows ดาวน์โหลด Plug-In ไปติดตั้งได้เลยครับ และพร้อมส่งได้เลยเมื่อคุณเล่นไฟล์เพลง หากเป็น Linux, Mac และอื่นๆ ต้องใช้้ sc_trans ซึ่งเป็นตัวส่ง stream บน Linux ดาวน์โหลดได้ที่ http://www.shoutcast.com/downloads/sc_trans_posix_040.tgz เมื่อได้ไฟล์มาแล้ว คลี่ไฟล์ออกโดยใช้คำสั่ง

#tar zxvf sc_trans_posix_040.tgz -C /opt

แก้ไขไฟล์ sc_trans.conf ดังนี้

PlaylistFile คือ ไฟล์รายการเพลงที่ต้องการเล่นและส่งข้อมูลไปให้ broadcaster ค่าปริยายคือ example.lst ให้คุณแก้ไขเป็นชื่อของคุณเองครับ เช่น playlist.lst เป็นต้น

ServerIP คือ domainname หรือ IP Address ของตัว broadcaster
ServerPort คือ หมายเลขพอร์ตที่ใช้ในการสื่อสาร ค่าปริยายคือ 8000

StreamTitle คือ ชื่อรายการ streaming ของคุณครับ เช่น DJ Ja Ja
StreamURL คือ URL ที่ผู้ฟังจะฟัง stream ของคุณได้ เช่น http://radio.dj-jaja.com:8000
Genre คือแนวเพลงของคุณ เช่น Rock, POP, R&B เป็นต้น

Shuffle คือกำหนดให้สุ่มเล่นเพลง ค่าปริยายเป็น 1 หากไม่ต้องการสุ่มเล่นเพลงให้ใส่ 0 ครับ

Bitrate คือจำนวนบิตในการส่ง ค่าปริยายคือ 8000 (8kbps)
SampleRate คือสัญญาณเสียง ค่าปริยายคือ 11025 (11Khz)
Channels คือจำนวน Channel ค่าปริยายคือ 1 (Mono)

มีค่าสำเร็จมาให้แล้วดังนี้

; Bitrate/SampleRate/Channels recommended values:
; 8kbps 8000/11025/1
; 16kbps 16000/11025/1
; 24kbps 24000/22050/1
; 32kbps 32000/22050/1
; 64kbps mono 64000/44100/1
; 64kbps stereo 64000/22050/2
; 96kbps stereo 96000/44100/2
; 128kbps stere0 128000/44100/2

Qulity คือกำหนดค่าคุณภาพเสียง 1-10 หมายเลข 1 คือดีที่สุด ส่วน 10 ก้อแย่สุด

CrossfadeMode กำหนดให้เล่น crossfade ค่าปริยายคือ 1
CrossfadeLength ช่วงในการ crossfade ค่าปริยายคือ 800ms

UseID3 ใช้ข้อมูล ID3 ของไฟล์ ค่าปริยายคือ 0 ไม่ได้ใช้ข้อมูล ID3

AIM, ICQ, IRC กำหนดค่า AIM, ICQ และ IRC เอาไว้ให้ผู้ฟังคุยกับ DJ

เมื่อตั้งค่าได้ตามใจแล้ว มาสร้าง list เพลงสำหรับเล่นและส่งไปยัง broadcaster กันครับ โดยใช้คำสั่ง

#find /home/mp3 -type f -name “*.mp3″ > /opt/sc_trans_040/playlist.lst

สมมุติว่าผมเก็บไฟล์ mp3 ที่เรียงเพลงไว้แล้วใน dir /home/mp3 นะครับ จากนั้นสั่งให้ sc_trans ส่ง stream ให้เราครับ

#/opt/sc_trans_040/sc_trans_linux &

แต่ยังไม่จบครับ ผมเกิดเจอปัญหาปิดโปรแกรมไม่ได้ แต่ก็เหนือเกิน ฟาม สามารถ
นี่เลยคับ คำสั่งนี้ เพื่อดู PID มัน แล้วก็จัดการ Kill ALL ให้หมด

pgrep sc_serv

ให้คุณใช้ browser ไปยังโดเมน broadcaster ของคุณครับ เช่น http://radio.dj-jaja.com:8000 คุณจะพบว่า sc_serv ที่ run ไว้แล้วจะแสดงรายชื่อเพลงที่กำลังเล่น รอคนฟังอยู่แล้ว ถ้าต้องการฟังเพลงก้อเพียงแค่คลิกท่ เมนู Listen หรือใช้โปรแกรมฟังเพลงอย่าง Winamp, Kaffeine หรือ Amarok ชี้ไปยัง http://radio.dj-jaja.com:8000 ครับ

Bookmark and Share

Crontab backup database

By สุดเดช, 27 กุมภาพันธ์ 2009 15:16

จากเมื่อวาน << คลิ๊กเพื่อดูเรื่องที่ต่อเนื่อง

วันนี้จะบอกวิธีการติดตั้ง Crontab กันน่ะคับ
เริ่มจากการสร้างไฟล์ Crontab ขึ้นมาก่อนน่ะคับ

15 4 * * * php -q /home/backup/rbackup.php > /dev/null 2>&1

backup_crontab

ความหมายของมันก็คือ ทุก ๆ วัน เวลา ตี 4.15 ให้ทำการ รัน สริปต์ ที่ชื่อว่า rbackup.php
เมื่อสร้างเสร็จแล้ว คราวนี้ก็มาดูผลการทำงาน ของ script กันน่ะคับ

backup_ssh

backup_mail2

backup_mail3

backup_mail4

ขอบคุณทุกท่าน ที่ดูแล้ว จะนำไปให้ให้เกิดประโยชน์ต่อไป
ขอบคุณทุกท่าน ที่เอาไปใช้แล้วให้เครดิตผม

กันลืม

crontab filename       	การนำเอาคำสั่ง crontab เข้ามาจาก ไฟล์อื่น

crontab -e                แก้ไข crontab ปัจจุบัน

crontab -l                 ดูคำสั่ง crontab ทั้งหมดที่มีอยู่

crontab -r                 ลบคำสั่ง crontab ที่มีทั้งหมด

crontab -u user          เป็นคำสั่งของผู้ดูแลระบบเท่านั้น(administrators) เพื่อใช้ดู  แก้ไข ลบ crontab ของ user แต่ล่ะคน

By default cron jobs sends a email to the user account executing the cronjob.  If this is not needed put the following command At the end of the cron job line  .

 >/dev/null 2>&1

****
15 * * * * rm -rf /var/www/html/xxx.com/ocache/*.png > /dev/null 2>&1

sp thx[1]: NECTEC
sp thx[2]: Thai Admin

Bookmark and Share

php script backup database

By สุดเดช, 26 กุมภาพันธ์ 2009 20:17

วันนี้ผมจะมานำเสนอ การ Backup database โดยใช้ php น่ะคับ

เป็นการ backup ข้อมูลผ่าน สริปต์ โดยใช้ ตัว crontab ใน Linux เป็นตัวเรียก สริปต์นี้

ใ้ห้ทำงานน่ะคับ วันนี้จะนำเสนอ ในเรื่องของ สริปต์กันก่อนน่ะคัีบ

ผมได้ เรียนรู้บางคำสั่ง จาก อาจารย์ เปิ้ล แอบ เซิฟ  และ การโค้ดดิ้ง แนะแนวโดยพี่แม๊กมอไซค์คับ

โดยการ backup ในครั้งนี้ เมื่อทำการแบ๊กอัพ เสร็จแล้ว มันจะส่งเมล์ไปบอก ยัง ผู้ดูแลระบบ
ในครั้งต่อไปผมจะ นำ คำสั่ง พร้อมกับ ภาพ มาประกอบให้ดูกันน่ะคับ
ขอบคุณทุกท่าน ที่ดูแล้ว จะนำไปให้ให้เกิดประโยชน์ต่อไป
ขอบคุณทุกท่าน ที่เอาไปใช้แล้วให้เครดิตผม

สังคมน่าอยู่เพราะว่ามีคนมีน้ำใจ

sp thx[1]: NECTEC
sp thx[2]: Thai Admin

<?

class BackUp{

function WhatBackup($whatBackup){
if (    (!$whatBackup) || ($whatBackup == "")    )    {
die("Specify folder to backup");
}
$this->whatBackup    = $whatBackup;
}

###    Make dir if not exists    ###
function WhereBackup($whereBackup){
$this->whereBackup    = $whereBackup;
}

###    Build FileName    ###
function FileName($fileName){
$today        = date("Y_m_d_H-i");
$fileName    = (    (!$fileName) || ($fileName == "")    ) ? $today : $fileName;
$this->fileName    = $fileName;
}
###    Do It    ###
function Backup(){

$today        = date("d-m-Y, H:i:s");
$comm         = "tar cfvz ".$this->whereBackup."/phpbb_".$this->fileName.".tar.gz ".$this->whatBackup;
###    If u want All output, use passthru() function    ###

### Send E-mail ###

$run        = exec($comm);
$msg        = ($run != "") ? "Backup OK" : "Backup FAILED";

$to  ="webxxx@mail.com";

$subject = "Backup system Database ip xxx [phpbb]";

$message = "Backup System Report Server : ip xxx <br />";
$message .="Date : ".$today ."<br />";
$message .="Status : ".$msg."<br />";
$message .="What Backup : ".$this->whatBackup."<br />";
$message .="Where Backup : ".$this->whereBackup."<br />";
$message .="File name : phpbb_".$this->fileName.".tar.gz";

$headers  = "MIME-Version: 1.0" . "rn";
$headers .= "Content-type: text/html; charset=utf-8" . "rn";
$headers .= "From: email@mail.com" . "rn";
$headers .= "X-Mailer: PHP/".phpversion();
@mail($to, $subject, $message, $headers);
exec("sleep 30");
}

}

?>
Bookmark and Share

SSH

By สุดเดช, 28 มกราคม 2009 15:35
Linux / Unix Command: ssh
Command Library

NAME

ssh – OpenSSH SSH client (remote login program)

SYNOPSIS

ssh [-l login_name ] hostname | user@hostname [command ]
ssh [-afgknqstvxACNTX1246 ] [-b bind_address ] [-c cipher_spec ] [-e escape_char ] [-i identity_file ] [-l login_name ] [-m mac_spec ] [-o option ] [-p port ] [-F configfile ] [-L port host hostport ] [-R port host hostport ] [-D port ] hostname | user@hostname [command ]

วิธีการใช้งาน ssh -l username hostname,ipaddress

credit : http://linux.about.com/od/commands/l/blcmdl1_ssh.htm

Bookmark and Share

553 could not create file

เมื่อเกิดปัญหา 553 colude not create file

เกิดจาก ไม่สามารถย้ายไฟล์ไปยังจุดหมายปลายทางได้เนื่องจากสิทธิ์ไม่พึ่งกระทำ


Macintosh:~ steffentchr$ ftp ftp.dummy.com
Connected to ftp.dummy.com.
220 (vsFTPd 2.0.3)
Name (ftp.dummy.com):steffentchr): steffen
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
226 Directory send OK.
ftp> put Desktop/stc1
local: Desktop/stc1 remote: Desktop/stc1
229 Entering Extended Passive Mode (|||64727|)
553 Could not create file.

วิธีการแก้ไขปัญหานี้คับ

chmod 750  ไปยัง directory ที่จะทำการย้ายไฟล์คับก็จะไม่เกิดปัญหานี้คับผม

ให้เครดิตผมด้วยน่ะคับ www.sudej.com

Bookmark and Share

คำสั่งเบื้องต้น vsftpd

credit : http://www.davelozinski.com/tutorials/ftp/index.php?1233128757977

Commands:

  • ftp [host] – open an ftp session with the specified host machine.
    Examples:
    C:\> ftp neserve0
    C:\> ftp erols.erols.com
  • open [host] – Establish a connection to the specified host when you’re already at an ftp prompt.
    Examples:
    ftp> open neserve0
    ftp> open erols.erols.com
  • user [username] – Log into an ftp server when you’re already connected in an ftp session.
    Examples:
    ftp> user dlozinsk
    ftp> user anonymous
  • ls [remote-directory] – Print a listing of the contents of remote-directory on the remote machine. The listing includes any system-dependent information that the server chooses to include.
    Examples:
    ftp> ls
    ftp> ls /usr/local/bin
  • dir [remote-directory] [local-file] – Print a listing of the contents in the directory remote-directory, and optionally, placing the output in local-file.
    Examples:
    ftp> dir
    ftp> dir /usr/local/bin
  • help [command] – Print an informative message about the meaning of command. If no argument is given, ftp prints a list of the known commands.
    Examples:
    ftp> help
    ftp> help dir
  • ? – synonym for help.
    Examples:
    ftp> ?
    ftp> ? dir
  • pwd – Print the name of the current working directory on the remote machine.Often times this includes printing the full path.
    Example:
    ftp pwd>
  • cd [remote-directory] – Change the working directory on the remote machine to remote-directory.
    Examples:
    ftp> cd /tmp
    ftp> cd ../..
  • lcd [directory] – Change the working directory to directory on the local machine. If no directory is specified, the user’s home directory is used.
    Examples:
    ftp> lcd c:\temp
    ftp> lcd ../..
  • ascii – Set the file transfer type to ASCII . Only use this transfer method for text-files. That is, files ending in .txt, html files, and/or perl programs.
    Example:
    ftp> ascii
  • binary – Set the file transfer type to support binary file transfer. Use this transfer method for anything other than a textfile. For example, Word documents, pdf files, gifs, jpgs, java class files, etc.
    Example:
    ftp> binary
  • put [local-file] – Put (upload) local-file to the remote machine. No wildcards!
    Examples:
    ftp> put index.html
    ftp> put test.txt
  • get [remote-file] – Retrieve (download) remote-file and store it on the local machine. No wildcards! Can only get one file at a time.
    Examples:
    ftp> get index.html
    ftp> get /tmp/readme.txt
  • mput [local-files] – Expand wild cards in the list of local-files given as arguments and do a put for each file in the resulting list. The list of files should be separated by spaces.
    Examples:
    ftp> mput *
    ftp> mput *.html
    ftp> mput *.html test.txt README
  • mget [multiple files and/or wildcards] – Expand wild cards in the list of remote files given as arguments and do a get for each file in the resulting list. The list of files should be separated by spaces.
    Examples:
    ftp> mget *
    ftp> mget *.gif
    ftp> mget *.doc image.gif salaries*
  • prompt – Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively retrieve or store files. If prompting is turned off, any mget or mput will transfer all files, and any mdelete will delete all files.
    Example:
    ftp> prompt
  • bell – Arrange that a bell be sounded after each file transfer command is completed.
    Example:
    ftp> bell
  • delete [remote-file] – Delete the remote-file on the remote machine.
    Examples:
    ftp> delete test.doc
    ftp> delete /tmp/temporary_file.txt
  • mkdir [new-directory-name] – create a directory new-directory-name on the remote machine.
    Examples:
    ftp> mkdir temp
    ftp> mkdir /tmp/dave
  • rmdir [directory-name] – Delete the directory entitled directory-name on the remote machine.
    Examples:
    ftp> rmdir temporary_directory
    ftp> rmdir /tmp/test_dir
  • rename [old-file-name] [new-file-name] – Rename the file old-file-name on the remote machine, to the file new-file-name.
    Examples:
    ftp> rename index.htm homepage.html
    ftp> rename /tmp/readme.txt /tmp/README_NOW.txt
  • bye – Terminate the FTP session with the remote server and exit ftp. On Unix, an end of file should also terminate the session and exit.
    Example:
    ftp> bye
  • quote site chmod xxx [file name] – Change the permission modes of the file file-name on the remote system to xxx mode. Note that the chmod command is not always implemented.
  • get [file-name] “|more” – Instead of downloading and saving the file file-name on the local machine, you view its contents. Only recommended to use with text files.
Bookmark and Share

ปรับแต่ง vsftpd

เป็นการ เพิ่ม สิทธิต่าง ๆ และ กำหนด กลุ่มและ สิทธิ์ผู้ใช้งาน ของ vsftpd


[root@sudej home]# groupadd ftp-users
[root@sudej home]# mkdir /home/ftp-docs
[root@sudej home]# chmod 750 /home/ftp-docs
[root@sudej home]# chown root:ftp-users /home/ftp-docs
[root@sudej home]# useradd -g ftp-users -d /home/ftp-docs user1
[root@sudej home]# passwd user1
Bookmark and Share

vsftpd

อ้างอิงจาก http://rd.cc.psu.ac.th/content/view/20/46/

เป็นคำแนะนำติดตั้งจัดการปรับแต่ง ftp server
ต้นแบบทดสอบด้วย linux ubuntu 6.06, fedora core 5,4

วิธีติดตั้ง ftp server ด้วยโปรแกรม vsftpd

  1. ติดตั้งโปรแกรม vsftpd
    หากเป็น ubuntu ให้ติดตั้งด้วยคำสั่ง
    apt-get install vsftpd

    หากเป็น fedora ให้ติดตั้งด้วยคำสั่ง
    yum install vsftpd

  2. หากเป็น fedora แก้ไขให้ทำงานทุกครั้งที่บูทเครื่อง
    chkconfig vsftpd on
  3. สั่งให้ทำงานด้วยคำสั่งว่า
    /etc/init.d/vsftpd start
  4. ตรวจสอบว่า vsftpd ทำงานแล้วด้วยคำสั่ง
    ps ax | grep vsftpd
    ได้คำตอบประมาณว่า
    ….. ?        Ss     0:00 /usr/sbin/vsftpd ….
    แสดงว่าใช้งานได้แล้ว
  5. การให้แฟ้มข้อมูลสามารถเปิดอ่านได้ผู้ใช้แบบสาธารณะชื่อ anonymous
    หากเป็น unbuntu ให้เก็บข้อมูลไว้ภายใต้ Directory ชื่อ /home/ftp/pub
    ซึ่งต้องสร้าง directory เพิ่มคือ
    mkdir -p /home/ftp/pub

    หากเป็น fedora ให้เก็บข้อมูลไว้ภายใต้ Directory ชื่อ /var/ftp/pub ได้เลย

  6. การปรับแต่งระบบทำได้โดยการแก้ไขแฟ้ม /etc/vsftpd/vsftpd.conf แล้ว ให้ระบบอ่านค่าที่ปรับใหม่ได้ด้วยคำสั่ง
    /etc/init.d/vsftpd restart
  7. การปรับแต่งค่าต่างๆ
    หากเป็น ubuntu ให้แก้ไขแฟ้ม /etc/vsftpd.conf

    หากเป็น fedora ให้แก้ไขแฟ้ม /etc/vsftpd/vsftpd.conf

    ต้องการให้ใช้งานได้เฉพาะภายใน home ของตนเอง ไม่ต้องการให้ออกไปเพ่นพ่านที่อื่น
    เพิ่ม/แก้ไขบรรทัดข้อความว่า chroot_local_user=YES

    ต้องการห้าม anonymous เข้ามาใช้บริการ
    เพิ่ม/แก้ไขบรรทัดข้อความว่า anonymous_enable=NO

    ต้องการให้ user สามารถ upload แฟ้มได้
    เพิ่ม/แก้ไขบรรทัดข้อความว่า local_enable=YES และ write_enable=YES

    แก้ไขเสร็จแล้วสั่ง vsftpd ทำงานใหม่ด้วยคำสั่ง
    /etc/init.d/vsftpd reload

  8. บน fedora หากเจอปัญหา upload แฟ้มขึ้น ftp server นี้ไม่ได้
    อาจเกิดจาก selinux ให้สั่งปิดการทำงานของ selinux
    โดยแก้ไขแฟ้มชื่อ /etc/selinux/config
    แก้ไขบรรทัดข้อความจากเดิมคือ SELINUX=enforcing
    ให้เป็นข้อความว่า SELINUX=disabled
    ต้อง reboot ใหม่แล้ว selinux จึงจะปิดการทำงานตามต้องการ
  9. ตัวอย่างหากต้องการเพิ่ม hard disk ลูกใหม่เข้าไป และต้องการให้ไปเป็นส่วนหนึ่งของพื้นที่ใน /home/ftp/pub
    ให้จัดการติดตั้ง hard disk และ mount ให้เรียบร้อยสามารถใช้งานได้ซะก่อน
    ตัวอย่างของผมคือเพิ่ม hard disk /dev/hdb1 ไปในพื้นที่ /mnt/data
    และต้องการให้ไปโผล่เป็นส่่วนหนึ่งของ /home/ftp/pub/newdisk
    ทำคำสั่งขั้นตอนดังนี้คือ
    mkdir  -p  /mnt/data
    mount  /dev/hdb1  /mnt/data
    mkdir  -p  /home/ftp/pub/newdisk
    mount  –bind  /mnt/data  /home/ftp/pub/newdisk

    แค่นี้ก็เสร็จแล้ว ตรวจสอบดูผลงานได้เลย

    แก้ไขให้ระบบทำงานคำสั่งเหล่านี้โดยอัตโนมัติทุกครั้งที่บูทเครื่อง
    ต้องแก้ไขแฟ้ม /etc/rc.local โดยเพิ่มบรรทัดคำสั่งเหล่านั้นเข้าไปด้วย

Bookmark and Share

การตั้งค่า utf8

By สุดเดช, 21 มกราคม 2009 18:33

สำหรับท่านที่ เปลี่ยนมาใช้ utf-8 แล้วเกิดปัญหา
เวลา Browser เปิดข้อมูลแล้วเกิดปัญหาตัวอักษรไม่แสดงผล
ตามที่เราตั้งค่าไว้
21-1-2552-18-24-16

ปัญหามันเกิดมาจาก ตัว Content-Type:text/html; ไม่ยอมเรียกค่า ปกติมันออกมา

เราก็มีวิธีแก้ปัญหาดังนี้คับ

สำหรับคนใช้ Linux fedora, redhat น่ะคับ
อับดับแรกก็ไปแก้ไข ไฟล์ที่ชื่อว่า httpd.conf

<code>##########################
AddDefaultCharset UTF-8
AddCharset ISO-8859-1  .iso8859-1  .latin1
AddCharset UTF-8       .utf8
AddCharset utf-8       .utf8
AddCharset TIS-620      .tis-620        th
##########################

สำหรับคนที่ไม่สามารถแก้ไขได้เนื่องจากท่านไม่ Admin ระบบ
ก็ให้เขียนไฟล์ .htaccess หรือ htaccess.txt
แล้วให้ upload ไปยังที่ directory ที่เก็บไฟล์ไว้ของผมอยู่ที่ htdocs คับ
ซึ่งของผมเช่า host ไว้ที่ www.appservhosting.com จารย์เปิ้ล แห่ง appservnetwork.com

<code><IfModule mod_rewrite.c>
AddDefaultCharset utf-8
</IfModule>

ขั้นตอนสุดท้ายมันยังไม่มาอีก
นี้เลยคับ ระบุตัวนี้ไว้ที่หน้าที่จะแสดงเลยคับ

header( 'Content-Type:text/html; charset=utf-8');


หรือใส่ตัว meta กำหนด content-type น่ะคับ

<code><meta http-equiv="content-type" content="text/html; charset=utf-8" />

ไม่ออกให้ตบ ลองดูคับ
21-1-2552-18-25-05
สุดเดช แห่ง สุดเดช บล๊อก ได้กล่าวไว้ว่า
การแบ่งบันสิ่งดี ๆ ให้แก่กัน ทำให้สังคมเราน่าอยู่ขึ้น

Bookmark and Share

Panorama theme by Themocracy