Archive for the ‘apache’ Category

Password Protecting Web Directories

Password Protecting Web Directories

QUICK TIP : ถ้าคุณใช้ FrontPage ,คุณควรที่จะใช้เครื่องมือป้องกันพาสเวิร์ดที่มากับ FrontPage ยกเว้น เมื่อใช้กับพาสเวิร์ดป้องกันไดเรกทอรี webstats ของคุณ

IMPORTANT: คุณจะต้องการใช้ทั้ง FTP และ SSH ใช้กับฟีเจอร์นี้. หมายความว่าถ้าคุณมี Value Plan,คุณไม่ควรใช้ฟีเจอร์นี้.

Using .htaccess

สมมุติว่าโดเมนเนมคุณคือ foobar.com และต้องการใช้การป้องกันไดเรกทอรีที่ http://foobar.com/members/ คุณควรจะทำต่อไปนี้:

1) ใช้เท็กอิดิเตอร์ เช่น Notepad สร้างไฟล์ที่ชื่อ “.htaccess”. อย่าลืม จุดข้างหน้าของ htaccess.จากนั้นในไฟล์ควรจะประกอบสิ่งต่าง ๆ ต่อไปนี้

—COPY EVERYTHING BELOW——————–
AuthUserFile /home/foobar/.htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic
<Limit GET POST>
require user Spock
</Limit>
—COPY UP TO THE LINE ABOVE—————

สำคั?มาก : อย่าลืมแทนที่ “foobar” เป็นโดเมนเนมของคุณ. อย่าใส่ .com หรือ .net ต่อท้าย.

2) เซฟไฟล์ในโหมดเท็กซ์ไฟล์ธรรมดา

3) อัพโหลดไฟล์โดย FTP สู่ /www/foobar/member/ ต้องแน่ใจว่าคุณอัพโหลดในโหมด ASCII (plain text)

4) ล็อกออนเข้าสู่แอคเคาน์ของคุณในเซร์ฟเวอร์ของเราผ่าน SSH.

5) พิมพ์คำสั่งข้างล่างลงไป ที่บรรทัดคำสั่งจากนั้นเคาะ Enter

htpasswd -c /home/foobar/.htpasswd Spock

จะสร้างไฟล์ชื่อ .htpasswd ในไดเรกทอรีโอมของคุณ.

6) คุณจะมีพร้อมให้พิมพ์พาสเวิร์ดสำหรับ Spock.

7) ต้องการอนุ?าติเพิ่มยูสเซอร์ที่เรียกว่า Kirk.
8) พิมพ์คำสั่งข้างล่างนี้เพิ่มเติมเข้าไป

htpasswd /home/foobar/.htpasswd Kirk

9) คุณควรที่จะเพิ่ม “require user Kirk” ใน .htaccess ของคุณ มันควรจะเหมือนข้างล่างนี้ :

—COPY EVERYTHING BELOW——————–
AuthUserFile /home/foobar/.htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic
<Limit GET POST>
require user Spock
require user Kirk
</Limit>
—COPY UP TO THE LINE ABOVE—————
10) คราวนี้มาทดสอบกันโดยเข้าไปที่ http://foobar.com/member/ คุณจะมีพร้อมสำหรับให้ใส่ค่า ยูสเซอร์เนมและพาสเวิร์ด.

Adding Additional Users and Passwords pairs

1) กลับมาที่ SSH เข้าสู่แอคเคาน์ของคุณ.

2) พิมพ์คำสั่งต่าง ๆ ที่พร้อมและกดปุ่ม Enter

htpasswd /home/foobar/.htpasswd Sulu

สำคัญมาก : อย่าลืมเพิ่ม “require user Sulu” เข้าสู่ไฟล์ .htaccess ของคุณ.

3) คุณอาจจะใช้ user/password ผสมกัน คุณสามารถสร้างใน .htpasswd ของคุณ เพื่ออนุญาติกการเข้าถึงการป้งกันไดเรกทอรีอื่น — จะต้องใช้ชื่อที่ถูกต้องที่อยู่ภายในไฟล์ .htaccess

IMPORTANT: คุณควรที่จะเก็บไฟล์ .htpasswd ในโฮมไดเรกทอรี ดังนั้นมันจะซ่อนจากบุคคลอื่นได้

  • Comments Off

# aptitude update
# aptitude install apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common
# aptitude install php5 php5-cgi php5-commonphp5-curlphp5-gd php5-mcrypt php5-mysql php5-odbc php5-pgsql php5-xmlrpc
# aptitude install libapache2-mod-php5

ช่วงนี้ aptitude ของ etch เป็นอะไรไม่รู้ ชอบติดตั้งไฟล์ไม่ครบ
(อาจเป็นที่ apt-proxy)
แก้ไขแพกเกจติดตั้งไฟล์ไม่ครบ โดยการแตกไฟล์โดยไม่ติดตั้ง ไปยัง /
# dpkg-deb -x /var/cache/apt/archives/apache2.2-common_2.2.3-3.1_i386.deb /

# aptitude install mysql-client-5.0 mysql-common mysql-server-5.0 phpmyadmin

