วันอาทิตย์ที่ 28 พฤศจิกายน พ.ศ. 2553

How to remove apache2 completly

เมื่อปีที่แล้วผมเขียนบทความการลง apache คราวนี้เรื่องการลบบ้างครับ

ปัญหาที่ผมเคยเจอคือ ลบแล้วแพ็คเกจไม่หมด ลงใหม่ก็ลงไม่ได้

เรียกว่า เก่าก็ไม่ไป ใหม่ก็ไม่มา

กรณีที่เป็น server นะครับ

ส่วน Desktop ง่ายๆเลยก็ synaptic package สำหรับ Desktop ไม่มีอะไรยาก ผมขออนุญาต
ไม่พิมพ์นะครับ (ขี้เกียจ)

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

 ทำตามดังนี้ครับ

พิมพ์คำสั่ง sudo dpkg --get-selections | grep apache

จะปรากฎแพ็คเกจที่ติดตั้งที่เป็น apache ขึ้นมาครับ เช่น

apache2                  install
apache2-doc               install
apache2-mpm-prefork            install
apache2-utils               install
apache2.2-common            install
libapache2-mod-auth-mysql         install
libapache2-mod-php5            install

จากนั้นพิมพ์คำสั่งนี้เพื่อลบให้สิ้นกลิ่นน้ำนมเลยครับ

 sudo apt-get remove apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-auth-mysql libapache2-mod-php5

ถ้ารายชื่อแพ็คเกจคุณมีมากกว่านั้น ก็ใส่ไปมากกว่านั้นครับ
เห็นคำสั่งยาวอย่างง ก็คือ sudo apt-get remove ตามด้วยแพ็คเกจที่เจอครับ

เมื่อกด Enter จะเจอ warning ดังนี้

Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following packages were automatically installed and are no longer required:
  ttf-wqy-zenhei ttf-kannada-fonts libaccess-bridge-java libmcrypt4 libt1-5 ttf-telugu-fonts rhino ttf-oriya-fonts dbconfig-common ttf-bengali-fonts
  php5-common
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common jetty libapache2-mod-auth-mysql libapache2-mod-php5 php5 php5-curl php5-gd
  php5-mcrypt php5-mysql phpmyadmin
0 upgraded, 0 newly installed, 14 to remove and 1 not upgraded.
After this operation, 39.1MB disk space will be freed.
Do you want to continue [Y/n]? y

เครื่องแค่ถามว่าเราจะลบหรือไม่ ก็พิมพ์ y แล้วกด Enter

--------

ถ้าเคยลงไว้ ระบบจะถามว่า

Configuring phpmyadmin
-------------- 
  Since you are removing phpmyadmin, it's possible that you no longer want the underlying database.
    If you like, database removal can be handled with dbconfig-common.                                                                                 
If you know that you do want to keep this database, or if you want to handle the removal of this database manually, you should refuse this option. 

 Otherwise, you should choose this option.                                                                                                                                                                                                                                                               
Deconfigure database for phpmyadmin with dbconfig-common?                                                                                                                                       <Yes>                                                <No> 

ก็ให้ตอบ no ไปครับ

จากนั้นก็ติดตั้งใหม่ครับ

sudo apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 libapache2-mod-auth-mysql



ถ้าสำเร็จ บรรทัดท้ายๆต้องเจอคำว่า

Setting up apache2-mpm-prefork (2.2.11-2ubuntu2.7) ...
 * Starting web server apache2                                                                                                                              apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                                                                                                     [ OK ]

Setting up apache2 (2.2.11-2ubuntu2.7) ...
Setting up apache2-doc (2.2.11-2ubuntu2.7) ...
 * Reloading web server config apache2                                                                                                                      apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                                                                                                     [ OK ]

Setting up libapache2-mod-auth-mysql (4.3.9-11) ...
Setting up libapache2-mod-php5 (5.2.6.dfsg.1-3ubuntu4.6) ...

เสร็จแล้วอย่าลืม Add lines นี้ลงไปที่ไฟล์บรรทัดท้ายสุด

พิมพ์ sudo nano /etc/apache2/apache2.conf

LoadModule php5_module  modules/libphp5.so
AddHandler php5-script php

แล้ว Save โดยกด Ctrl+O ,แล้วกด Enter ออกจากโปรแกรมโดยกด Ctrl+X

restart service โดย /etc/init.d/apache2 restart

ขอขอบคุณที่มาจาก
http://dan.drydog.com/apache2php.html

http://dancingpenguinsoflight.com/2009/02/how-to-completely-reset-an-apache-instance-in-ubuntu/

ไม่มีความคิดเห็น:

แสดงความคิดเห็น