วันอังคารที่ 20 มกราคม พ.ศ. 2558

Config Apache web server ให้ผู้ใช้งานทั่วไปใช้งานภาษา Perl, Php และ Python

        ในบทความก่อนผู้เขียนได้กล่าวถึงการคอนฟิก Apache web server ให้ผู้ใช้งานทั่วไปที่ไม่ใช่
root ใช้งานการเขียนเว็บและและสร้างเว็บไซต์ด้วยภาษา HTML ได้  ดังที่ทราบกันดีว่าภาษา
HTML มีข้อจำกัดในการใช้งาน คือ เป็นการสื่อสารทางเดียวระหว่าง server กลับ client ไม่สามารถ
ประมวลผล คำนวณเปรียบเทียบข้อมูลได้
        ในบทความนี้ผู้เขียนจะกล่าวถึงการคอนฟิก Apache web server เพื่อให้ผู้ใช้งานทั่วไปที่ไม่ใช่
root ใช้งานภาษา Perl, Php ละภาษา Python เพื่อใช้ในการติดต่อสื่อสารระหว่าง web server และ
Database server และเพื่อการประมวลผล การจำเว็บเพจที่เป็นการสื่อสารสองทาง (Dynamic web)

วันอาทิตย์ที่ 18 มกราคม พ.ศ. 2558

Config Apache Web server เพื่อให้ผู้ใช้งานเครือข่ายใช้งานภาษา HTML

        หลังที่เราติดตั้ง Web server บน Debian 7.8 GNU/Linux แล้ว  จะมีเพียงผู้บริหารระบบ (root)
คนเดียวเท่านั้นที่สามารถเขียนเว็บลงบน server ได้  ส่วนผู้ใช้งานระบบทั่วไป (users) ยังไม่สามารถ
ใช้งานในการเขียนเว็บเพจลงบน server ได้  ทั้งนี้เพื่อความปลอดภัยของระบบนั่นเอง
        ดังที่กล่าวมาข้างต้นในบทความก่อน ๆ ว่าจุดมุ่งหมายในการติดตั้งระบบปฏิบัติการ Debian
7.8 GNU/Linux ของผู้เขียน คือ การใช้ทรัพยากรร่วมกัน ใช้งานฮาร์ดแวร์ให้เกิดประโยชน์สูงสุด
ใช้ซอฟท์แวร์ร่วมกัน เพียงติดตั้งกันครั้งเดียวก็สามารถจัดสรรค์ให้ผู้ใช้งานระบบได้ใช้กันอย่าง
ทั่งถึง  การติดตั้ง Apache web server ที่เป็นค่าเริ่มต้น root จะสามารถใช้งานเพื่อเขียนเว็บเพจไว้
ที่ไดเรคทอรี /var/www  หลังการติดตั้งจะมีไฟล์ภาษา HTML  เพียงไฟล์เดียว คือ index.html เรียก
ใช้งานผ่านบราวเซอร์ได้ที่ url  http://localhost หรือ http://127.0.0.1 หรือ http://ip adress  ที่ท่านกำหนด
 ดังตัวอย่างในภาพ



        การกำหนดให้ผู้ใช้งานทั่วไปให้ใช้งาน Apache 2 Web Server
            
การกำหนดให้ผู้ใช้งาน Apache 2 สามารถใช้งานภาษา HTML ได้ ทำได้โดยเปิดใช้คอนฟิกไฟล์
2 ไฟล์โดย root ดังนี้

submarine@Debian78:~$ su
Password: 
root@Debian78:/home/submarine# 

เปลี่ยนไปใช้ไดเรกทอรีที่ต้องการเชื่อมโยงคำสั่ง

root@Debian78:/home/submarine# cd /etc/apache2/mods-enabled
root@Debian78:/etc/apache2/mods-enabled# 

สั่งเปิดใช้งานคอนฟิกไฟล์ 2 ไฟล์ ดังนี้

root@Debian78:/etc/apache2/mods-enabled# ln -s ../mods-available/userdir.conf userdir.conf

root@Debian78:/etc/apache2/mods-enabled# ln -s ../mods-available/userdir.load userdir.load

สั่งรัน Apache ใหม่อีกรอบเพื่อโหลดคำสั่งที่เพิ่มขึ้น


root@Debian78:/etc/apache2/mods-enabled# /etc/init.d/apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
root@Debian78:/etc/apache2/mods-enabled# 

ทดลองใช้งานภาษา HTML ของผู้ใช้งานทั่วไปโดยสร้างไดเรกทอรี ชื่อ public_html เพื่อเก็บ
ไฟล์ภาษา HTML หรือภาษาอื่น เช่น Php และภาษา Python เป็นต้น ตัวอย่างต่อไปนี้ผู้เขียนจะใช้ผู้
ใช้งานทั่วไป ชื่อ submarine ทดลองใช้งานภาษา HTML ดังนี้

submarine@Debian78:~$ mkdir public_html

เปิดใช้งานไดเรคทอรีที่สร้างขึ้นเพื่อเก็บไฟล์ที่เว็บเพจ

submarine@Debian78:~$ cd public_html/
submarine@Debian78:~/public_html$ 

สร้างไฟล์ตัวอย่างภาษา HTML ชื่อ index.html

submarine@Debian78:~/public_html$ pico index.html 



<html><body><h1>It works!</h1>
<p>ทดสอบการใช้งานภาษา HTML ของผู้ใช้งานทั่วไปที่ไม่ใช่ root</p>
<p>เวอร์ชั่นหลัง ๆ ของ Apache จะต้องคอนฟิกเพิ่มเติมตามที่กล่าวมาแล้ว ค่าเริ่มต้นจะต่างจากเวอร์ชั่นแรก ๆ ครับ</p>
</body></html>

การเขียนเว็บเพจภาษา HTML เดี๋ยวนี้ทำได้ง่ายขึ้นมากมีโปรแกรมสำเร็จรูปช่วยเขียน แต่
จากประสบการณ์ของผู้เขียนในช่วงแรก ๆ ที่สอนนักเรียน ผู้เขียนจะเน้นให้นักเรียนเขียน
ด้วย Command line interface เช่น จากเครื่องระบบปฏิบัติการวินโดวส์หลังจากเพิ่มชื่อผู้ใช้งาน
ระบบแล้ว จะอธิบายว่าเราเชื่อมต่อระบบเครือข่ายคอมพิวเตอร์ให้สามารถสื่อสารข้อมูลกันได้
มี Server เป็นระบบปฏิบัติการลินุกซ์อยู่หน้าชั้นเรียน ทุกคนสามารถใช้งานคอมพิวเตอร์ที่เป็น
Server ได้พร้อมกัน ครูต้องเพิ่มชื่อ และกำหนดรหัสผ่านก่อนจึงจะใช้งานได้ ให้นักเรียนตั้งชื่อ
ผู้ใช้งานและรหัสผ่านเป็นภาษาอังกฤษส่งครู และจำไว้เพราะต้องใช้งานทุกครั้งที่ใช้ Server
ครูก็ถือโอกาสสอนว่าการตั้งชื่อ username และ password ที่มีลักษณะอย่างไร
        เมื่อมี username กับ password แล้วครูก็อธิบายวิธีติดต่อกับ Server โดยใช้โปรแกรมติดต่อ
เครือข่ายระยะไกล เช่น โปีแกรม putty เป็นต้น  ครูควรสอนให้นักเรียนเข้าใจภาษา HTML
ให้เข้าพอระดับหนึ่งก่อนให้ใช้โปรแกรมสำเร็จรูปเขียนเว็บเพจ
        กลับเข้ามาเรื่องกำลังเสนอ  เมื่อเขียนไฟล์ index.html แล้วเราสามารถเรียนใช้งานเว็บเพจ
ที่เขียนขึ้นด้วยบราวเซอร์ที่ url http://ip address/~username

        ตัวอย่าง เช่น Server ที่ผู้เขียนใช้งานมีไอพีแอดเดรส 192.168.1.104 , username ชื่อ
submarine ก็ใช้ url  http://192.168.1.104/~submarine จะได้ผลดังตัวอย่าง


        งานเข้าแล้วครับ ภาษาไทยไม่แสดงผล ดังนั้นผู้บริหารงานระบบ (Administrator) ที่ดีต้อง
