Linux Windows CentOS Web Server DNS PHP MySql
แสดงบทความที่มีป้ายกำกับ server แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ server แสดงบทความทั้งหมด

วันศุกร์ที่ 9 สิงหาคม พ.ศ. 2556

how to install Direct Admin on a clean installation of CentOS 5 and 6. The procedure is exactly the same on both these operating systems and with both 32-bit and 64-bit versions. It is very important to start off with a clean installation, as the DirectAdmin installer will take care of all software components you need.

Do you meet the system requirements?
If you have purchased your license directly from DirectAdmin.com, sign into your client account at https://www.directadmin.com/clients and click the "view" link next to your license. Verify that the server IP address and operating system is correct. Also make sure that the license is Active and Verified (if it isn't, you need to contact Direct Admin support). If you have problems with a license obtained through Woktron Web Hosting, please contact Woktron Support.

1. update CentOS to the latest version (currently 5.8 or 6.3)

yum update

2. install DirectAdmin

Begin by installing the required dependencies for Directadmin:
yum install wget gcc gcc-c++ flex bison make bind bind-libs bind-utils openssl openssl-devel perl quota libaio libcom_err-devel libcurl-dev gd zlib-devel zip unzip libcap-devel cronie
Continue by downloading the DirectAdmin setup routine using wget, set file permissions to writable with chmod and finally startup the setup routine by issuing the ./setup.sh command:
wget http://www.directadmin.com/setup.sh
chmod 755 setup.sh
./setup.sh
After the setup routine starts you will be presented with a number of options. You should have your license details ready.


(start installation routine:)
***************************************************** * * Have you run the pre-install commands? CTRL-C if not. * http://help.directadmin.com/item.php?id=354 * ***************************************************** Please enter your Client ID : xxxxx Please enter your License ID : xxxxx Please enter your hostname \(server.domain.com\) It must be a Fully Qualified Domain Name Do *not* use a domain you plan on using for the hostname: eg. don't use domain.com. Use server.domain.com instead. Do not enter http:// or www Enter your hostname (FQDN) : xxxxx.xxxxx.com Client ID: xxxxx License ID: xxxxx Hostname: xxxxx.xxxxx.com Is this correct? (y,n) : y The following ethernet devices/IPs were found. Please enter the name of the device you wish to use: eth0 xxx.xxx.xxx.xxx eth1
when using a Virtual Private Server (VPS) you should select the respective virtual network port:
venet0:0 (the usual option)
venet0:1
If unsure enter the following in commandline and see which ETH adapter is using your public IP address:
ifconfig
(installation routine continued:)
Enter the device name: xxx Is xxx.xxx.xxx.xxx the IP in your license? (y,n) : y DirectAdmin will now be installed on: Enterprise 5.7 Is this correct? (must match license) (y,n) : y You now have 2 options for your apache/php setup. 1: customapache: end-of-life software. Includes Apache 1.3, php 4 and frontpage. **Not recommended**. Will not work with newer OSs. Limited tech support. 2: custombuild 1.1: newer software (recommended). Includes any Apache version, php 4, 5, or both in cli and/or suphp. Frontpage not available. Post any issues with custombuild to the forum: http://www.directadmin.com/forum/forumdisplay.php?f=61 Enter your choice (1 or 2): 2 You have chosen custombuild 1.1. 2011-11-11 14:47:00 http://files.directadmin.com/services/custombuild/1.1/custombuild/build Resolving files.directadmin.com Connecting to files.directadmin.com|:80 connected. HTTP request sent, awaiting response 200 OK Length: 289046 (282K) [text/plain] Saving to: `/usr/local/directadmin/custombuild/build' 100%[===========================================================================>] 289,046 855K/s in 0.3s 2011-11-11 14:47:01 (855 KB/s) `/usr/local/directadmin/custombuild/build' saved [289046/289046] Would you like the default settings of apache 2.2 and php 5 cli? (y/n): y * Using the default settings for custombuild. Would you like to search for the fastest download mirror? (y/n): y
* This option works fine for a basic webserver install. If you'd like to have more control over what should or should not be installed set this option to N

