Sep 04

High scalability with Nginx, I have read some article about Nginx, which show more powerful with load balance, reverse proxy, imap, pop3 and smtp.
This post is howto install Nginx for using in our project, let’s go….

Install prerequisites :
[code lang='bash']apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev[/code]

Get source package : http://sysoev.ru/nginx/nginx-0.6.32.tar.gz
Get syslog patch : http://wiki.codemongers.com/NginxModules?action=AttachFile&do=get&target=syslog.patch

[code lang='bash']tar zxf nginx-0.6.32.tar.gz
cd nginx-0.6.32
patch -p1 < ../syslog.patch #which use SysLog
./configure --with-http_ssl_module --with-mail --with-mail_ssl_module --with-syslog
make
make install
[/code]

init.d script
vi /etc/init.d/nginx
[code lang='bash']
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/nginx/sbin
DAEMON=/usr/local/nginx/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;

restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac

exit 0
[/code]

Give some permissions:
[code lang='bash']
chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults[/code]

Ok, already done.

Tagged with:
Aug 05

หลังจากติดตั้งเครื่องใหม่เรียบร้อยแล้ว
[code lang='bash']
apt-get install ssh screen
apt-get install apache2 apache2-prefork-dev php5 php5-cli php5-dev php5-gd php5-mcrypt php5-mysql make
[/code]

- config apache2

[code lang='bash']
a2dismod cgi
a2dismod autoindex
a2dismod negotiation
a2dismod status
a2enmod rewrite
a2enmod expires
[/code]

สำหรับการใช้งานร่วมกับ PEAR Database
[code lang='php']apt-get install php-pear php-db[/code]

Tagged with:
Aug 05

จดไว้กันลืม จะใช้จะได้ไม่ต้องหาอีก ช่วงนี้ยิ่งมีอะไรต่อมิอะไรเยอะแยะไปหมด
สำหรับคนที่ต้องการใช้ PHP4 บน Ubuntu 8.04 นะครับ Download source มาเลยครับ ไม่ต้องคิดมาก ต้อง compile แน่นอน
ขั้นแรกติดตั้งสิ่งที่ต้องการก่อน ทางที่ดีก็เอา PHP5 ลงไปด้วย เผื่อใช้ ครับ แต่ปิดที่ apache ละกันครับ

.   
apt-get install build-essential flex bison
apt-get install libmysqlclient15-dev libbz2-dev libjpeg62-dev libpng-dev libtiff-dev libfreetype6-dev libmcrypt-dev librecode-dev
apt-get install apache2 apache2-threaded-dev php5 php5-cli php5-dev php5-gd php5-mcrypt php5-mysql php5-recode php5-curl php-pear php-db

ถัดไปเริ่มทำการ configure ก็เก็บเอาจาก config.nice มาให้ใช้เลยครับ จะได้ง่ายๆ

.   
#! /bin/sh
#
# Created by configure
'./configure' \
'--with-mysql' \
'--with-zlib' \
'--with-bz2' \
'--with-gd' \
'--enable-gd' \
'--enable-gd-native-ttf' \
'--with-jpeg-dir' \
'--with-png-dir' \
'--with-ttf' \
'--with-freetype-dir' \
'--with-iconv' \
'--enable-track-vars' \
'--with-gettext' \
'--enable-trans-id' \
'--enable-mbstring' \
'--with-openssl' \
'--disable-cli' \
'--with-mcrypt' \
'--with-pear' \
'--with-recode' \
'--with-zlib' \
'--with-apxs2=/usr/bin/apxs2' \
'--with-config-file-path=/etc/php4' \
'--prefix=/usr/local/php4' \
"$@"

เสร็จสิ้นกระบวนการรบ จะเอาไปทำอะไรต่อก็แล้วแต่ละกันครับ

Tagged with:
Apr 21