กำหนดให้ Apache Web Server ให้สามารถภาษาไทยได้  ทำได้ดังนี้

        แก้ไขไฟล์ /etc/apache2/conf.d/charset ให้แสดงผลเป็นภาษาไทย utf-d  โดยเพิ่มข้อความ
AddDefaultCharset UTF-8  ลงในไฟล์ ดังตัวอย่าง


# Read the documentation before enabling AddDefaultCharset.
# In general, it is only a good idea if you know that all your files
# have this encoding. It will override any encoding given in the files
# in meta http-equiv or xml encoding tags.

AddDefaultCharset UTF-8


   เหมือนเช่นเคยการแก้ไขคอนฟิกไฟล์ในระบบต้องแก้ไขโดย root  เมื่อแก้ไขเสร็จสั่งให้
Apache web server ทำงานใหม่อีกครั้งเพื่อโหลดคำสั่งที่เขียนเพิ่มลงไป

root@Debian78:/home/submarine# 
root@Debian78:/home/submarine# /etc/init.d/apache2 force-reload
[ ok ] Reloading web server config: apache2.
root@Debian78:/home/submarine# 

        เมื่อเรียกใช้งานผ่านบราวเซอร์ Web server ก็จะสามารถใช้งานภาษาไทยได้ตามต้องการ



        นอกจากรองรับภาษา HTML แล้ว Apache web server ยังรองรับการใช้งานภาษาอื่น ๆ ที่เป็น
ภาษาสคริปต์ได้ เช่น ภาษา Perl, Php, Python ซึ่งผู้เขียนได้ได้กล่าวถึงมาแล้วในบทความก่อน ๆ




วันศุกร์ที่ 16 มกราคม พ.ศ. 2558

Sound & Video on Debian 7.8 NGU/Linux

        Debian GNU/Linux เป็นดิสทริบิวชั่นที่ออกแบบมาสำหรับการใช้งานเป็น servers
อย่างไรก็ตามดิสทริบิวชั่นหลังสามารถใช้งานเป็น Desktop ด้วยได้ดีทีเดียว คงไม่มีใครปฏิเสธ
ความบันเทิง ดูหนัง ฟังเพลงไปด้วยด้วยขณะที่ใช้คอมพิวเตอร์  Debian 7.8 ก็รองรับการใช้งาน
เหล่านี้เช่นเดียวกัน
        ผู้เขียนขอแนะนำแพคเกจสำหรับใช้งานมัลติมีเดียบน Debian 7.8 GNU/Linux



        



Debian 7.8 GNU/Linux Review

submarine@Debian78:~$ su
Password:
root@Debian78:/home/submarine# pico /etc/a
acpi/         adjtime       alternatives/ apache2/      apm/          at.deny       avahi/
adduser.conf  aliases       anacrontab    apg.conf      apt/          at-spi2/     
root@Debian78:/home/submarine# pico /etc/apt/sources.list
root@Debian78:/home/submarine# aptitude update
Hit http://ftp.us.debian.org wheezy Release.gpg                                                        
Hit http://ftp.us.debian.org wheezy-updates Release.gpg
Hit http://security.debian.org wheezy/updates Release.gpg
Hit http://ftp.us.debian.org wheezy Release
Hit http://security.debian.org wheezy/updates Release
Hit http://security.debian.org wheezy/updates/main Sources
Hit http://security.debian.org wheezy/updates/main i386 Packages          
Hit http://security.debian.org wheezy/updates/main Translation-en         
Hit http://ftp.us.debian.org wheezy-updates Release
Hit http://ftp.us.debian.org wheezy/main Sources
Hit http://ftp.us.debian.org wheezy/main i386 Packages
Hit http://ftp.us.debian.org wheezy/main Translation-en
Hit http://ftp.us.debian.org wheezy-updates/main Sources                                                       
Hit http://ftp.us.debian.org wheezy-updates/main i386 Packages/DiffIndex                                       
Hit http://ftp.us.debian.org wheezy-updates/main Translation-en/DiffIndex                                      
                                                                                                   4,122 kB/s 0s
root@Debian78:/home/submarine# nmap localhost