Below you will find what options you have when selecting a custom setup of DirectAdmin:
Would you like the default settings of apache 2.2 and php 5 cli? (y/n):  N
Would you like to have PHP4 or PHP5 as default? (4/5): 
Would you like to have PHP5? (yes/no): 
Would you like to have PHP5 as CLI or CGI? (cli/cgi): 
Would you like to have PHP4? (yes/no): 
Would you like to have ionCube? (yes/no): 
Would you like to have Zend Optimizer? (yes/no): 
Would you like to have an ability to update/instal MySQL using CustomBuild? (yes/no): 
Which version of MySQL you would like to have? (5.0/5.1): 
Which version of Apache you would like to have? (1.3/2.0/2.2): 
Would you like to have an ability to update/instal Exim using CustomBuild? (yes/no): 
Would you like to have an ability to install Dovecot? (yes/no): 
Would you like to have an ability to install/update phpMyAdmin using CustomBuild? (yes/no): 
Would you like to have an ability to install/update SquirrelMail webmail using CustomBuild? (yes/no): 
Would you like to have an ability to install/update RoundCube webmail using CustomBuild? (yes/no): 
Would you like to have an ability to install/update UebiMiau webmail using CustomBuild (not recommended)? (yes/no): 
Would you like to have an ability to install/update Atmail Open webmail using CustomBuild? (yes/no): 
Would you like to search for the fastest download mirror? (y/n):
When the install routine has completed, you should be ready to login to your newly installed control panel via: http://xx.xx.xx.xx:2222(where xx.xx.xx.xx is your IP address or domain name). 2222 is the port DirectAdmin normally communicates on. It is important to keep this port open in your firewall
In case you forgot your admin password enter the following:
cd /usr/local/directadmin
./directadmin i

3. update custombuild:

After having DirectAdmin succesfully installed it is now time to secure your server. A good first step would be to install the CSF Firewall. It is also important to periodically update your server. This can be done by issuing the following commands:
cd /usr/local/directadmin/custombuild
./build clean 
./build update 
./build update_versions

4. Dealing with RPM errors

When installing RPMs, errors can sometimes occur. Don't panic, solving them is usually easy. If you didn't know what to install during your RedHat installation, you might have installed a few services, such as apache and sendmail. These services must be removed before the rpm will be able to be installed.

For example, lets say you are trying to install exim and you get the following:
rpm -ivh exim-3.36-2.i386.rpm
  Preparing...                         ########################################### [100%]
  file /somefile from install of exim-3.36-2 conflicts with file from package sendmail-8.1
  ...
This would mean that sendmail is already installed on your server and you must remove it. This can easily be accomplished by running the following:
rpm -e --nodeps sendmail
Then you will be able to install your rpm. This follows for other services such as apache, apache-devel, wu-ftp, php, MySQL and so forth. If you need to figure out if you already have a service installed, you can run
rpm -q servicename
or
rpm -qa | grep substring
Where substring is just a word. For example, using "apache" might return:
rpm -qa | grep apache
apache-fp-1.3.27-2
apache-fp-devel-1.3.27-2
apache-fp-manual-1.3.27-2

5. Troubleshooting

If you are having trouble with RPMs hanging, please take a look at:

how to install Direct Admin on a clean installation of CentOS 5 and 6. The procedure is exactly the same on both these operating systems and with both 32-bit and 64-bit versions. It is very important to start off with a clean installation, as the DirectAdmin installer will take care of all software components you need.

Do you meet the system requirements?
If you have purchased your license directly from DirectAdmin.com, sign into your client account at https://www.directadmin.com/clients and click the "view" link next to your license. Verify that the server IP address and operating system is correct. Also make sure that the license is Active and Verified (if it isn't, you need to contact Direct Admin support). If you have problems with a license obtained through Woktron Web Hosting, please contact Woktron Support.

1. update CentOS to the latest version (currently 5.8 or 6.3)

yum update

2. install DirectAdmin

Begin by installing the required dependencies for Directadmin:
yum install wget gcc gcc-c++ flex bison make bind bind-libs bind-utils openssl openssl-devel perl quota libaio libcom_err-devel libcurl-dev gd zlib-devel zip unzip libcap-devel cronie
Continue by downloading the DirectAdmin setup routine using wget, set file permissions to writable with chmod and finally startup the setup routine by issuing the ./setup.sh command:
wget http://www.directadmin.com/setup.sh
chmod 755 setup.sh
./setup.sh
After the setup routine starts you will be presented with a number of options. You should have your license details ready.


