Just Play and Just Knowledge
Apache FancyIndex Overide Apache Icons
เคยเขียนการทำ list ไฟล์ด้วย apache modindexoptions มาแล้วแต่ติดปัญหาเรื่อง icons ที่ไม่ได้เอามาตามที่เราต้องการกลับไปเอา icon ซึ่งเป็น default ของ apache มาทำให้ index list มองแล้วไม่สวยดังใจ เลยมาเขียน .htaccess เพื่อให้เปลี่ยนที่อยู่ของ icons ให้ไปตามที่เราต้องการ
สำหรับใครที่ต้องการ icons ต่างๆ สามารถหาโหลดได้ทั่วไปแต่หากว่าไม่อยากโหลดมาก็สามารถเอาของผมไปใช้ได้ครับ สำหรับการ overide ตามนี้เลยครับ ส่วนนี้จะอยู่ใน .htaccess นะครับ
AddIconByEncoding (CMP,/index-style/icons/compressed.gif) x-compress x-gzip
#AddIconByType (TXT,/index-style/icons/text.gif) text/*
AddIconByType (IMG,/index-style/icons/image2.gif) image/*
AddIconByType (SND,/index-style/icons/sound2.gif) audio/*
AddIconByType (VID,/index-style/icons/video.png) video/*
AddIcon /index-style/icons/back.gif ..
AddIcon /index-style/icons/pdf.png .pdf
AddIcon /index-style/icons/html.png .html .xhtml .xml
AddIcon /index-style/icons/html.png .txt
AddIcon /index-style/icons/compressed.gif .rar .zip
AddIcon /index-style/icons/dll.png .dll
AddIcon /index-style/icons/shellscript.png .sh
AddIcon /index-style/icons/library.png .jar .lib
AddIcon /index-style/icons/msword_doc.png .doc .docx
AddIcon /index-style/icons/msexcel_xls.png .xls .xlsx
AddIcon /index-style/icons/msaccess_mdb.png .mdb .mdbx
AddIcon /index-style/icons/doc_encrypted.png .key .csr
AddIcon /index-style/icons/binary.png .bin .exe
AddIcon /index-style/icons/swf.png .bin .swf
AddIcon /index-style/icons/source_java.png .java
AddIcon /index-style/icons/source_c.png .c
AddIcon /index-style/icons/source_cpp.png .cpp
AddIcon /index-style/icons/source_ruby.png .rb
AddIcon /index-style/icons/xml.png .xml
AddIcon /index-style/icons/properties.png .properties
#AddIcon /icon/hand.right.gif README
AddIcon /index-style/icons/folder.gif ^^DIRECTORY^^
AddIcon /index-style/icons/blank.gif ^^BLANKICON^^
DefaultIcon /index-style/icons/unknown.gif
No comments yet.
584No trackbacks yet.
Install and Deploy Rails with Apache Modrails
about 4 months ago - No comments
Jaideawhosting ตอนนี้ได้เปลี่ยนมาใช้งาน mod_rails แทน mod_proxy และ fastcgi แล้วเพราะเห็นว่าเจ้า mod_rails มันเสถียรจริงๆ อีกอย่างการ deploy ก็ทำได้ง่ายดายมาก เอาเป็นว่ามาดูวิธิการลงกันเลย
Install Passenger
1. ทำการติดตั้ง passenger gem (mod_rails)
gem install passenger
2. ติดตั้งเป็น module ของ apache
passenger-install-apache2-module
เป็นอันว่าเรียบร้อยแล้วสำหรับการลง ง่ายไหมละ
Mod-rails Config
1. เปิดไฟล์ httpd.conf ของ apahce มาครับ
2. การ deploy ด้วย virtual host
ServerName www.xxx.com
ServerAlias www.xxxx.com xxxx.com
[...]
มาป้องกัน IndexOption ด้วยพาสเวิร์ดดีกว่า
about 6 months ago - No comments
หลังจากที่ทำ IndexOption ด้วย htaccess แล้วเราอยากปกป้อง directory บางอันไหม หากต้องการทำตามนี้เลย ซึ่งการทำจะใช้งาน .htaccess เหมือนเดิมและจะเพิ่มในส่วนของ .htpasswd มาเพื่อใช้ในการเข้าสู่ระบบ
วิธีการทำ
1. ไปยัง folder ที่ต้องการป้องกันด้วยรหัสผ่าน
2. สร้างไฟล์ .htaccess
เพิ่ม code ต่อไปนี้
AuthType Basic
AuthName “Yun Trade File Repositories”
AuthUserFile ที่อยู่เต็ม #ex /home/nolifelover/public_html/.htpasswd
Require valid-user
3. สร้างไฟล์ .htpasswd โดยใช้งาน http://www.htaccesstools.com/htpasswd-generator/ เข้ามาช่วยก็ไปใช้จากนั้นเอา output มาใส่ในไฟ์ .htpasswd ก็จะได้ระบบป้องกันไดเรกทอรี่นี้แล้ว
เพิ่มเติม
http://httpd.apache.org/docs/1.3/howto/auth.html
http://www.htaccesstools.com/htpasswd-generator/
Apache FancyIndex with .htaccess
about 6 months ago - 2 comments
ห่างหายไปนานเลยกับการเขียนบล๊อกวันนี้มาอัพเดดหน่อย สำหรับตัวนี้จะเป็นการใช้งานของ apache IndexOptions ซึ่งจะเป็นการทำให้ folder เราสามารถ list ไฟล์ต่างๆ ได้เลย โดยการเขียนจะใช้งาน .htaccess เพื่อกำหนดค่าต่างๆ ครับ
วิธีการทำ
1. เริ่มแรกเลยไปยัง folder ที่ต้องการทำ index จากนั้นให้สร้างไฟล์ .htaccess แล้วเพิ่มโค้ดข้างล่างนี้
Options Indexes FollowSymLinks
IndexOptions FancyIndexing
IndexOptions VersionSort
IndexOptions HTMLTable
IndexOptions FoldersFirst
IndexOptions IconsAreLinks
IndexOptions IgnoreCase
IndexOptions SuppressDescription
IndexOptions SuppressHTMLPreamble
IndexOptions XHTML
IndexOptions IconWidth=16
IndexOptions IconHeight=16
IndexOptions NameWidth=*
IndexOrderDefault Descending Name
HeaderName /index-style/header.html
ReadmeName /index-style/footer.html
2. ให้ไปโหลดไฟล์ที่ http://recurser.com/articles/2008/12/29/styling-apache-directory-listings-with-mod_autoindex/ เพื่อทำให้สวยงามโดยการนำเอาไฟล์ไปไว้ที่ /index-style ก็จะได้รูปแบบสวยๆ แล้ว
เพิ่มเติม
http://recurser.com/articles/2008/12/29/styling-apache-directory-listings-with-mod_autoindex/
Working with php in mac 10.5.X
about 1 year ago - No comments
สวัสดีครับสำหรับวันนี้เมื่อผมต้องการเขียน php บน mac เนี่ยผมต้องทำอย่างไรครับสำหรับที่จริงแล้วเรามีทางเลือกได้หลายทางครับ จะเอาที่มีเป็น package อยู่แล้วมา install หรือนั่ง compile apache ใหม่ก็แล้วแต่ครับ สำหรับวิธีที่ผมเลือกคือเลือกที่จะใช้ apache ที่มีอยู่ใน 10.5.x อยู่แล้วครับ สำหรับใครที่อยากจะลงโดยไม่ต้องยุ่งกับอะไรสามารถเลือก MAMP, XAMPP or Marc Liyanage ได้ครับ สำหรับใครที่ต้องการใช้ที่ติดกับ mac อยู่แล้วก็ตามมาเลยครับ
Enable Developer Tools
คือการเปิดสิทธิให้สามารถใช้ root user ได้ เพื่อไม่ให้เกิดปัญหาเรื่องการใช้งานในการ access file permission สำหรับวิธีการให้ไปที่ Menu ->Go ->Utilities-> Directory Utility จากนั้นให้ทำการเลือก ปลดล็อกไฟล์ตรงรูปกุญแจแล้วจะมีการ Authenticate เพื่อตรวจสอบสิทธิการใช้ ให้เราใส่ password ลงไป หลังจากนั้นให้ไปที่ menu->edit->enable root users จะมีการถามพาสเวิร์ดให้เราใส่ password ของ [...]