วิธีทำเครื่องคอมพิวเตอร์ที่บ้านให้เป็นเหมือนเซิร์ฟเวอร์

วิธีทำเครื่องคอมพิวเตอร์ที่บ้านให้เป็นเหมือนเซิร์ฟเวอร์

สิ่งที่ต้องมี
1. โดเมนเนม – ถ้าไม่มีเป็นของตัวเองต้องไปให้คนที่ปล่อยให้คนอื่นใช้ซับโดเมนได้ ตัวอย่างนี้ใช้โดเมนตัวเอง
2. DDNS service – Dynamic DNS ใช้ update DNS ให้ชี้มาที่ IP เรา ถึงแม้ว่าเป็น dynamic IP ก็ใช้ได้ ถ้ามันมี update client ให้ด้วยหรือ router มัน support มาแล้วก็จะดีมาก ตัวอย่างนี้ใช้http://freedns.afraid.org
3. คอมพิวเตอร์

ขั้นตอนการทำ
1. ไปเซต NS (Name Server) ที่ Domain Registrar (ของที่เราจดโดเมน) ให้มันชี้ มาที่ freedns.afraid.org ตามข้างล่างเลย
· ns1.afraid.org
· ns2.afraid.org
· ns3.afraid.org
· ns4.afraid.org
2. ไปสมัครสมาชิกที่ http://freedns.afraid.org แล้วก็ตั้งค่าพวก server ว่าชี้ไปที่ไหน ดูตัวอย่างข้างล่างได้เลย
Domain

Host Type

IP
Mydomain.com

A

1.2.3.4

3. ไปโหลด Client สำหรับ update record ที่นี่เลย http://www.techknowpro.com/freedns/index.php วินโดวส์ ถ้าลินุกซ์หรือแมค ก็ไปหาเอาที่นี่แล้วกันhttp://freedns.afraid.org/scripts/freedns.clients.php
4. ลง Client ที่โหลดมาบนคอมพิวเตอร์ที่เตรียมไว้แล้วก็ตั้งค่า
5. รอ DNS Cache มันรีเฟรชซักพักก็ใช้ได้แล้ว (ไม่เกินห้านาที)

ที่มา: www.bloggang.com

QR Code: in Python

libpng12-0
libpng12-dev
pkg-config

Install libqrencode
http://fukuchi.org/works/qrencode/index.en.html
Libqrencode is a C library for encoding data in a QR Code symbol, a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and is highly robust.
Download: http://fukuchi.org/works/qrencode/qrencode-3.1.1.tar.gz

Compile & install
./configure
make
make install

Usage
qrencode -h

Install pyqrencode
http://github.com/bitly/pyqrencode
Python bindings for libqrencode

Download
http://github.com/bitly/pyqrencode/archives/master

Install
python setup.py install

Usage
python test_qr.py

Problem
$ python test_qr.py
Traceback (most recent call last):
File “test_qr.py”, line 1, in <module>
from qrencode import Encoder
ImportError: libqrencode.so.3: cannot open shared object file: No such file or directory
Solution
$ export LD_LIBRARY_PATH=/usr/local/lib

Problem: cannot load shared object file

Problem: cannot load shared object file
error while loading shared libraries: libgds.so: cannot load shared object file: No such file or directory

Solution
LD_LIBRARY_PATH /opt/interbase/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

or
export LD_LIBRARY_PATH=/opt/interbase/lib

replace /opt/interbase/lib with your library path

QR Code: in Python

pyqrcode
Project site at: http://pyqrcode.sourceforge.net/
Download source code: http://downloads.sourceforge.net/pyqrcode/pyqrcode-0.2.1.tar.gz?use_mirror=
Install from sourcecode on Ubuntu 10.04

$ sudo apt-get install jcc sun-openjdk-6-jdk python-imaging python-setuptools python-dev
For Python 2.6
replace “-m jcc” with “-m jcc.__main__” in Makefile
make
sudo make install

code example

[code lang=”python”]
#!/usr/bin/env python
# coding: utf-8
#
# pyqrcode sample encoder

import sys, qrcode

e = qrcode.Encoder()
image = e.encode(‘woah!’, version=15, mode=e.mode.BINARY, eclevel=e.eclevel.H)
image.save(‘out.png’)
[/code]

There is a error like this.
Traceback (most recent call last):
File “sample1.py”, line 6, in <module>
import sys, qrcode
File “/usr/local/lib/python2.6/dist-packages/qrcode-0.2.1-py2.6-linux-i686.egg/qrcode/__init__.py”, line 21, in <module>
_qrcode._setExceptionTypes(JavaError, InvalidArgsError)
AttributeError: ‘module’ object has no attribute ‘_setExceptionTypes’

Drupal กับ .htaccess

Install drupal เสร็จ เข้าไปแก้ไข config ของ Theme แล้วมี error ประมาณว่า
* warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /var/www/jack/includes/file.inc on line 129.
* Security warning: Couldn’t write .htaccess file. Please create a .htaccess file in your sites/default/files directory which contains the following lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks
ทั้งที่ สร้างไฟล์ .htaccess และให้สิทธิแล้ว แต่ก็ไม่หาย
วิธีแก้คือ ให้เปลี่ยน permission ของ directory files ให้เป็น 777 ซะ

ติดตั้ง GD Library

หลังจากติดตั้ง Drupal แล้ว
มี message แจ้งเกี่ยวกับ GD Library
ให้ทำการติดตั้ง Package  php5-gd ด้วยคำสั่ง
sudo apt-get install php5-gd
จากนั้น restart apache ด้วยคำสั่ง
sudo /etc/init.d/apache2 restart
ก็เป็นอันเรียบร้อย
ที่มา: http://drupal.org/node/540838

Apache : How to Enable mod_rewrite on Ubuntu

เปิดใช้โมดูล mod_rewrite

sudo a2enmod rewrite

แก้ไฟล์คอนฟิก

sudo nano /etc/apache2/sites-enabled/000-default

แก้ไข none ให้เป็น all

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

สุดท้าย บูต Apache ใหม่

sudo /etc/init.d/apache2 restart
ตรวจสอบว่าใช้ได้หรือยังด้วยคำสั่ง
apache2ctl -M

อย่าลืมตรวจสอบไฟล์ .htaccess มาได้ copy มาไว้ที่ /var/www แล้วหรือไม่ เพราะบางครั้ง มันไม่ได้ copy มา ไม่รู้ว่าทำไม ‘-_-

เท่านี้ Clean URL ก็จะใช้ได้แล้ว
ที่มา: drupal.in.thdrupal.org/