(start installation routine:)
***************************************************** * * Have you run the pre-install commands? CTRL-C if not. * http://help.directadmin.com/item.php?id=354 * ***************************************************** Please enter your Client ID : xxxxx Please enter your License ID : xxxxx Please enter your hostname \(server.domain.com\) It must be a Fully Qualified Domain Name Do *not* use a domain you plan on using for the hostname: eg. don't use domain.com. Use server.domain.com instead. Do not enter http:// or www Enter your hostname (FQDN) : xxxxx.xxxxx.com Client ID: xxxxx License ID: xxxxx Hostname: xxxxx.xxxxx.com Is this correct? (y,n) : y The following ethernet devices/IPs were found. Please enter the name of the device you wish to use: eth0 xxx.xxx.xxx.xxx eth1
when using a Virtual Private Server (VPS) you should select the respective virtual network port:
venet0:0 (the usual option)
venet0:1
If unsure enter the following in commandline and see which ETH adapter is using your public IP address:
ifconfig
(installation routine continued:)
Enter the device name: xxx Is xxx.xxx.xxx.xxx the IP in your license? (y,n) : y DirectAdmin will now be installed on: Enterprise 5.7 Is this correct? (must match license) (y,n) : y You now have 2 options for your apache/php setup. 1: customapache: end-of-life software. Includes Apache 1.3, php 4 and frontpage. **Not recommended**. Will not work with newer OSs. Limited tech support. 2: custombuild 1.1: newer software (recommended). Includes any Apache version, php 4, 5, or both in cli and/or suphp. Frontpage not available. Post any issues with custombuild to the forum: http://www.directadmin.com/forum/forumdisplay.php?f=61 Enter your choice (1 or 2): 2 You have chosen custombuild 1.1. 2011-11-11 14:47:00 http://files.directadmin.com/services/custombuild/1.1/custombuild/build Resolving files.directadmin.com Connecting to files.directadmin.com|:80 connected. HTTP request sent, awaiting response 200 OK Length: 289046 (282K) [text/plain] Saving to: `/usr/local/directadmin/custombuild/build' 100%[===========================================================================>] 289,046 855K/s in 0.3s 2011-11-11 14:47:01 (855 KB/s) `/usr/local/directadmin/custombuild/build' saved [289046/289046] Would you like the default settings of apache 2.2 and php 5 cli? (y/n): y * Using the default settings for custombuild. Would you like to search for the fastest download mirror? (y/n): y
* This option works fine for a basic webserver install. If you'd like to have more control over what should or should not be installed set this option to N

Below you will find what options you have when selecting a custom setup of DirectAdmin:
Would you like the default settings of apache 2.2 and php 5 cli? (y/n):  N
Would you like to have PHP4 or PHP5 as default? (4/5): 
Would you like to have PHP5? (yes/no): 
Would you like to have PHP5 as CLI or CGI? (cli/cgi): 
Would you like to have PHP4? (yes/no): 
Would you like to have ionCube? (yes/no): 
Would you like to have Zend Optimizer? (yes/no): 
Would you like to have an ability to update/instal MySQL using CustomBuild? (yes/no): 
Which version of MySQL you would like to have? (5.0/5.1): 
Which version of Apache you would like to have? (1.3/2.0/2.2): 
Would you like to have an ability to update/instal Exim using CustomBuild? (yes/no): 
Would you like to have an ability to install Dovecot? (yes/no): 
Would you like to have an ability to install/update phpMyAdmin using CustomBuild? (yes/no): 
Would you like to have an ability to install/update SquirrelMail webmail using CustomBuild? (yes/no): 
Would you like to have an ability to install/update RoundCube webmail using CustomBuild? (yes/no): 
Would you like to have an ability to install/update UebiMiau webmail using CustomBuild (not recommended)? (yes/no): 
Would you like to have an ability to install/update Atmail Open webmail using CustomBuild? (yes/no): 
Would you like to search for the fastest download mirror? (y/n):
When the install routine has completed, you should be ready to login to your newly installed control panel via: http://xx.xx.xx.xx:2222(where xx.xx.xx.xx is your IP address or domain name). 2222 is the port DirectAdmin normally communicates on. It is important to keep this port open in your firewall
In case you forgot your admin password enter the following:
cd /usr/local/directadmin
./directadmin i

3. update custombuild:

After having DirectAdmin succesfully installed it is now time to secure your server. A good first step would be to install the CSF Firewall. It is also important to periodically update your server. This can be done by issuing the following commands:
cd /usr/local/directadmin/custombuild
./build clean 
./build update 
./build update_versions

4. Dealing with RPM errors

When installing RPMs, errors can sometimes occur. Don't panic, solving them is usually easy. If you didn't know what to install during your RedHat installation, you might have installed a few services, such as apache and sendmail. These services must be removed before the rpm will be able to be installed.

For example, lets say you are trying to install exim and you get the following:
rpm -ivh exim-3.36-2.i386.rpm
  Preparing...                         ########################################### [100%]
  file /somefile from install of exim-3.36-2 conflicts with file from package sendmail-8.1
  ...
This would mean that sendmail is already installed on your server and you must remove it. This can easily be accomplished by running the following:
rpm -e --nodeps sendmail
Then you will be able to install your rpm. This follows for other services such as apache, apache-devel, wu-ftp, php, MySQL and so forth. If you need to figure out if you already have a service installed, you can run
rpm -q servicename
or
rpm -qa | grep substring
Where substring is just a word. For example, using "apache" might return:
rpm -qa | grep apache
apache-fp-1.3.27-2
apache-fp-devel-1.3.27-2
apache-fp-manual-1.3.27-2

5. Troubleshooting

If you are having trouble with RPMs hanging, please take a look at:

วันพฤหัสบดีที่ 1 สิงหาคม พ.ศ. 2556

 