Starting Nmap 6.00 ( http://nmap.org ) at 2015-01-15 21:48 EST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000032s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 997 closed ports
PORT    STATE SERVICE
25/tcp  open  smtp
111/tcp open  rpcbind
631/tcp open  ipp

Nmap done: 1 IP address (1 host up) scanned in 0.35 seconds
root@Debian78:/home/submarine#
root@Debian78:/home/submarine#
root@Debian78:/home/submarine# top

top - 22:40:56 up  1:29,  2 users,  load average: 0.28, 0.09, 0.07
Tasks: 117 total,   2 running, 115 sleeping,   0 stopped,   0 zombie
%Cpu(s): 37.5 us, 25.0 sy,  0.0 ni, 37.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   1020572 total,   731684 used,   288888 free,    86572 buffers
KiB Swap:   975868 total,        0 used,   975868 free,   509716 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND                                          
 4290 root      20   0 35636 9064 4324 S  42.2  0.9   0:15.41 Xorg                                             
 5434 root      20   0  4516 1376 1016 R  42.2  0.1   0:05.00 top                                              
    1 root      20   0  2288  736  632 S   0.0  0.1   0:01.38 init                                             
    2 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kthreadd                                         
    3 root      20   0     0    0    0 S   0.0  0.0   0:00.38 ksoftirqd/0                                      
    6 root      rt   0     0    0    0 S   0.0  0.0   0:00.49 migration/0                                      
    7 root      rt   0     0    0    0 S   0.0  0.0   0:00.04 watchdog/0                                       
    8 root      rt   0     0    0    0 S   0.0  0.0   0:00.04 migration/1                                      
   10 root      20   0     0    0    0 S   0.0  0.0   0:00.14 ksoftirqd/1                                      
   12 root      rt   0     0    0    0 S   0.0  0.0   0:00.03 watchdog/1                                       
   13 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 cpuset                                           
   14 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 khelper                                          
   15 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kdevtmpfs                                        
   16 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 netns                                            
   17 root      20   0     0    0    0 S   0.0  0.0   0:00.03 sync_supers                                      
   18 root      20   0     0    0    0 S   0.0  0.0   0:00.00 bdi-default                                      
   19 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kintegrityd                                      
   20 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kblockd                                          
   21 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kworker/1:1                                      
root@Debian78:/home/submarine#
root@Debian78:/home/submarine#
root@Debian78:/home/submarine# uname -a
Linux Debian78 3.2.0-4-686-pae #1 SMP Debian 3.2.65-1+deb7u1 i686 GNU/Linux
root@Debian78:/home/submarine#
root@Debian78:/home/submarine#
root@Debian78:/home/submarine# lsb_release -a
No LSB modules are available.
Distributor ID:    Debian
Description:    Debian GNU/Linux 7.8 (wheezy)
Release:    7.8
Codename:    wheezy
root@Debian78:/home/submarine#
root@Debian78:/home/submarine#
root@Debian78:/home/submarine#


 root@Debian78:/home/submarine# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:23:8b:04:09:ea
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:44 Base address:0xe000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2027 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2027 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:85572 (83.5 KiB)  TX bytes:85572 (83.5 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:23:4d:b3:a2:b0
          inet addr:192.168.1.104  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::223:4dff:feb3:a2b0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7886 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6292 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7377153 (7.0 MiB)  TX bytes:831615 (812.1 KiB)

root@Debian78:/home/submarine#


วันพฤหัสบดีที่ 15 มกราคม พ.ศ. 2558

Database Server บน Debian 7.8 GNU/Linux

        ฐานข้อมูลเป็น Debian 78 GNU Linux ผู้เขียนชอบใช้อยู่ 2 ตัว คือ MySQL และ PostgreSQL
ทั้งสองตัวเป็น Opensource software ใช้งานง่ายสามารถใช้กับภาษาสคริปต์เพื่อใช้งานผ่าน
Web server เช่น ภาษา Perl, Java, Php, Python ตัวอย่างดังที่ผู้เขียนได้นำเสนอในบทความก่อน ๆ
         การติดตั้งฐานข้อมูลท่านสามารถศึกษารายละเอียดจากบทความเรื่อง Web server โดย
ผู้เขียนจะติดตั้งพร้อมกันทั้ง Apache2, MySQL-server, PostgreSQL, Php5, PhpMyAdmin,
PhpPgAdmin และ PgAdmin3 โดยแพคเกจต่าง ๆ จะมีฟังก์ชั่นการใช้งานดังนี้
        Apache 2 ใช้งานเป็น Web server สามารถแสดงผลโปรแกแรมภาษา html ภาษาสคริปต์ที่
ใช้ติดต่อฐานข้อมูลได้ เช่น ภาษา Perl, Php และ Python เป็นต้น
        MySQL-server

วันพุธที่ 14 มกราคม พ.ศ. 2558

Upgrade Debian 7.7 to Debian 7.8 GNU/Linux



          10 มกราคม 2558 ที่ผ่านมาผู้พัฒนาระบบปฏิบัติการลินุกซ์ Debian GNU/Linux ได้ประกาศ
เผยแพร่ Debian 7.8 GNU/Linux โดยไก้แก้ไขบัก และเพิ่มแพคเกจใหม่ ๆ ท่านใดสนใจก็สามารถ
อัพเกรด Debian ดิสทริบิวชั่นก่อน ๆ มาเป็น Debian 7.8 โดยใช้ root user  ตามคำสั่ง ดังนี้

        ลองตรวจสอบรายละเอียดของดิสทริบิวชั่นเดิม ด้วยคำสั่ง lsb_release -a

root@Sotharavej:/home/submarine# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.7 (wheezy)
Release: 7.7
Codename: wheezy
root@Sotharavej:/home/submarine#

     



        ก่อนอัพเกรด ต้องอัพเดทแพคเกจให้เป็นปัจจุบันเสียก่อนด้วยคำสั่ง apt-get update หรือ
aptitude update

root@Sotharavej:/home/submarine# apt-get update
Ign file: unstable Release.gpg
Ign file: unstable Release                                                  
Err file: unstable/main i386 Packages                                        
  File not found
Err file: unstable/contrib i386 Packages                                    
  File not found
Err file: unstable/non-free i386 Packages                                    
  File not found
Ign file: unstable/contrib Translation-en_US                                
Ign file: unstable/contrib Translation-en                                    
Ign file: unstable/main Translation-en_US                                    
Ign file: unstable/main Translation-en                                      
Ign file: unstable/non-free Translation-en_US                                
Ign file: unstable/non-free Translation-en                                  
Get:1 http://dl.google.com stable Release.gpg [198 B]                        
Get:2 http://dl.google.com stable Release [1,347 B]                          
Get:3 http://dl.google.com stable/main i386 Packages [1,216 B]              
Get:4 http://ftp.us.debian.org wheezy Release.gpg [1,655 B]                  
Get:5 http://ftp.debian.org wheezy-backports Release.gpg [836 B]            
Get:6 http://security.debian.org wheezy/updates Release.gpg [836 B]          
Ign http://dl.google.com stable/main Translation-en_US                      
Get:7 http://ftp.us.debian.org wheezy-updates Release.gpg [836 B]            
Ign http://dl.google.com stable/main Translation-en                          
Get:8 http://security.debian.org wheezy/updates Release [102 kB]            
Get:9 http://ftp.debian.org wheezy-backports Release [147 kB]                
Get:10 http://ftp.us.debian.org wheezy Release [168 kB]                      
Get:11 http://security.debian.org wheezy/updates/main Sources [147 kB]      
Get:12 http://ftp.debian.org wheezy-backports/main i386 Packages/DiffIndex [7,819 B]
Get:13 http://ftp.us.debian.org wheezy-updates Release [124 kB]              
Get:14 http://ftp.debian.org wheezy-backports/contrib i386 Packages/DiffIndex [5,197 B]
Get:15 http://security.debian.org wheezy/updates/main i386 Packages [238 kB]
Get:16 http://ftp.us.debian.org wheezy/main Sources [5,971 kB]              
Get:17 http://ftp.debian.org wheezy-backports/non-free i386 Packages/DiffIndex [6,163 B]
Hit http://ftp.debian.org wheezy-backports/contrib Translation-en/DiffIndex  
Get:18 http://ftp.debian.org wheezy-backports/main Translation-en/DiffIndex [7,819 B]
Get:19 http://ftp.debian.org wheezy-backports/non-free Translation-en/DiffIndex [4,369 B]
Get:20 http://ftp.debian.org wheezy-backports/main i386 2015-01-07-1442.54.pdiff [632 B]
Get:21 http://ftp.debian.org wheezy-backports/main i386 2015-01-07-1442.54.pdiff [632 B]
Get:22 http://ppa.launchpad.net lucid Release.gpg [316 B]                    
Get:23 http://ftp.debian.org wheezy-backports/contrib i386 2015-01-13-1445.58.pdiff [251 B]
Hit http://ppa.launchpad.net lucid Release                                  
Get:24 http://ftp.debian.org wheezy-backports/contrib i386 2015-01-13-1445.58.pdiff [251 B]
Hit http://ppa.launchpad.net lucid/main i386 Packages                        
Get:25 http://ftp.debian.org wheezy-backports/non-free i386 2015-01-08-2046.20.pdiff [1,498 B]
Get:26 http://ftp.debian.org wheezy-backports/non-free i386 2015-01-08-2046.20.pdiff [1,498 B]
Get:27 http://ftp.debian.org wheezy-backports/main 2015-01-07-1442.54.pdiff [424 B]
Get:28 http://ftp.debian.org wheezy-backports/main 2015-01-07-1442.54.pdiff [424 B]
Get:29 http://ftp.debian.org wheezy-backports/non-free 2015-01-08-2046.20.pdiff [779 B]
Get:30 http://ftp.debian.org wheezy-backports/non-free 2015-01-08-2046.20.pdiff [779 B]
Get:31 http://ftp.debian.org wheezy-backports/main i386 2015-01-07-2046.15.pdiff [1,945 B]
Get:32 http://ftp.debian.org wheezy-backports/main i386 2015-01-07-2046.15.pdiff [1,945 B]
Get:33 http://ftp.debian.org wheezy-backports/non-free i386 2015-01-13-0843.36.pdiff [31 B]
Get:34 http://ftp.debian.org wheezy-backports/non-free i386 2015-01-13-0843.36.pdiff [31 B]
Get:35 http://ftp.debian.org wheezy-backports/main 2015-01-08-2046.20.pdiff [226 B]
Get:36 http://ftp.debian.org wheezy-backports/main 2015-01-08-2046.20.pdiff [226 B]
Get:37 http://ftp.debian.org wheezy-backports/non-free 2015-01-13-0843.36.pdiff [31 B]
Get:38 http://ftp.debian.org wheezy-backports/non-free 2015-01-13-0843.36.pdiff [31 B]
Get:39 http://ftp.debian.org wheezy-backports/main i386 2015-01-08-2046.20.pdiff [677 B]
Get:40 http://ftp.debian.org wheezy-backports/main i386 2015-01-08-2046.20.pdiff [677 B]
Get:41 http://ftp.us.debian.org wheezy/main i386 Packages [5,859 kB]        
Ign http://ppa.launchpad.net lucid/main Translation-en_US                    
Get:42 http://security.debian.org wheezy/updates/main Translation-en [134 kB]
Ign http://ppa.launchpad.net lucid/main Translation-en                      
Get:43 http://ftp.debian.org wheezy-backports/main 2015-01-12-0242.53.pdiff [435 B]
Get:44 http://ftp.debian.org wheezy-backports/main 2015-01-12-0242.53.pdiff [435 B]
Get:45 http://ftp.debian.org wheezy-backports/main i386 2015-01-12-0242.53.pdiff [1,410 B]
Get:46 http://ftp.debian.org wheezy-backports/main i386 2015-01-12-0242.53.pdiff [1,410 B]
Get:47 http://ftp.debian.org wheezy-backports/main 2015-01-13-0843.36.pdiff [340 B]
Get:48 http://ftp.debian.org wheezy-backports/main 2015-01-13-0843.36.pdiff [340 B]
Get:49 http://ftp.debian.org wheezy-backports/main i386 2015-01-12-0843.51.pdiff [1,937 B]
Get:50 http://ftp.debian.org wheezy-backports/main i386 2015-01-12-0843.51.pdiff [1,937 B]
Get:51 http://ftp.debian.org wheezy-backports/main 2015-01-13-1445.58.pdiff [406 B]
Get:52 http://ftp.debian.org wheezy-backports/main 2015-01-13-1445.58.pdiff [406 B]
Get:53 http://ftp.debian.org wheezy-backports/main i386 2015-01-13-1445.58.pdiff [513 B]
Get:54 http://ftp.debian.org wheezy-backports/main i386 2015-01-13-1445.58.pdiff [513 B]
Get:55 http://ftp.us.debian.org wheezy/main Translation-en [3,848 kB]        
Get:56 http://ftp.us.debian.org wheezy-updates/main Sources [1,805 B]                                        
Hit http://ftp.us.debian.org wheezy-updates/main i386 Packages/DiffIndex                                    
Hit http://ftp.us.debian.org wheezy-updates/main Translation-en/DiffIndex                                    
Fetched 16.8 MB in 21s (764 kB/s)                                                                            
W: Failed to fetch file:/root/packages/dists/unstable/main/binary-i386/Packages  File not found

W: Failed to fetch file:/root/packages/dists/unstable/contrib/binary-i386/Packages  File not found

W: Failed to fetch file:/root/packages/dists/unstable/non-free/binary-i386/Packages  File not found

E: Some index files failed to download. They have been ignored, or old ones used instead.
root@Sotharavej:/home/submarine#


        อัพเกรดเป็น  Debian 7.8 GNU/Linux  ด้วยคำสั่ง apt-get upgrade หรือ aptitude upgrade

root@Sotharavej:/home/submarine# apt-get upgrade
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following packages will be upgraded:
  apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common apt apt-utils base-files binutils
  debian-archive-keyring evolution-data-server evolution-data-server-common file google-chrome-stable
  libapache2-mod-php5 libapt-inst1.5 libapt-pkg4.12 libcamel-1.2-33 libcurl3 libcurl3-gnutls libebackend-1.2-2
  libebook-1.2-13 libecal-1.2-11 libedata-book-1.2-13 libedata-cal-1.2-15 libedataserver-1.2-16
  libedataserverui-3.0-1 libevent-2.0-5 libmagic1 libssl1.0.0 linux-image-3.2.0-4-686-pae openssl php5
  php5-cli php5-common php5-gd php5-mcrypt php5-mysql php5-pgsql tzdata tzdata-java wireless-regdb
42 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 96.8 MB of archives.
After this operation, 1,039 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://dl.google.com/linux/chrome/deb/ stable/main google-chrome-stable i386 39.0.2171.99-1 [47.4 MB]
Get:2 http://ftp.us.debian.org/debian/ wheezy/main base-files i386 7.1wheezy8 [67.0 kB]                      
Get:3 http://security.debian.org/ wheezy/updates/main libssl1.0.0 i386 1.0.1e-2+deb7u14 [3,037 kB]
Get:4 http://ftp.us.debian.org/debian/ wheezy/main libapt-pkg4.12 i386 0.9.7.9+deb7u7 [902 kB]              
Get:5 http://ftp.us.debian.org/debian/ wheezy/main debian-archive-keyring all 2014.3~deb7u1 [60.7 kB]        
Get:6 http://ftp.us.debian.org/debian/ wheezy/main apt i386 0.9.7.9+deb7u7 [1,254 kB]                        
Get:7 http://ftp.us.debian.org/debian/ wheezy/main libapt-inst1.5 i386 0.9.7.9+deb7u7 [167 kB]              
Get:8 http://ftp.us.debian.org/debian/ wheezy/main linux-image-3.2.0-4-686-pae i386 3.2.65-1 [23.0 MB]      
Get:9 http://security.debian.org/ wheezy/updates/main libevent-2.0-5 i386 2.0.19-stable-3+deb7u1 [171 kB]    
Get:10 http://security.debian.org/ wheezy/updates/main file i386 5.11-2+deb7u7 [53.1 kB]                    
Get:11 http://security.debian.org/ wheezy/updates/main libmagic1 i386 5.11-2+deb7u7 [206 kB]                
Get:12 http://security.debian.org/ wheezy/updates/main libcurl3 i386 7.26.0-1+wheezy12 [336 kB]              
Get:13 http://security.debian.org/ wheezy/updates/main libcurl3-gnutls i386 7.26.0-1+wheezy12 [326 kB]      
Get:14 http://security.debian.org/ wheezy/updates/main php5-cli i386 5.4.36-0+deb7u3 [2,641 kB]              
Get:15 http://security.debian.org/ wheezy/updates/main libapache2-mod-php5 i386 5.4.36-0+deb7u3 [2,664 kB]  
Get:16 http://ftp.us.debian.org/debian/ wheezy/main tzdata-java all 2014j-0wheezy1 [130 kB]                  
Get:17 http://ftp.us.debian.org/debian/ wheezy/main tzdata all 2014j-0wheezy1 [442 kB]                      
Get:18 http://ftp.us.debian.org/debian/ wheezy/main apache2 i386 2.2.22-13+deb7u4 [1,438 B]                  
Get:19 http://ftp.us.debian.org/debian/ wheezy/main apache2-mpm-prefork i386 2.2.22-13+deb7u4 [2,348 B]      
Get:20 http://ftp.us.debian.org/debian/ wheezy/main apache2.2-common i386 2.2.22-13+deb7u4 [292 kB]          
Get:21 http://ftp.us.debian.org/debian/ wheezy/main apache2.2-bin i386 2.2.22-13+deb7u4 [776 kB]            
Get:22 http://ftp.us.debian.org/debian/ wheezy/main apache2-utils i386 2.2.22-13+deb7u4 [163 kB]            
Get:23 http://ftp.us.debian.org/debian/ wheezy/main apt-utils i386 0.9.7.9+deb7u7 [376 kB]                  
Get:24 http://ftp.us.debian.org/debian/ wheezy/main evolution-data-server i386 3.4.4-3+deb7u1 [799 kB]      
Get:25 http://ftp.us.debian.org/debian/ wheezy/main libcamel-1.2-33 i386 3.4.4-3+deb7u1 [771 kB]            
Get:26 http://security.debian.org/ wheezy/updates/main php5-pgsql i386 5.4.36-0+deb7u3 [62.7 kB]            
Get:27 http://ftp.us.debian.org/debian/ wheezy/main libedataserver-1.2-16 i386 3.4.4-3+deb7u1 [499 kB]      
Get:28 http://security.debian.org/ wheezy/updates/main php5-mysql i386 5.4.36-0+deb7u3 [77.1 kB]            
Get:29 http://ftp.us.debian.org/debian/ wheezy/main libebackend-1.2-2 i386 3.4.4-3+deb7u1 [430 kB]          
Get:30 http://security.debian.org/ wheezy/updates/main php5-mcrypt i386 5.4.36-0+deb7u3 [15.6 kB]            
Get:31 http://security.debian.org/ wheezy/updates/main php5-gd i386 5.4.36-0+deb7u3 [34.4 kB]                
Get:32 http://ftp.us.debian.org/debian/ wheezy/main libebook-1.2-13 i386 3.4.4-3+deb7u1 [496 kB]            
Get:33 http://security.debian.org/ wheezy/updates/main php5-common i386 5.4.36-0+deb7u3 [619 kB]            
Get:34 http://ftp.us.debian.org/debian/ wheezy/main libecal-1.2-11 i386 3.4.4-3+deb7u1 [524 kB]              
Get:35 http://ftp.us.debian.org/debian/ wheezy/main libedata-book-1.2-13 i386 3.4.4-3+deb7u1 [471 kB]        
Get:36 http://ftp.us.debian.org/debian/ wheezy/main libedata-cal-1.2-15 i386 3.4.4-3+deb7u1 [485 kB]        
Get:37 http://security.debian.org/ wheezy/updates/main binutils i386 2.22-8+deb7u2 [4,555 kB]                
Get:38 http://ftp.us.debian.org/debian/ wheezy/main evolution-data-server-common all 3.4.4-3+deb7u1 [1,359 kB]
Get:39 http://ftp.us.debian.org/debian/ wheezy/main libedataserverui-3.0-1 i386 3.4.4-3+deb7u1 [498 kB]      
Get:40 http://ftp.us.debian.org/debian/ wheezy/main wireless-regdb all 2014.10.07-1~deb7u1 [6,982 B]        
Get:41 http://security.debian.org/ wheezy/updates/main openssl i386 1.0.1e-2+deb7u14 [694 kB]                
Get:42 http://security.debian.org/ wheezy/updates/main php5 all 5.4.36-0+deb7u3 [1,026 B]                    
Fetched 96.8 MB in 1min 44s (925 kB/s)                                                                      
Reading changelogs... Done
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 144618 files and directories currently installed.)
Preparing to replace base-files 7.1wheezy7 (using .../base-files_7.1wheezy8_i386.deb) ...
Unpacking replacement base-files ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Setting up base-files (7.1wheezy8) ...
Installing new version of config file /etc/debian_version ...
(Reading database ... 144618 files and directories currently installed.)
Preparing to replace libapt-pkg4.12:i386 0.9.7.9+deb7u6 (using .../libapt-pkg4.12_0.9.7.9+deb7u7_i386.deb) ...
Unpacking replacement libapt-pkg4.12:i386 ...
Setting up libapt-pkg4.12:i386 (0.9.7.9+deb7u7) ...
(Reading database ... 144618 files and directories currently installed.)
Preparing to replace debian-archive-keyring 2014.1~deb7u1 (using .../debian-archive-keyring_2014.3~deb7u1_all.deb) ...
Unpacking replacement debian-archive-keyring ...
Setting up debian-archive-keyring (2014.3~deb7u1) ...
(Reading database ... 144620 files and directories currently installed.)
Preparing to replace apt 0.9.7.9+deb7u6 (using .../apt_0.9.7.9+deb7u7_i386.deb) ...
Unpacking replacement apt ...
Processing triggers for man-db ...
Setting up apt (0.9.7.9+deb7u7) ...
gpg: key B98321F9: "Squeeze Stable Release Key <debian-release@lists.debian.org>" not changed
gpg: key 473041FA: "Debian Archive Automatic Signing Key (6.0/squeeze) <ftpmaster@debian.org>" not changed
gpg: key 65FFB764: "Wheezy Stable Release Key <debian-release@lists.debian.org>" not changed
gpg: key 46925553: "Debian Archive Automatic Signing Key (7.0/wheezy) <ftpmaster@debian.org>" not changed
gpg: key 518E17E1: "Jessie Stable Release Key <debian-release@lists.debian.org>" not changed
gpg: key 2B90D010: "Debian Archive Automatic Signing Key (8/jessie) <ftpmaster@debian.org>" not changed
gpg: key C857C906: "Debian Security Archive Automatic Signing Key (8/jessie) <ftpmaster@debian.org>" not changed
gpg: Total number processed: 7
gpg:              unchanged: 7
(Reading database ... 144620 files and directories currently installed.)
Preparing to replace libapt-inst1.5:i386 0.9.7.9+deb7u6 (using .../libapt-inst1.5_0.9.7.9+deb7u7_i386.deb) ...
Unpacking replacement libapt-inst1.5:i386 ...
Preparing to replace libssl1.0.0:i386 1.0.1e-2+deb7u13 (using .../libssl1.0.0_1.0.1e-2+deb7u14_i386.deb) ...
Unpacking replacement libssl1.0.0:i386 ...
Preparing to replace libevent-2.0-5:i386 2.0.19-stable-3 (using .../libevent-2.0-5_2.0.19-stable-3+deb7u1_i386.deb) ...
Unpacking replacement libevent-2.0-5:i386 ...
Preparing to replace file 5.11-2+deb7u6 (using .../file_5.11-2+deb7u7_i386.deb) ...
Unpacking replacement file ...
Preparing to replace libmagic1:i386 5.11-2+deb7u6 (using .../libmagic1_5.11-2+deb7u7_i386.deb) ...
Unpacking replacement libmagic1:i386 ...
Preparing to replace libcurl3:i386 7.26.0-1+wheezy11 (using .../libcurl3_7.26.0-1+wheezy12_i386.deb) ...
Unpacking replacement libcurl3:i386 ...
Preparing to replace google-chrome-stable 39.0.2171.95-1 (using .../google-chrome-stable_39.0.2171.99-1_i386.deb) ...
Unpacking replacement google-chrome-stable ...
Preparing to replace libcurl3-gnutls:i386 7.26.0-1+wheezy11 (using .../libcurl3-gnutls_7.26.0-1+wheezy12_i386.deb) ...
Unpacking replacement libcurl3-gnutls:i386 ...
Preparing to replace linux-image-3.2.0-4-686-pae 3.2.63-2+deb7u2 (using .../linux-image-3.2.0-4-686-pae_3.2.65-1_i386.deb) ...
Unpacking replacement linux-image-3.2.0-4-686-pae ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
Preparing to replace tzdata-java 2014h-0wheezy1 (using .../tzdata-java_2014j-0wheezy1_all.deb) ...
Unpacking replacement tzdata-java ...
Preparing to replace tzdata 2014h-0wheezy1 (using .../tzdata_2014j-0wheezy1_all.deb) ...
Unpacking replacement tzdata ...
Processing triggers for man-db ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Processing triggers for menu ...
Setting up tzdata (2014j-0wheezy1) ...

Current default time zone: 'America/New_York'
Local time is now:      Wed Jan 14 04:46:02 EST 2015.
Universal Time is now:  Wed Jan 14 09:46:02 UTC 2015.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

(Reading database ... 144613 files and directories currently installed.)
Preparing to replace php5-cli 5.4.36-0+deb7u1 (using .../php5-cli_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement php5-cli ...
Preparing to replace apache2 2.2.22-13+deb7u3 (using .../apache2_2.2.22-13+deb7u4_i386.deb) ...
Unpacking replacement apache2 ...
Preparing to replace apache2-mpm-prefork 2.2.22-13+deb7u3 (using .../apache2-mpm-prefork_2.2.22-13+deb7u4_i386.deb) ...
[ ok ] Stopping web server: apache2 ... waiting .
Unpacking replacement apache2-mpm-prefork ...
Preparing to replace apache2.2-common 2.2.22-13+deb7u3 (using .../apache2.2-common_2.2.22-13+deb7u4_i386.deb) ...
Unpacking replacement apache2.2-common ...
Preparing to replace apache2.2-bin 2.2.22-13+deb7u3 (using .../apache2.2-bin_2.2.22-13+deb7u4_i386.deb) ...
Unpacking replacement apache2.2-bin ...
Preparing to replace apache2-utils 2.2.22-13+deb7u3 (using .../apache2-utils_2.2.22-13+deb7u4_i386.deb) ...
Unpacking replacement apache2-utils ...
Preparing to replace libapache2-mod-php5 5.4.36-0+deb7u1 (using .../libapache2-mod-php5_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement libapache2-mod-php5 ...
Preparing to replace php5-pgsql 5.4.36-0+deb7u1 (using .../php5-pgsql_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement php5-pgsql ...
Preparing to replace php5-mysql 5.4.36-0+deb7u1 (using .../php5-mysql_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement php5-mysql ...
Preparing to replace php5-mcrypt 5.4.36-0+deb7u1 (using .../php5-mcrypt_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement php5-mcrypt ...
Preparing to replace php5-gd 5.4.36-0+deb7u1 (using .../php5-gd_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement php5-gd ...
Preparing to replace php5-common 5.4.36-0+deb7u1 (using .../php5-common_5.4.36-0+deb7u3_i386.deb) ...
Unpacking replacement php5-common ...
Preparing to replace apt-utils 0.9.7.9+deb7u6 (using .../apt-utils_0.9.7.9+deb7u7_i386.deb) ...
Unpacking replacement apt-utils ...
Preparing to replace binutils 2.22-8 (using .../binutils_2.22-8+deb7u2_i386.deb) ...
Unpacking replacement binutils ...
Preparing to replace evolution-data-server 3.4.4-3 (using .../evolution-data-server_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement evolution-data-server ...
Preparing to replace libcamel-1.2-33 3.4.4-3 (using .../libcamel-1.2-33_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libcamel-1.2-33 ...
Preparing to replace libedataserver-1.2-16 3.4.4-3 (using .../libedataserver-1.2-16_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libedataserver-1.2-16 ...
Preparing to replace libebackend-1.2-2 3.4.4-3 (using .../libebackend-1.2-2_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libebackend-1.2-2 ...
Preparing to replace libebook-1.2-13 3.4.4-3 (using .../libebook-1.2-13_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libebook-1.2-13 ...
Preparing to replace libecal-1.2-11 3.4.4-3 (using .../libecal-1.2-11_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libecal-1.2-11 ...
Preparing to replace libedata-book-1.2-13 3.4.4-3 (using .../libedata-book-1.2-13_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libedata-book-1.2-13 ...
Preparing to replace libedata-cal-1.2-15 3.4.4-3 (using .../libedata-cal-1.2-15_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libedata-cal-1.2-15 ...
Preparing to replace evolution-data-server-common 3.4.4-3 (using .../evolution-data-server-common_3.4.4-3+deb7u1_all.deb) ...
Unpacking replacement evolution-data-server-common ...
Preparing to replace libedataserverui-3.0-1 3.4.4-3 (using .../libedataserverui-3.0-1_3.4.4-3+deb7u1_i386.deb) ...
Unpacking replacement libedataserverui-3.0-1 ...
Preparing to replace openssl 1.0.1e-2+deb7u13 (using .../openssl_1.0.1e-2+deb7u14_i386.deb) ...
Unpacking replacement openssl ...
Preparing to replace php5 5.4.36-0+deb7u1 (using .../php5_5.4.36-0+deb7u3_all.deb) ...
Unpacking replacement php5 ...
Preparing to replace wireless-regdb 2014.06.13-1~deb7u1 (using .../wireless-regdb_2014.10.07-1~deb7u1_all.deb) ...
Unpacking replacement wireless-regdb ...
Processing triggers for man-db ...
Processing triggers for libglib2.0-0:i386 ...
Setting up libapt-inst1.5:i386 (0.9.7.9+deb7u7) ...
Setting up libssl1.0.0:i386 (1.0.1e-2+deb7u14) ...
Setting up libevent-2.0-5:i386 (2.0.19-stable-3+deb7u1) ...
Setting up libmagic1:i386 (5.11-2+deb7u7) ...
Setting up file (5.11-2+deb7u7) ...
Setting up libcurl3:i386 (7.26.0-1+wheezy12) ...
Setting up google-chrome-stable (39.0.2171.99-1) ...
Setting up libcurl3-gnutls:i386 (7.26.0-1+wheezy12) ...
Setting up linux-image-3.2.0-4-686-pae (3.2.65-1) ...
Running depmod.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
update-initramfs: Generating /boot/initrd.img-3.2.0-4-686-pae
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8105e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168d-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168d-1.fw for module r8169
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
Generating grub.cfg ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.2.0-4-686-pae
Found initrd image: /boot/initrd.img-3.2.0-4-686-pae
Found Windows 7 (loader) on /dev/sda1
Found openSUSE 13.2 (x86_64) on /dev/sda2
done
Setting up tzdata-java (2014j-0wheezy1) ...
Setting up php5-common (5.4.36-0+deb7u3) ...
Setting up php5-cli (5.4.36-0+deb7u3) ...
Setting up apache2.2-bin (2.2.22-13+deb7u4) ...
Setting up apache2-utils (2.2.22-13+deb7u4) ...
Setting up apache2.2-common (2.2.22-13+deb7u4) ...
Setting up apache2-mpm-prefork (2.2.22-13+deb7u4) ...
[ ok ] Starting web server: apache2.
Setting up apache2 (2.2.22-13+deb7u4) ...
Setting up libapache2-mod-php5 (5.4.36-0+deb7u3) ...
[ ok ] Reloading web server config: apache2.
Setting up php5-pgsql (5.4.36-0+deb7u3) ...
Setting up php5-mysql (5.4.36-0+deb7u3) ...
Setting up php5-mcrypt (5.4.36-0+deb7u3) ...
Setting up php5-gd (5.4.36-0+deb7u3) ...
Setting up apt-utils (0.9.7.9+deb7u7) ...
Setting up binutils (2.22-8+deb7u2) ...
Setting up libcamel-1.2-33 (3.4.4-3+deb7u1) ...
Setting up libedataserver-1.2-16 (3.4.4-3+deb7u1) ...
Setting up libebackend-1.2-2 (3.4.4-3+deb7u1) ...
Setting up libebook-1.2-13 (3.4.4-3+deb7u1) ...
Setting up libecal-1.2-11 (3.4.4-3+deb7u1) ...
Setting up libedata-book-1.2-13 (3.4.4-3+deb7u1) ...
Setting up libedata-cal-1.2-15 (3.4.4-3+deb7u1) ...
Setting up evolution-data-server-common (3.4.4-3+deb7u1) ...
Setting up evolution-data-server (3.4.4-3+deb7u1) ...
Setting up libedataserverui-3.0-1 (3.4.4-3+deb7u1) ...
Setting up openssl (1.0.1e-2+deb7u14) ...
Setting up php5 (5.4.36-0+deb7u3) ...
Setting up wireless-regdb (2014.10.07-1~deb7u1) ...
Processing triggers for menu ...
Processing triggers for libapache2-mod-php5 ...
[ ok ] Reloading web server config: apache2.
root@Sotharavej:/home/submarine#
root@Sotharavej:/home/submarine#
root@Sotharavej:/home/submarine# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree    
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@Sotharavej:/home/submarine#

          ตรวจสอบว่าระบบอัพเกรดเป็น Debian 7.8 GNU/Linux หรือยัง

root@Sotharavej:/home/submarine# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezy
root@Sotharavej:/home/submarine#






วันอังคารที่ 13 มกราคม พ.ศ. 2558

การเขียนโปรแกรมภาษา Python ให้แสดงผลบน Web server บน Debian 7.7 GNU/Linux

        ภาษา Python เป็นภาษาคอมพิวเตอร์ชั้นสูง จัดเป็นภาษาสคริปต์ เช่นเดียวกับภาษา Java,
Perl, C เป็นภาษาที่นิยมนำมาใช้งานเป็นตัวเชื่อมต่อ (interface) ระหว่าง servers ภาษา Python ยัง
ทำงานเป็นภาษา CGI (Common Gateway Interface) ดังนั้นเพื่อรันผ่าน Apache web server ต้องนำ
ไฟล์ที่เขียนขึ้นไปเก็บไว้ที่ไดเรกทอรีที่สามารถรันภาษา CGI ได้ ในที่นี้บน Debian 7.7 GNU/Linux
เราจะรันภาษา Python ที่ไดเรกทอรี /usr/lib/cgi-bin

        การรันภาษา Python บน Aperche web server เราเพียงใช้คำสั่งข้างล่างนี้สั่งให้แสดงข้อมูล
บน web server ผ่านทางบราวเซอร์  เพียงแต่สั่งคำสั่งแสดงผลไว้ส่วนนำของโปรแกรม


print "Content-Type: text/plain;charset=utf-8"
print


        ตัวอย่างไฟล์ ชื่อ test.py เพื่อทดสอบการใช้งานภาษา Python บน Web server  รายละเอียด
โปรแกรม มีดังนี้


#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World! ทดสอบภาษา Python บน Apache web server with Debian 7.7 GNU/Linux"


        เมื่อแสดงผลทางบราวเซอร์จะได้ดังภาพ





        ลองนำไฟล์ select_data.py มาเพิ่มคำสั่งให้แสดงผลผ่านบราวเซอร์ และเก็บไว้ในไดเรคทอรี
ที่รันภาษา CGI ได้  กำหนดสิทธิ์ให้อ่านเขียนข้อมูลได้  และเรียกใช้งานผ่านบราวเซอร์
รายละเอียดโปรแกรมมี ดังนี้


#!/usr/bin/python

import psycopg2

print "Content-Type: text/plain;charset=utf-8"
print

conn = psycopg2.connect(database="python", user="submarine", password="xxxxxxxxxxxx", host="127.0.0.1", port="5432")
print "Opened database successfully"

cur = conn.cursor()

cur.execute("SELECT id, name, address, salary  from persons")
rows = cur.fetchall()
for row in rows:
   print "ID = ", row[0]
   print "NAME = ", row[1]
   print "ADDRESS = ", row[2]
   print "SALARY = ", row[3], "\n"

print "Operation done successfully";
conn.close()

       เรียกใช้งานที่  http://localhost/cgi-bin/select_data.py จะได้ผลดังภาพ



การเขียนโปรแกรมภาษา Python เพื่อเชื่อมต่อ PostgreSQL Database server บน Debian 7.7 GNU/Linux

          Debian 7.7 GNU/Linux ได้ติดตั้งภาษา Python 2.7.3 มาเป็นค่าเริ่มต้นแล้ว ผู้เขียนได้กล่าวถึง
การใช้งานภาษา Python มาบ้างแล้วในบทความ เรื่อง การประมวลผลภาพ (Image Processing) ด้วย
ภาษา Python  ในบทความนี้จะกล่าวถึงการใช้ภาษา Python เป็นตัวเชื่อม (interface) กับ PostgreSQL
Database server


        การใช้ภาษา python เพื่อเชื่อมต่อกับ PostgreSQL Database server ต้องติดตั้งชุดโปรแกรม
(Library) python-psycopg2 เพิ่มเติม


        ใช้ root user เพื่อติดตั้งชุดดปรแกรม ดังตัวอย่าง

submarine@Debian77:~$ su
Password:
root@Debian77:/home/submarine# aptitude install python-psycopg2
The following NEW packages will be installed:
  python-egenix-mxdatetime{a} python-egenix-mxtools{a} python-psycopg2
0 packages upgraded, 3 newly installed, 0 to remove and 85 not upgraded.
Need to get 469 kB of archives. After unpacking 1,783 kB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://ftp.us.debian.org/debian/ wheezy/main python-egenix-mxtools i386 3.2.1-1.1 [108 kB]
Get: 2 http://ftp.us.debian.org/debian/ wheezy/main python-egenix-mxdatetime i386 3.2.1-1.1 [111 kB]
Get: 3 http://ftp.us.debian.org/debian/ wheezy/main python-psycopg2 i386 2.4.5-1 [250 kB]
Fetched 469 kB in 3s (134 kB/s)        
Selecting previously unselected package python-egenix-mxtools.
(Reading database ... 154014 files and directories currently installed.)
Unpacking python-egenix-mxtools (from .../python-egenix-mxtools_3.2.1-1.1_i386.deb) ...
Selecting previously unselected package python-egenix-mxdatetime.
Unpacking python-egenix-mxdatetime (from .../python-egenix-mxdatetime_3.2.1-1.1_i386.deb) ...
Selecting previously unselected package python-psycopg2.
Unpacking python-psycopg2 (from .../python-psycopg2_2.4.5-1_i386.deb) ...
Setting up python-egenix-mxtools (3.2.1-1.1) ...
Setting up python-egenix-mxdatetime (3.2.1-1.1) ...
Setting up python-psycopg2 (2.4.5-1) ...
                                       
root@Debian77:/home/submarine# exit
exit
submarine@Debian77:~$ clear

        สร้าง Python directory เพื่อเก็บข้อมูล และไฟล์ที่เกียวข้อง

submarine@Debian77:~$ mkdir Python
submarine@Debian77:~$ cd Python/

        ลองเรียกใช้โปรแกรมภาษา Python

submarine@Debian77:~/Python$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

       ออกจากโปรแกรมด้วยคำสั่ง  Ctrl+D

       ผู้เขียนสร้างฐานข้อมูลบน PostgreSQLชื่อ python

       เขียนโปรแกรมภาษา Python ชื่อ connect_database.py เพื่อติดต่อฐานข้อมูล ดังนี้

submarine@Debian77:~/Python$ pico connect_database.py

#!/usr/bin/python

import psycopg2

conn = psycopg2.connect(database="python", user="submarine", password="xxxxxxxxxxxx", host="127.0.0.1", port="543$

print "Opened database successfully"


        สั่งรันโปรแกรมด้วยคำสั่ง python  และผลการรันโปรแกรม

submarine@Debian77:~/Python$ python connect_database.py
Opened database successfully

       เมื่อโปรแกรมติดต่อฐานข้อมูลได้แล้ว  ลองศึกษาตัวอย่างไฟล์ create_table.py เขียนขึ้น
เพื่อสร้างตาราง ชื่อ persons บนฐานข้อมูล python  ดังนี้

#!/usr/bin/python

import psycopg2

conn = psycopg2.connect(database="python", user="submarine", password="xxxxxxxxxxxx", host="127.0.0.1", port="5$
print "Opened database successfully"

cur = conn.cursor()
cur.execute('''CREATE TABLE persons
       (ID INT PRIMARY KEY     NOT NULL,
       NAME           TEXT    NOT NULL,
       AGE            INT     NOT NULL,
       ADDRESS        CHAR(50),
       SALARY         REAL);''')
print "Table created successfully"

conn.commit()
conn.close()

     
        สั่งรันโปรแกรม และผลลัพธ์

submarine@Debian77:~/Python$ python create_table.py

Opened database successfully
Table created successfully

submarine@Debian77:~/Python$

        ตัวอย่างต่อไปนี้เป็นการโปรแกรม ชื่อ ไฟล์ insert_data.py  เพื่อใส่ข้อมูลลงในตาราง ชื่อ
persons บนฐานข้อมูลที่ python ที่สร้างขึ้น  รายละเอียดโปรแกรมมีดังนี้


#!/usr/bin/python

import psycopg2

conn = psycopg2.connect(database="python", user="submarine", password="xxxxxxxxxxxx", host="127.0.0.1", port="5432")
print "Opened database successfully"

cur = conn.cursor()

cur.execute("INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY) \
      VALUES (1, 'Weerapong  Srichaj', 32, 'Chacheongsao', 200000.00 )");

cur.execute("INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY) \
      VALUES (2, 'Prasit  Srichaj', 25, 'Prachin Buri', 15000.00 )");

cur.execute("INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY) \
      VALUES (3, 'Somchit  Srichaj', 23, 'Skon Nakhon', 20000.00 )");

cur.execute("INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY) \
      VALUES (4, 'Anongnat  Srichaj', 25, 'Skon Nakhon ', 65000.00 )");

conn.commit()
print "Records created successfully";
conn.close()

        สั่งรันโปรแกรม และผลลัพธ์ปรากฏดังข้อมูลข้างล่างนี้

submarine@Debian77:~/Python$ python insert_data.py
Opened database successfully
Records created successfully

        เขียนโปรแกรมชื่อไฟล์ select_data.py เพื่อให้แสดงผลข้อมูลที่ใส่ไว้ในตาราง  รายละเอียด
โปรแกรม  มีดังนี้

submarine@Debian77:~/Python$ pico select_data.py

 #!/usr/bin/python

import psycopg2

conn = psycopg2.connect(database="python", user="submarine", password="xxxxxxxxxxxx", host="127.0.0.1", port="5432")
print "Opened database successfully"

cur = conn.cursor()

cur.execute("SELECT id, name, address, salary  from persons")
rows = cur.fetchall()
for row in rows:
   print "ID = ", row[0]
   print "NAME = ", row[1]
   print "ADDRESS = ", row[2]
   print "SALARY = ", row[3], "\n"

print "Operation done successfully";
conn.close()

        สั่งรันโปรแกรมจะได้ผลลัพธ์ดังรายละเอียดข้างล่างนี้

submarine@Debian77:~/Python$ python select_data.py
Opened database successfully
ID =  1
NAME =  Weerapong  Srichaj
ADDRESS =  Chacheongsao                                    
SALARY =  200000.0

ID =  2
NAME =  Prasit  Srichaj
ADDRESS =  Prachin Buri                                    
SALARY =  15000.0

ID =  3
NAME =  Somchit  Srichaj
ADDRESS =  Skon Nakhon                                      
SALARY =  20000.0

ID =  4
NAME =  Anongnat  Srichaj
ADDRESS =  Skon Nakhon                                      
SALARY =  65000.0

Operation done successfully
submarine@Debian77:~/Python$

        จะเห็นว่าภาษา Python เขียนง่าย ใช้งานง่ายไม่ต้องคอมไพล์เหมือนกับภาษา Java, C/C++
จึงเหมาะอย่างยิ่งสำหรับการเขียนโปรแกรมทั้งการแสดงผลผ่าน command line และ web server
ในบทความต่อไปผู้เขียนจะกล่าวถึงการเขียนโปรแกรมภาษา Python ให้ทำงานร่วมกับ Web
server และ PostgreSQL


วันจันทร์ที่ 12 มกราคม พ.ศ. 2558

การเขียนโปรแกรมภาษา Perl ติดต่อ PostgreSQL Database Server ผ่าน Web Sever Apache

        หลังจากเราปรับแต่ง ทดลองเขียนโปรแกรมภาษา Perl ให้แสดงผลบน Web server และเขียน
โปรแกรมภาษา Perl ให้ติดต่อ PostgreSQL Database server โดยใช้ DBI ได้แล้ว  ในบทความนี้เราจะ
นำทั้งสองเรื่องมารวมในไฟล์เดียวกัน เพื่อนให้ Web server สามารถใช้ภาษา Perl ไปติดต่อกับ
PostgreSQL database server แล้วนำข้อมูลมาแสดงผลบน Web server โดยใช้ Browser ได้
        วิธีการ คือ นำคำสั่ง  print "Content-type: text/plain\n\n" ; มาใส่ไว้บนหัวของไฟล์ .pl ที่เก็บอยู่ใน
ไดเรกทอรีที่สามารถใช้งานภาษา Perl ได้บน Web server ไนที่นี้เราจะเก็บไฟล์ภาษา perl ไว้ที่
ไดเรกทอรี่ /usr/lib/cgi-bin
        ตัวอย่าง ไฟล์ connect_postgresql.pl

#!/usr/bin/perl

print "Content-type: text/plain\n\n" ;
use DBI;
use strict;

my $driver   = "Pg";
my $database = "web";
my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
my $userid = "submarine";
my $password = "xxxxxxxxxxxx";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
                      or die $DBI::errstr;

print "Opened database successfully...เย้!...ติดต่อฐานข้อมูลได้แล้ว\n";

เขียนไฟล์เสร็จแล้วกำหนดให้อ่าน เขียนไฟล์ได้ด้วยทำสั่ง chmod +x connect_postgresql1.pl
แล้วเรียกใช้งานตาม url ที่กำหนดไว้  ในที่นี้ผู้เขียนจะเรียกใช้งานไฟล์ดังกล่าวที่
http://localhost/cgi-bin-connect_postgresql1.pl  ได้ผลดังภาพ



        เมื่อสามารถเปิดฐานข้อมูลโดยใช้ภาษา perl เชื่อมต่อฐานข้อมูล PostgreSQL โดยให้นำมา
แสดงผลบน Web server apache ที่อ่านด้วยบราวเซอร์ได้แล้ว ต่อไปจะเป็นตัวอย่างการสร้างตาราง
บนฐานข้อมูล  ผู้เขียนสร้างฐานข้อมูล ชื่อ debian ด้วยแพคเกจ phpPgAdmin ที่เป็นโปรแกรม
จัดการฐานข้อมูล PostgreSQL ด้วยภาษา Php

       ตัวอย่างไฟล์  create_table.pl   เพื่อสร้างตารางชื่อ persons บนฐานข้อมูล ชื่อ debian


#!/usr/bin/perl

print "Content-type: text/plain\n\n" ;

use DBI;
use strict;

my $driver   = "Pg"; 
my $database = "debian";
my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
my $userid = "submarine";
my $password = "xxxxxxxxxxxx";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
                      or die $DBI::errstr;
print "Opened database successfully\n";

my $stmt = qq(CREATE TABLE persons
      (ID INT PRIMARY KEY     NOT NULL,
       NAME           TEXT    NOT NULL,
       AGE            INT     NOT NULL,
       ADDRESS        CHAR(50),
       SALARY         REAL););
my $rv = $dbh->do($stmt);
if($rv < 0){
   print $DBI::errstr;
} else {
   print "Table created successfully\n";
}
$dbh->disconnect();


        กำหนดสิทธิ์ไฟล์ให้อ่าน เขียนได้ด้วยคำสั่ง chmod +x create_table.pl แล้วรันโปรแกรมด้วย
คำสั่ง ./create_table.pl  หรือจะเรียกใช้งานผ่านบราวเซอร์ก็ได้


        เมื่อมีฐานข้อมูล และตารางแล้ว ไฟล์ต่อไปนี้เป็นตัวอย่างไฟล์ภาษา Perl ที่เขียนขึ้นเพื่อ
ใส่ข้อมูล (insert) ในตารางที่สร้างขึ้น  ในที่นี้จะตั้งชื่อไฟล์ insert_data.pl


#!/usr/bin/perl
print "Content-type: text/plain\n\n" ;

use DBI;
use strict;

my $driver   = "Pg"; 
my $database = "debian";
my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
my $userid = "submarine";
my $password = "xxxxxxxxxxxx";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
                      or die $DBI::errstr;
print "Opened database successfully\n";

my $stmt = qq(INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY)
      VALUES (1, 'นพ.วีระพงษ์  ศรีชาติ', 51, 'ฉะเชิงเทรา', 100000.00 ));
my $rv = $dbh->do($stmt) or die $DBI::errstr;

$stmt = qq(INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY)
      VALUES (2, 'นพ.ประสิทธิ์  ศรีชาติ', 46, 'ปราจีณบุรี', 150000.00 ));
$rv = $dbh->do($stmt) or die $DBI::errstr;

$stmt = qq(INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY)
      VALUES (3, 'นายสมจิตร  ศรีชาติ', 43, 'สกลนคร', 40000.00 ));
$rv = $dbh->do($stmt) or die $DBI::errstr;

$stmt = qq(INSERT INTO persons (ID,NAME,AGE,ADDRESS,SALARY)
      VALUES (4, 'นายผเด็จ  ศรีชาติ', 37, 'สกลนคร', 25000.00 ););
$rv = $dbh->do($stmt) or die $DBI::errstr;

print "Records created successfully\n";
$dbh->disconnect();

        หลังเขียนโปรแกรมเสร็จก็คำเช่นเดียวกัน คือ กำหนดสิทธิ์ของไฟล์ และรันโปรแกรม  ถ้า
ไม่มีข้อผิดพลาดก็ศึกษาไฟล์ตัวอย่างต่อไปเพื่อนำข้อมูลในตารางบนฐานข้อมูลมาแสดงทั้งบน
Command line และแสดงผลบนบราวเซอร์
     
        ต่อไปนี้เป็นตัวอย่างไฟล์ select_data.pl ให้นำข้อมูลในตารางมาแสดงผล 


#!/usr/bin/perl

print "Content-type: text/plain\n\n" ;

use DBI;
use strict;

my $driver   = "Pg"; 
my $database = "debian";
my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
my $userid = "submarine";
my $password = "xxxxxxxxxxxx";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
                      or die $DBI::errstr;
print "Opened database successfully\n";

my $stmt = qq(SELECT id, name, address, salary  from persons;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute() or die $DBI::errstr;
if($rv < 0){
   print $DBI::errstr;
}
while(my @row = $sth->fetchrow_array()) {
      print "ID = ". $row[0] . "\n";
      print "NAME = ". $row[1] ."\n";
      print "ADDRESS = ". $row[2] ."\n";
      print "SALARY =  ". $row[3] ."\n\n";
}
print "Operation done successfully\n";
$dbh->disconnect();

        หลังกำหนดสิทธิ์ สั่งรัน และแสดงผลด้วยบราวเซอร์ได้ผลดังภาพข้างล่างนี้



        สิ่งที่ยังต้องพัฒนาต่อ คือ การเขียนโปรแกรมให้รับข้อมูลไปใส่ในตาราง และปรับการ
แสดงผลผ่านบราวเซอร์ให้นำเสนอข้อมูลเป็นตารางเพื่อความสวยงามซึ่งทำได้ไม่ยากนัก
เพียงทบทวนการเขียนตารางบนภาษา HTML อีกเล้กน้อยก็ทำได้แล้ว
       จากบทความนี้จะเห็นว่าเราสามารถใช้งาน Debian 7.7 GNU/Linux, Apache, PostgreSQL,
Perl และ Perl DBI มาใช้งานเพื่อจัดการฐานข้อมูลได้อย่างมีประสิทธิภาพ