หากใครหา php5-gmp ซึ่งจะไปใช้กับ Ubuntu 7.10 ก็จะหาไม่ได้นะครับ ขั้นแรกคือรอ Ubuntu 8.04 (Hardy Heron) ซึ่งจะมีให้เลย แถมยังเป็น LTS (Long Time Support) อีกด้วย ก็จะ launch ในวันที่ 24 เมษายน ที่จะถึงนี้เอง
แต่พอดีผมใช้อยู่และรอไม่ได้ก็เลยต้องหาวิธีทำให้ PHP5 ของ Ubuntu 7.10 ใช้ได้ก็เลยไปหาใน Ubuntuforums.org มีคนทำเป็น package ด้วย link ดูได้จากด้านล่างนะครับ (อีกที่ มี compile package ไว้ให้ด้วย)
ผมได้แก้ให้เป็น version 5.2.3 ครับ แต่วิธีการเดียวกัน

Steps to enter at the command line:

1. apt-get install build-essential debhelper libgmp3c2 libgmp3-dev

(More tools might be needed depending on what you already have installed, but you will tend to get warnings about what is missing)

Then, download the PHP sources:

2. apt-get source php5

My version is 5.2.3, but yours may be different.

Get all the dependencies for building PHP:

3. apt-get build-dep php5

Change into the debian build directory for PHP:

** Found problem with : libsnmp10-dev – virtual package with libsnmp-dev
used with apt-get install —all of package–

4. cd php5-5.2.3/debian

Let’s edit the modulelist file.

5. vi modulelist

Insert a line below the one that says

gd GD

with the contents:
gmp GMP

Next, edit the rules file. Either open it from gedit directly or use:

6. vi rules

Look for the line that says:

–with-curl=shared,/usr \

Open a line below this with the contents:
--with-gmp=shared,/usr \

Make sure not to forget the backslash on the end. Also, GMP installed itself into /usr/local on my machine. Your location may be different.

Now, we edit the control file. Again, either use the gedit GUI to open the file or type:

7.vi control

Add this to the end of the file:
Package: php5-gmp
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, ${php:Depends}, php5-common (= ${Source-Version})
Description:GMP module for php5
This package provides a module for GMP to be used with PHP5.
.
PHP5 is an HTML-embedded scripting language. Much of its syntax is borrowed
from C, Java and Perl with a couple of unique PHP-specific features thrown
in. The goal of the language is to allow web developers to write
dynamically generated pages quickly.

Make sure that you keep all that text as one big block with no extra lines between it. It’s ok to have an extra line after it, but not between it. Just see how the other entries are entered and go from there.

Move up a directory.

8. cd ..

Now, run:

9. sudo dpkg-buildpackage

This will do the whole configure/compile for PHP and create debs in the parent directory. This does take awhile, though. When this process is done, move up to the parent directory:

10. cd ..

And, you will see all of the PHP debs, including the new php5-gmp_[version].deb

Run a dpkg -i on the ones you need (I just used the gmp one):

11.dpkg -i php5-gmp_523-1ubuntu6.3_i386.deb

เป็นอันเสร็จพิธี อย่าลืม restart apache นะครับ

อ้างอิง

Tagged with:
Mar 13

วันนี้มาลอง Compile Kernel ของ FreeBSD 7.0 กัน ตามนี้เลย
[code lang='bash']
cd /usr/src/sys/i386/conf
cp GENERIC IPFWKERN
[/code]
## edit IPFWKERN ##
เพิ่ม
[code lang='bash']
options IPFIREWALL
options IPDIVERT
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPFIREWALL_FORWARD
options IPSTEALTH
options ACCEPT_FILTER_HTTP
options ACCEPT_FILTER_DATA
[/code]
หลังจากเสร็จแล้ว
[code lang='bash']
config IPFWKERN
cd /usr/src
make kernel KERNCONF=IPFWKERN
make installkernel KERNCONF=IPFWKERN
[/code]
หลังจากนั้น แก้ /etc/rc.conf เพิ่ม
[code lang='bash']
firewall_enable="YES"
firewall_type="/etc/ipfw.rules"
filewall_logging="YES"
[/code]
แล้วอย่าลืมสร้าง ipfw.rules ล่ะครับ
หลังจากนั้นก็ Reboot เป็นอันเสร็จเรียบร้อย

Tagged with:
preload preload preload