This is only a quick note, on how to disable SELinux on a system using command line tools: Open file /etc/sysconfig/selinux which should more or less be like this:

# This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#           enforcing - SELinux security policy is enforced. 
#           permissive - SELinux prints warnings instead of enforcing. 
#           disabled - SELinux is fully disabled. 
SELINUX=enforcing 
# SELINUXTYPE= type of policy in use. Possible values are: 
#           targeted - Only targeted network daemons are protected. 
#           strict - Full SELinux protection. 
SELINUXTYPE=targeted


Next, find the line saying: SELINUX=enforcing and replace it with SELINUX=disabled

save and reboot.

Note: Be very careful when editing this file. the other day. occidentally changed the value of SELINUXTYPE to something other than the allowed values and managed to completely prevent my 6.4 CentOS kernel from booting. (God save the live CD's ...)

 

This is only a quick note, on how to disable SELinux on a system using command line tools: Open file /etc/sysconfig/selinux which should more or less be like this:

# This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#           enforcing - SELinux security policy is enforced. 
#           permissive - SELinux prints warnings instead of enforcing. 
#           disabled - SELinux is fully disabled. 
SELINUX=enforcing 
# SELINUXTYPE= type of policy in use. Possible values are: 
#           targeted - Only targeted network daemons are protected. 
#           strict - Full SELinux protection. 
SELINUXTYPE=targeted


Next, find the line saying: SELINUX=enforcing and replace it with SELINUX=disabled

save and reboot.

Note: Be very careful when editing this file. the other day. occidentally changed the value of SELINUXTYPE to something other than the allowed values and managed to completely prevent my 6.4 CentOS kernel from booting. (God save the live CD's ...)


VSFTPD is a service which allows us to setup ftp server in secure way. it is Very Secure File Transfer Protocol Daemon (VSFTPD).
By default ftp server can be access anonymously ( ‘/var/ftp’ anonymous space ) and we can also configure login-based FTP sessions.

In this HowTo i will show you the login-based FTP configuration and installation.

First of Installation of VSFTPD using of course ‘yum’.


Step-1

yum install vsftpd

Setp-2 Edit main config file
vi /etc/vsftpd/vsftpd.conf
change below line as follows :
anonymous_enable=NO
local_enable=YES

Step-3 Enable ‘vsftpd’ in multi-user runlevels using ‘chkconfig’ & Start Service.
chkconfig vsftpd on
service vsftpd start

Step-3 Set SeLinux Booleon
getsebool -a | grep ftp - dupms FTP-related SELinux booleans
setsebool -P ftp_home_dir on

Now you can make login-based ftp session
Open your browser type : ftp://username@localhost or IP address of your FTP Server.


- See more at: http://www.broexperts.com/2013/04/how-to-install-vsftp-on-centos-6-4/#sthash.0USZPQ4l.dpuf


VSFTPD is a service which allows us to setup ftp server in secure way. it is Very Secure File Transfer Protocol Daemon (VSFTPD).
By default ftp server can be access anonymously ( ‘/var/ftp’ anonymous space ) and we can also configure login-based FTP sessions.

In this HowTo i will show you the login-based FTP configuration and installation.

First of Installation of VSFTPD using of course ‘yum’.


Step-1

yum install vsftpd

Setp-2 Edit main config file
vi /etc/vsftpd/vsftpd.conf
change below line as follows :
anonymous_enable=NO
local_enable=YES

Step-3 Enable ‘vsftpd’ in multi-user runlevels using ‘chkconfig’ & Start Service.
chkconfig vsftpd on
service vsftpd start

Step-3 Set SeLinux Booleon
getsebool -a | grep ftp - dupms FTP-related SELinux booleans
setsebool -P ftp_home_dir on

Now you can make login-based ftp session
Open your browser type : ftp://username@localhost or IP address of your FTP Server.


- See more at: http://www.broexperts.com/2013/04/how-to-install-vsftp-on-centos-6-4/#sthash.0USZPQ4l.dpuf

วันอังคารที่ 30 กรกฎาคม พ.ศ. 2556


สำหรับท่านที่ต้องการทำระบบ Hotspot ภายในเองที่มีผู้ใช้งานไม่เกิน 30-50 เครื่อง โดยสามารถความคุมความเร็วของผู้ใช้งานแต่ละกลุ่ม/แผนก รวมไปถึงการกำหนดความเร็วในการใช้อินเตอร์เน็ตภายในองค์กร หรือจะบล็อคโปรแกรมใดก็ได้นะครับ  ลองนำไปใช้ดูได้นะครับ


การสร้าง hotspot server

1. เมื่อได้ IP Address แล้ว จะเข้าสู่การสร้าง Hotspot โดยใช้ wizards

1.1. IP / Hotspot

 


1.2. กด Hotspot Setup
 
1.3. เลือก Interface ที่ต้องการทำ Hotspot เช่น ether4 กด next


 
1.4. กำหนด IP Address ให้กับ Interface ที่ใช้งาน
 

1.5. กำหนดช่วง IP Address ที่จะแจกให้กับ Client


 


1.6. ใส่ค่า SSL CERTIFICATE หากได้ทำเครื่องหมายรับรองความปลอดภัยทางอิเล็กทรอนิกส์ไว้ สามารถ นำมา Import เข้าได้เลย หาก ไม่มี เลือก None แล้ว กด Next
 
1.7. ใส่ IP Address SMTP Server หรือ IP Address Mail Server แล้ว กด Next
 


1.8. DNS Server ค่าที่ได้จาก ISP (ผู้ให้บริการ อินเตอร์เน็ต) แล้ว กด Next


 

1.9. DNS Name ใส่ชื่อ Hotspot ที่เราสร้างเช่น hotspot.yourname.com แล้ว กด Next
 

1.10. สร้าง user และ password สำหรับใช้งาน Hotspot


 

1.11. ระบบจะแจ้งว่า Setup has completed successfully กด OK


 


เมื่อ Config เสร็จแล้ว มีการ Add user แล้ว 1 user

หากไม่ต้องการ Authen ให้ disable hotspot server



ตอนนี้ Hotspot พร้อมทำงานแล้ว ให้กลับมาที่ Computer บ้าง ทำการ Config Local Area Connection ในส่วน Internet protocol (TCP/IP) ให้เลือก Obtain an IP Address automatically และ Obtain DNS server Address automatically

เพราะ ว่าได้กำหนด ใน Hotspot ให้ทำการแจก IP Address ให้ด้วยแล้ว


 
ต่อมาดูที่ Status ของ Local Area Connection ว่าได้รับ IP Address และค่าอื่น ตามที่กำหนดไว้หรือไม่


 



ตามที่เรากำหนดไว้ว่า ether4 IP 192.168.10.1(Gateway) ส่วน IP Address ได้รับจาก DHCP Server คือ 192.168.10.2-192.168.10.254

ทำการทดสอบเข้าใช้งานโดย เปิด IE ขึ้นมา จะปรากฏหน้า Login Hotspot user = admin password = ว่าง

 

หลังจาก Login เป็นที่เรียบร้อยแล้ว จะปรากฏหน้าต่าง Status ขึ้นมา


 

แจ้ง ชื่อ User ที่ login IP Address ค่า download upload ข้อมูลทั้งหมด แสดงเวลาที่อยู่ในระบบ และ ข้อมูลดังกล่าว ข้างต้นจะปรับปรุงทุกๆ 1 นาที


สำหรับท่านที่ต้องการทำระบบ Hotspot ภายในเองที่มีผู้ใช้งานไม่เกิน 30-50 เครื่อง โดยสามารถความคุมความเร็วของผู้ใช้งานแต่ละกลุ่ม/แผนก รวมไปถึงการกำหนดความเร็วในการใช้อินเตอร์เน็ตภายในองค์กร หรือจะบล็อคโปรแกรมใดก็ได้นะครับ  ลองนำไปใช้ดูได้นะครับ


การสร้าง hotspot server

1. เมื่อได้ IP Address แล้ว จะเข้าสู่การสร้าง Hotspot โดยใช้ wizards

1.1. IP / Hotspot

 


1.2. กด Hotspot Setup
 
1.3. เลือก Interface ที่ต้องการทำ Hotspot เช่น ether4 กด next


 
1.4. กำหนด IP Address ให้กับ Interface ที่ใช้งาน
 

1.5. กำหนดช่วง IP Address ที่จะแจกให้กับ Client


 


1.6. ใส่ค่า SSL CERTIFICATE หากได้ทำเครื่องหมายรับรองความปลอดภัยทางอิเล็กทรอนิกส์ไว้ สามารถ นำมา Import เข้าได้เลย หาก ไม่มี เลือก None แล้ว กด Next
 
1.7. ใส่ IP Address SMTP Server หรือ IP Address Mail Server แล้ว กด Next
 


1.8. DNS Server ค่าที่ได้จาก ISP (ผู้ให้บริการ อินเตอร์เน็ต) แล้ว กด Next


 

1.9. DNS Name ใส่ชื่อ Hotspot ที่เราสร้างเช่น hotspot.yourname.com แล้ว กด Next
 

1.10. สร้าง user และ password สำหรับใช้งาน Hotspot


 

1.11. ระบบจะแจ้งว่า Setup has completed successfully กด OK


 


เมื่อ Config เสร็จแล้ว มีการ Add user แล้ว 1 user

หากไม่ต้องการ Authen ให้ disable hotspot server



ตอนนี้ Hotspot พร้อมทำงานแล้ว ให้กลับมาที่ Computer บ้าง ทำการ Config Local Area Connection ในส่วน Internet protocol (TCP/IP) ให้เลือก Obtain an IP Address automatically และ Obtain DNS server Address automatically

เพราะ ว่าได้กำหนด ใน Hotspot ให้ทำการแจก IP Address ให้ด้วยแล้ว


 
ต่อมาดูที่ Status ของ Local Area Connection ว่าได้รับ IP Address และค่าอื่น ตามที่กำหนดไว้หรือไม่


 



ตามที่เรากำหนดไว้ว่า ether4 IP 192.168.10.1(Gateway) ส่วน IP Address ได้รับจาก DHCP Server คือ 192.168.10.2-192.168.10.254

ทำการทดสอบเข้าใช้งานโดย เปิด IE ขึ้นมา จะปรากฏหน้า Login Hotspot user = admin password = ว่าง

 

หลังจาก Login เป็นที่เรียบร้อยแล้ว จะปรากฏหน้าต่าง Status ขึ้นมา


 

แจ้ง ชื่อ User ที่ login IP Address ค่า download upload ข้อมูลทั้งหมด แสดงเวลาที่อยู่ในระบบ และ ข้อมูลดังกล่าว ข้างต้นจะปรับปรุงทุกๆ 1 นาที

คนที่พัฒนาระบบงานบน Linux หรือ Unix และเป็นผู้ที่ไม่ชอบย้ายมือออกจากคีย์บอร์ดนั้น ขอแนะนำให้ใ้ช้ Vi Editor แล้วท่านจะไม่ผิดหวัง เนื่องจาก vi นั้นถูกออกแบบมาให้ใช้งาน โดยที่ไม่จำเป็นต้องเอามือออกจากคีย์บอร์ดเลย ไม่เพียงเท่านั้น 10 นิ้วของท่าน จะไม่หลุดออกแป้น a s d f space j k l : เลย แม้แต่ลูกศรขึ้นลง ก็ไม่ได้ใช้ ตัวเลข ก็ไม่ได้ใช้ อยากรู้แล้วใช้ไหมครับ ว่ามันทำงานอย่างไร
vi ประกอบด้วย 2 Mode คือ
  1. Mode command ไว้สำหรับใช้คำสั่ง Mode นี้ เพียงกด Esc ก็จะเข้าสู่ Mode command อัตโนมัติ (คิดอะไรไม่ออก กด Esc ลูกเดียว)
  2. Mode การพิมพ์ ไว้สำหรับเพิ่มข้อมูล เลื่อน Cursor ต่าง ๆ แต่เราต้องใช้ Command ก่อน เช่น หากต้องการเพิ่มอักษร ต้องสั่ง I (Insert) เสียก่อน และเมื่อพิมพ์จะเป็นการแทรกข้อความอัตโนมัติ
การเลื่อนทิศทาง (Motivation) 
สังเกตุนะครับ มือจะไม่ขยับไปใช้ ลูกศร ขึ้นลง เลย ทำให้ทำงานได้เร็วขึ้น
  • h = เลื่อนไปทางซ้าย
  • l = เลื่อนไปทางขวา
  • j = เลื่อนลง
  • k = เลื่อนขึ้น
  • หาก พิมพ์ 8l = เลื่อนไปทางขวา 8 ตัวอักษร
  • w , W = เลื่อนไปทางขวา 1 คำ เช่น this is test เมื่อกด w จะเลื่อน Cursor ไป 1 word Cursor จะไปยืนอยู่ที่ this is test เป็นต้น
  • { = เลื่อนไปยังต้น Paragraph
  • } = เลื่อนไปยังท้าย Paragraph
  • :หมายเลขบรรทัด = เลื่อนไปยังบรรทัดที่ต้องการ เช่น :10 หมายถึงไปบรรทัดที่ 10 เป็นต้น
  • $ = ไปตัวอักษรท้ายสุดของบรรทัด
  • 0 = ไปตัวอักษรตัวแรกสุด ของบรรทัด
การกระทำการ (Operator)
  • i = เพิ่มตัวอักษร (insert) ใช้งาน โดยพิมพ์ i แล้วพิมพ์ต่อได้เลย
  • I = เพิ่มตัวอักษรต้นบรรทัด
  • x = ลบตัวษรทีละ 1 ตัว
  • 10x = ลบตัวอักษร 10 ตัว
  • dw = ลบทั้งคำ
  • dd = ลบทั้งบรรทัด
  • yy = yank หมายถึง Copy ทั้งบรรทัด
  • p = วาง (Paste) วางบรรทัดล่างจาก Cursor อยู่
  • P = วาง (Paste) วางแทรกบรรทัดปัจจุบัน
การจัดการเกี่ยวกับไฟล์
  • :w ชื่อไฟล์ = save ไฟล ์ด้วยชื่อที่กำหนด
  • :wq = save ไฟล์ และออกจาก vi (Quit)
  • :q! = ออกจาก vi โดยไม่ Save
  • :set
    • set nu = สั่งให้ vi แสดงหมายเลขบรรทัด
    • set ic = สั่งให้เวลา Search ไม่ดูการค้น ตัวเล็ก ตัวใหญ่ ใด ๆ (Ignore Case)
    • set nu ic สั่งให้ทำงานทั้ง 2 แบบ
ลอง Telnet แล้วไปของพิมพ์เล่น ๆ ดูนะครับ ทางด้านบนนั้น เป็นเพียงแค่ความสามารถเพียงนิดเดียวของ Vi ครับ หวังว่าหลายคนที่มองหา Editor ฟรี ๆ ความสามารถสูง ๆ ที่พร้อมใช้ังานอยู่ใน Server อยู่แล้วครับ

คนที่พัฒนาระบบงานบน Linux หรือ Unix และเป็นผู้ที่ไม่ชอบย้ายมือออกจากคีย์บอร์ดนั้น ขอแนะนำให้ใ้ช้ Vi Editor แล้วท่านจะไม่ผิดหวัง เนื่องจาก vi นั้นถูกออกแบบมาให้ใช้งาน โดยที่ไม่จำเป็นต้องเอามือออกจากคีย์บอร์ดเลย ไม่เพียงเท่านั้น 10 นิ้วของท่าน จะไม่หลุดออกแป้น a s d f space j k l : เลย แม้แต่ลูกศรขึ้นลง ก็ไม่ได้ใช้ ตัวเลข ก็ไม่ได้ใช้ อยากรู้แล้วใช้ไหมครับ ว่ามันทำงานอย่างไร
vi ประกอบด้วย 2 Mode คือ
  1. Mode command ไว้สำหรับใช้คำสั่ง Mode นี้ เพียงกด Esc ก็จะเข้าสู่ Mode command อัตโนมัติ (คิดอะไรไม่ออก กด Esc ลูกเดียว)
  2. Mode การพิมพ์ ไว้สำหรับเพิ่มข้อมูล เลื่อน Cursor ต่าง ๆ แต่เราต้องใช้ Command ก่อน เช่น หากต้องการเพิ่มอักษร ต้องสั่ง I (Insert) เสียก่อน และเมื่อพิมพ์จะเป็นการแทรกข้อความอัตโนมัติ
การเลื่อนทิศทาง (Motivation) 
สังเกตุนะครับ มือจะไม่ขยับไปใช้ ลูกศร ขึ้นลง เลย ทำให้ทำงานได้เร็วขึ้น
  • h = เลื่อนไปทางซ้าย
  • l = เลื่อนไปทางขวา
  • j = เลื่อนลง
  • k = เลื่อนขึ้น
  • หาก พิมพ์ 8l = เลื่อนไปทางขวา 8 ตัวอักษร
  • w , W = เลื่อนไปทางขวา 1 คำ เช่น this is test เมื่อกด w จะเลื่อน Cursor ไป 1 word Cursor จะไปยืนอยู่ที่ this is test เป็นต้น
  • { = เลื่อนไปยังต้น Paragraph
  • } = เลื่อนไปยังท้าย Paragraph
  • :หมายเลขบรรทัด = เลื่อนไปยังบรรทัดที่ต้องการ เช่น :10 หมายถึงไปบรรทัดที่ 10 เป็นต้น
  • $ = ไปตัวอักษรท้ายสุดของบรรทัด
  • 0 = ไปตัวอักษรตัวแรกสุด ของบรรทัด
การกระทำการ (Operator)
  • i = เพิ่มตัวอักษร (insert) ใช้งาน โดยพิมพ์ i แล้วพิมพ์ต่อได้เลย
  • I = เพิ่มตัวอักษรต้นบรรทัด
  • x = ลบตัวษรทีละ 1 ตัว
  • 10x = ลบตัวอักษร 10 ตัว
  • dw = ลบทั้งคำ
  • dd = ลบทั้งบรรทัด
  • yy = yank หมายถึง Copy ทั้งบรรทัด
  • p = วาง (Paste) วางบรรทัดล่างจาก Cursor อยู่
  • P = วาง (Paste) วางแทรกบรรทัดปัจจุบัน
การจัดการเกี่ยวกับไฟล์
  • :w ชื่อไฟล์ = save ไฟล ์ด้วยชื่อที่กำหนด
  • :wq = save ไฟล์ และออกจาก vi (Quit)
  • :q! = ออกจาก vi โดยไม่ Save
  • :set
    • set nu = สั่งให้ vi แสดงหมายเลขบรรทัด
    • set ic = สั่งให้เวลา Search ไม่ดูการค้น ตัวเล็ก ตัวใหญ่ ใด ๆ (Ignore Case)
    • set nu ic สั่งให้ทำงานทั้ง 2 แบบ
ลอง Telnet แล้วไปของพิมพ์เล่น ๆ ดูนะครับ ทางด้านบนนั้น เป็นเพียงแค่ความสามารถเพียงนิดเดียวของ Vi ครับ หวังว่าหลายคนที่มองหา Editor ฟรี ๆ ความสามารถสูง ๆ ที่พร้อมใช้ังานอยู่ใน Server อยู่แล้วครับ

วันจันทร์ที่ 29 กรกฎาคม พ.ศ. 2556

หลังจากติดตั้ง CentOS แบบ Minimal ไปเมื่อคราวที่แล้ว มาวันนี้มีเหตุที่จะต้องแก้ไข IP Address ของเครื่อง ด้วยความที่เราเคยใช้ Redhat มาก่อน ก็ลงมือพิมพ์คำสั่ง setup เพื่อจะเข้าไปแก้ไขทันที แต่ปรากฏว่า มันไม่มีคำสั่ง setup ซะงั้น ไปลองหาดูในเน็ทเขาก็บอกว่าต้องติดตั้ง setuptool เข้าไปด้วย ซึ่งก็สามารถติดตั้งได้ผ่านทาง yum นี้หละ ได้ความอย่างนั้นแล้ว ก็ทดสอบทันทีเลยหละกัน ว่าคำสั่ง setup ที่เราเคยใช้สมัย Redhat มันจะยังหน้าตาเหมือนเดิมไหม
อย่างแรกก็ลองพิมพ์คำสั่ง setup ดูก่อนว่าใช้งานไม่ได้จริงไหม และก็อย่างที่เห็นใช้ไม่ได้ – -’
1
 # setup
centos-install-setuptool


















จากนั้นทำการติดตั้ง setuptool และ system-config* (อันนี้หมายถึงว่าให้ติดตั้งโปรแกรมทุกตัวที่ชื่อขึ้นต้นด้วย system-config นะครับ)
1
2
 # yum install setuptool
 # yum install system-config*
เมื่อทำการติดตั้งเสร็จแล้วก็มาลองกันหน่อยว่าใช้งานได้หรือยัง
1
 # setup
จะเห็นว่าเปิดโปรแกรม setup ขึ้นมาได้แล้ว และสามารถแก้ไขค่า Network และ Firewall ได้
centos-install-setuptool
ลองเข้าไปแก้ไข IP Address ดูเล็กน้อย
centos-install-setuptool

















คำสั่ง setup นี้ก็เหมาะกับคนที่ทำงานผ่านทาง command line แต่จำคำสั่งไม่ค่อยได้ ก็น่าจะพอช่วยให้แก้ไขงานไปได้ในเวลาฉุกเฉิน

หลังจากติดตั้ง CentOS แบบ Minimal ไปเมื่อคราวที่แล้ว มาวันนี้มีเหตุที่จะต้องแก้ไข IP Address ของเครื่อง ด้วยความที่เราเคยใช้ Redhat มาก่อน ก็ลงมือพิมพ์คำสั่ง setup เพื่อจะเข้าไปแก้ไขทันที แต่ปรากฏว่า มันไม่มีคำสั่ง setup ซะงั้น ไปลองหาดูในเน็ทเขาก็บอกว่าต้องติดตั้ง setuptool เข้าไปด้วย ซึ่งก็สามารถติดตั้งได้ผ่านทาง yum นี้หละ ได้ความอย่างนั้นแล้ว ก็ทดสอบทันทีเลยหละกัน ว่าคำสั่ง setup ที่เราเคยใช้สมัย Redhat มันจะยังหน้าตาเหมือนเดิมไหม
อย่างแรกก็ลองพิมพ์คำสั่ง setup ดูก่อนว่าใช้งานไม่ได้จริงไหม และก็อย่างที่เห็นใช้ไม่ได้ – -’
1
 # setup
centos-install-setuptool


















จากนั้นทำการติดตั้ง setuptool และ system-config* (อันนี้หมายถึงว่าให้ติดตั้งโปรแกรมทุกตัวที่ชื่อขึ้นต้นด้วย system-config นะครับ)
1
2
 # yum install setuptool
 # yum install system-config*
เมื่อทำการติดตั้งเสร็จแล้วก็มาลองกันหน่อยว่าใช้งานได้หรือยัง
1
 # setup
จะเห็นว่าเปิดโปรแกรม setup ขึ้นมาได้แล้ว และสามารถแก้ไขค่า Network และ Firewall ได้
centos-install-setuptool
ลองเข้าไปแก้ไข IP Address ดูเล็กน้อย
centos-install-setuptool

















คำสั่ง setup นี้ก็เหมาะกับคนที่ทำงานผ่านทาง command line แต่จำคำสั่งไม่ค่อยได้ ก็น่าจะพอช่วยให้แก้ไขงานไปได้ในเวลาฉุกเฉิน