บันทึกการเปิดโมดูลแบบน้อยสุด module-minimal
# a2enmod actions
# a2enmod alias
# a2enmod authz_host
# a2enmod cgi
# a2enmod dir
# a2enmod mime
# a2enmod php5
# a2enmod rewrite
# a2enmod status
# /etc/init.d/apache2 restart

บันทึกการเปิดใช้โมดูลแบบปกติ module-normal
# a2enmod alias
# a2enmod auth_basic
# a2enmod authn_file
# a2enmod authz_default
# a2enmod authz_groupfile
# a2enmod authz_host
# a2enmod authz_user
# a2enmod autoindex
# a2enmod cgi
# a2enmod dir
# a2enmod env
# a2enmod mime
# a2enmod mod_python
# a2enmod negotiation
# a2enmod php5
# a2enmod setenv
# a2enmod status
# /etc/init.d/apache2 restart

เอา php.ini จากตัวอย่างแบบ recommended มาใช้
# cp /usr/share/doc/php5/examples/php.ini-recommended /etc/php5/apache2/php.ini

แก้จะให้ใช้ได้กับ drupal
# vi /etc/php5/apache2/php.ini

...
; หน่วยความจำที่ยอมให้สคริปต์รันได้
; เก่าเป็น 8M drupal แนะนำ 12M เราใช้ 16M กันเหนียว
memory_limit = 16M ; Maximum amount of memory a script may consume (8MB)
...
; ตัวแปรเป็น global อัตโนมัติ
; อันนี้ก็กันเหนียว ตอนเขียนโค๊ดเรี่ยราดไว้หลายที่ เก่าเป็น Off เราแก้เป็น On
register_globals = On
...
; ขนาดไฟล์ใหญ่สุด ที่ post ได้
; อันนี้จำได้แม่น หน้าแตกเพราะเอา Bon Echo เข้าไม่ได้ เก่าเป็น 8M แก้เป็น 20M
post_max_size = 20M
...
; adodb ไม่ต้องก็ได้
include_path = ".:/usr/share/php5:/usr/share/php4:/usr/share/php/adodb"
...
; ค่าแนะนำของ drupal
session.save_handler = user
...
; ค่าแนะนำของ drupal
session.cache_limiter = none
...

ส่วนของไซต์ ถ้ามีหลายไซท์ ควรแยกไฟล์ออกมาวางไว้ที่ /etc/apache2/site-available
เวลาจะเปิดใช้งานก็ใช้คำสั่ง a2ensite
เช่นไซต์ example.com
# vi /etc/apache2/sites-available/example.com

<VirtualHost *:80>
  ServerAdmin webmaster@example.com
  ServerName www.example.com

  DocumentRoot /var/www/www.example.com/
  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>
  <Directory /swww2/var/www/www.thaitux.info/>
    Options Indexes FollowSymLinks MultiViews
    DirectoryIndex index.html index.php
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/log/apache2/error.log

  LogLevel warn

  CustomLog /var/log/apache2/access.log combined
  ServerSignature On
</VirtualHost>

เปิดใช้งานด้วยคำสั่ง
# a2ensite example.com
# /etc/init.d/apache2 restart

  • Comments Off

This brief introduction for configuring sites and modules in Debian’s Apache 2 package explains how to add and remove sites using the supplied tools, along with adding and removing modules.

The main source of confusiong comes from the various directories stored beneath /etc/apache2:

sites-available
A list of configuration files - one per site. A blank install will contain the file default. The system admin can have as many sites here as they need - however - they will not all be active.
sites-enabled
A list of symlinks to configuration files in sites-available. A blank install will contain a symlink 000default to sites-available/default. The sites listed here are the sites which will be active. The site to be used if no virtual hosts match will be the first file found (hence the 000 on 000default).
mods-available
A list of configuration files - one or more per module. Each dpkg installed module will add files here. e.g. php4.conf and php4.load are added with the libapache2-mod-php package. Again - the system admin can install whatever modules they wish - however - until they are set available they will not be active.
mods-enabled
A list of symlinks to configuratioon files in modes-available. Only modules linked in here will be activated on the webserver.

Now - several discussions on #debian IRC channel on freenode recently have had people advising others to either copy files from the available to the enabled directories or to manually symlink them. The user has, however, a better option - the four commands a2ensite, a2dissite, a2enmod and a2dismod

a2ensite
Will create the correct symlinks in sites-enabled to allow the site configured in sitefilename to be served
a2dissite
Will remove the symlinks from sites-enabled so that the site configured in sitefilename will not be served
a2enmod
e.g. a2enmod php4 will create the correct symlinks in mods-enabled to allow the module to be used. In this example it will link both php4.conf and php4.load for the user
a2dismod
Will remove the symlinks from mods-enabled so that the module cannot be used

We covered these this new layout briefly when discussing the upgrade from Apache 1.x to 2.x, and again when dicussing how to enable mod_rewrite for Apache.

  • Comments Off

Time

Mp3

Msn status

  • manon2029@hotmail.com is

Chat with Meeh

Donate

    If you find an article useful, then please make a donation.

หมวดหมู่

UserOnline

Counter

  • Visitors today: 23
  • Visitors yesterday: 48
  • Visitors per day: 260
  • Max. visitors per day: 255
  • Total page views: 155,880
  • Page views of this page: 260
  • Currently online: 1
  • Max. online: 23
  • Total visitors: 33,987
  • counterStatistics