Rasanya entri terakhir sebelum entri ni ialah 2 bulan lepas, sekarang dah bulan 5, aku rasa inilah tempoh paling lama aku tak jenguk blog aku. Mungkin sejak aku memiliki seketul blackberry atau mungkin juga sebab terlalu sibuk, blog ni dilupakan. Aku baru login tadi, baru nak approve komen-komen yang terkandas. Untuk pembukaan bulan 5 ni, aku nak post satu tutorial mengenai bagaimana untuk install nginx bersama php-fpm.
Bagi siapa-siapa yang masih tidak tahu, engine x atau lebih dikenali sebagai nginx ialah web server oleh Igor Sysoev seorang warga Rusia. nginx ni sangat ringan, pantas dan sangat stabil. Tak makan banyak memory. Aku dah menggunakan nginx lebih 1 tahun lebih untuk pelbagai projek-projek laman web alternatif bagi Apache. Sesuai untuk laman web yang sangat sibuk. PHP-FPM pula ialah process manager untuk PHP bagi yang menggunakan nginx. Semua request untuk php akan diforward ke PHP-FPM.
Server yang akan aku gunakan untuk installation ini ialah CentOS 5.4 x86_64.
Sebelum mulakan, install dependency.
yum install gcc autoconf make openssl-devel curl-devel mysql mysql-devel zlib-devel libmcrypt
1. Download source nginx di http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-0.7.65.tar.gz tar xvfz nginx-0.7.65.tar.gz cd nginx-0.7.65
2. Configure dan make
./configure --pid-path=/usr/local/nginx/logs/nginx.pid --sbin-path=/usr/local/sbin/nginx --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_ssl_module make make install
3. Install Daemon nginx untuk CentOS. init script ini dibuat oleh notrocketsurgery.com
wget http://imiahus.com/upl/nginx-daemon -O /etc/init.d/nginx chmod 750 /etc/init.d/nginx
install start stop daemon
cd /usr/local/src wget http://imiahus.com/upl/apps-sys-utils-start-stop-daemon-IR1_9_18-1.tar.gz tar zxvf apps-sys-utils-start-stop-daemon-IR1_9_18-1.tar.gz cd apps/sys-utils/start-stop-daemon-IR1_9_18-1/ gcc start-stop-daemon.c -o start-stop-daemon cp start-stop-daemon /usr/sbin chkconfig --add nginx chkconfig --level 345 nginx on
4. Install PHP-FPM
download PHP dan PHP-FPM patch. Untuk installation ini aku akan gunakan PHP 5.2.13
cd /usr/local/src wget http://www.php.net/get/php-5.2.13.tar.gz/from/my.php.net/mirror wget http://php-fpm.org/downloads/php-5.2.13-fpm-0.5.13.diff.gz tar xvfz php-5.2.13.tar.gz gunzip php-5.2.13-fpm-0.5.13.diff.gz cd php-5.2.13 patch -p1 ../php-5.2.13-fpm-0.5.13.diff ./buildconf --force ./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysql-sock --with-gd --without-sqlite --disable-pdo --disable-reflection make make install
5. edit php-fpm punya conf.
nano /usr/local/etc/php-fpm.conf
uncomment <!– dan –> pada “Unix user of processes” dan “Unix group of processes” dalam php-fpm.conf
...Unix user of processes &amp;amp;amp;amp;amp;lt;value name=&amp;amp;amp;amp;amp;quot;user&amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;gt;nobody&amp;amp;amp;amp;amp;lt;/value&amp;amp;amp;amp;amp;gt; Unix group of processes &amp;amp;amp;amp;amp;lt;value name=&amp;amp;amp;amp;amp;quot;group&amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;gt;nobody&amp;amp;amp;amp;amp;lt;/value&amp;amp;amp;amp;amp;gt;...
6. edit configuration nginx supaya menggunakan PHP-FPM. Kat bawah ni contoh aku punya nginx conf.
nano /usr/local/nginx/conf/nginx.conf
nginx.conf
#user nobody;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 10;
gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name imiahus.com www.imiahus.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/imiahus/www/;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /home/imiahus/www/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/imiahus/www/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
}
7. Start service nginx dan php-fpm
service nginx start service php-fpm start
Done! :) .






‘KIAMAT DAN KEADAANNYA’
http://www.scribd.com/doc/36025155/Surat-Kepada-Yang-DiPertuan-Agong-Dan-Mufti-Mufti
[Reply]