Senin, 07 Desember 2009

instalasi,konfigurasi nginx serta mengaktifkan php-cgi di freebsd

Apa yang nginx?

Nginx adalah (kepanjangan "engine X") is a lightweight web server/reverse proxy and e-mail (IMAP/POP3) proxy, licensed under a BSD-like license. Nginx adalah (diucapkan "mesin X") adalah sebuah web server ringan / reverse proxy dan e-mail (IMAP/POP3) proxy, dilisensikan di bawah lisensi BSD-mirip.

Dalam tutorial ini kita akan mencoba untuk menginstal web server nginx dengan PHP5, PHP5 Ext, MySQL5 dan Pecl-Memcache PHP FreeBSD7 modul server.

Saya akan menggunakan port untuk menginstal semua paket.

Installing MySQL6

di tutorial sebelumnya saya sudah membuat langkah-langkah instalasi dan konfigurasi. jadi saya asumsikan tmen2 sudah menginstall mysql60-server

langkah selanjutnya adalah

Installing PHP5

# cd /usr/ports/lang/php5
# make config # Make config (make config disini digunakan untuk mensetting package yang akan diinstall dalam php5)
[X] CLI Build CLI version

[X] CGI Build CGI version

[X] APACHE Build Apache module

[ ] DEBUG Enable debug

[X]] SUHOSIN Enable Suhosin protection system

[X] MULTIBYTE Enable zend multibyte support

[ ] IPV6 Enable ipv6 support

[ ] REDIRECT Enable force-cgi-redirect support (CGI only)

[ ] DISCARD Enable discard-path support (CGI only)

[X] FASTCGI Enable fastcgi support (CGI only)

[X] PATHINFO Enable path-info-check support (CGI only)

# make install clean # Make install bersih
#cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

langkah selanjutnya instalasi php5-extension

Installing PHP5 Extension

[code]# cd /usr/ports/lang/php5-extensions/

# make config #

Options for php5-extensions 1.0 Pilihan untuk php5-extensions 1,0
------------------------------------------------- -------------------------------------------------
[X] FTP FTP support

[X] GD

[X] GETTEXT

[X] MBSTRING

[X] MYSQL

[ ] POSIX

[ ] SQLITE

[X] ZLIB

# make install clean

langkah selanjutnya instalasi nginx

Installing Nginx

#cd /usr/ports/www/nginx/

#make install clean

Installing Lighttpd

#cd /usr/ports/www/lighttpd/

#make install clean

Install spawn-fcgi

Digunakan untuk mengaktifkan php yang ada pada komputer server kita.

Ambil spawn-fcgi terbaru dari instalasi Lighttpd lain atau hanya menginstalnya sebagai berikut:
# pkg_add -r -v lighttpd
Sample output: Contoh output:

 scheme:   [ftp] skema: [ftp] 
user: [] user: []
password: [] password: []
host: [ftp.freebsd.org] host: [ftp.freebsd.org]
port: [0] Port: [0]
document: [/pub/FreeBSD/ports/amd64/packages-7.0-release/Latest/lighttpd.tbz] Dokumen: [/ pub/FreeBSD/ports/amd64/packages-7.0-release/Latest/lighttpd.tbz]
---> ftp.freebsd.org:21 ---> Ftp.freebsd.org: 21
looking up ftp.freebsd.org menengadah ftp.freebsd.org
connecting to ftp.freebsd.org:21 menghubungkan ke ftp.freebsd.org: 21
<<<> <<<220>
>>> USER anonymous >>> PENGGUNA anonim
<<<> <<<331>
..... .....
..... .....
x lib/lighttpd/mod_access.so x lib / lighttpd / mod_access.so
x lib/lighttpd/mod_accesslog.a x lib / lighttpd / mod_accesslog.a
x lib/lighttpd/mod_accesslog.la x lib / lighttpd / mod_accesslog.la
x lib/lighttpd/mod_accesslog.so x lib / lighttpd / mod_accesslog.so
x lib/lighttpd/mod_alias.a x lib / lighttpd / mod_alias.a
x lib/lighttpd/mod_alias.la x lib / lighttpd / mod_alias.la
x lib/lighttpd/mod_alias.so x lib / lighttpd / mod_alias.so
x lib/lighttpd/mod_auth.a x lib / lighttpd / mod_auth.a
x lib/lighttpd/mod_auth.la x lib / lighttpd / mod_auth.la
..... .....
.. ..

Sekarang Anda dapat menggunakan / etc / local / bin / spawn-fcgi untuk proses swap. Jika Anda ingin, Anda dapat menyalin / usr / local / bin / spawn-fcgi ke / root atau direktori lain dan hanya menghapus paket lighttpd dengan mengetikkan perintah berikut:

# cp /usr/local/bin/spawn-fcgi /root/

# pkg_delete -v lighttpd-1.4.18_1

# cp /root/spawn-fcgi /usr/local/bin/spawn-fcgi

Sekarang Anda dapat mulai PHP FastCGI dari baris perintah sebagai berikut:

# /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/local/bin/php-cgi
berikut maksud dari command line diatas,

  • -a 127.0.0.1 : PHP FastCGI bind IP address, where Nginx will connect. -a 127.0.0.1: PHP FastCGI bind alamat IP, di mana nginx akan menghubungkan.
  • -p 9000 : PHP FastCGI port number, where Nginx will connect. -p 9.000: PHP FastCGI nomor port, di mana nginx akan menghubungkan.
  • -u www : PHP FastCGI username. -u www: PHP FastCGI username.
  • -g www : PHP FastCGI groupname. -g www: PHP FastCGI groupname.
  • -f /usr/local/bin/php-cgi : Path to PHP5 fastcgi binary. -f / usr / local / bin / php-cgi: Path ke PHP5 fastcgi biner.

Memverifikasi bahwa php berjalan sebagai FastCGI, masukkan:
# sockstat -4 | grep 9000
Contoh Keluaran:

 www      php-cgi    8998  0  tcp4   127.0.0.1:9000    *:* php-cgi www 8998 0 tcp4 127.0.0.1:9000 *: * 
www php-cgi 8997 0 tcp4 127.0.0.1:9000 *:* php-cgi www 8997 0 tcp4 127.0.0.1:9000 *: *
www php-cgi 8996 0 tcp4 127.0.0.1:9000 *:* php-cgi www 8996 0 tcp4 127.0.0.1:9000 *: *
www php-cgi 8995 0 tcp4 127.0.0.1:9000 *:* php-cgi www 8995 0 tcp4 127.0.0.1:9000 *: *
www php-cgi 8994 0 tcp4 127.0.0.1:9000 *:* php-cgi www 8994 0 tcp4 127.0.0.1:9000 *: *
www php-cgi 8993 0 tcp4 127.0.0.1:9000 *:* php-cgi www 8993 0 tcp4 127.0.0.1:9000 *: *

# cd /tmp
# fetch http://bash.cyberciti.biz/dl/251.sh.zip
- jika tidak dapat mendownload silahkan download secara manual dengan mengunjungi website

http://bash.cyberciti.biz/dl/251.sh.zip
- setelah itu masukkan file yg telah didownload tadi dengan menggunakan aplikasi winscp
- setelah selesei lanjutkan perintah berikut
# unzip 251.sh.zip
# mv 251.sh /usr/local/etc/rc.d/php.cgi.sh
# chmod +x /usr/local/etc/rc.d/php.cgi.sh
# rm 251.sh.zip

Untuk memulai php FastCGI, enter:
# /usr/local/etc/rc.d/php.cgi.sh start
# sockstat -4 | less

Berhenti php FastCGI, enter:
# /usr/local/etc/rc.d/php.cgi.sh stop

Connect Nginx Webserver To PHP FastCGI Process

Buka file ngixn.conf Anda, masukkan:
# vi /usr/local/etc/nginx/nginx.conf
Tambahkan konfigurasi berikut nginx petunjuk sehingga dapat melewati naskah PHP FastCGI server untuk mendengarkan pada 127.0.0.1:9000:

location ~ \.php$ { lokasi ~ \. php $ (
fastcgi_pass 127.0 .0 .1 : 9000 ;
fastcgi_pass 127,0 .0 .1: 9.000;

fastcgi_index index.php ; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /websites/example.com/http$fastcgi_script_name ; fastcgi_param SCRIPT_FILENAME / website / example.com / http $ fastcgi_script_name;
include fastcgi_params ; termasuk fastcgi_params;
} )

Jika situs Web Anda di-host di / home / www / zeeboy / http, konfigurasi Anda akan terlihat seperti sebagai berikut:

server { server (
listen 80 ; mendengarkan 80;
server_name zeeboy www.ny@h_ny0.com ; SERVER_NAME zeeboy www.ny@h_ny0.com;

access_log /var/log/nginx/zeeboy/access.log main ; access_log / var / log / nginx / zeeboy / access_log utama;

location / { lokasi / (
root /home/www/zeeboy/http ; root / home / www / zeeboy / http;
index index.php index.html index.htm ; indeks index.php index.html index.htm;
} )

error_page 500 502 503 504 /50x.html ; error_page 500 502 503 504 / 50x.html;
location = /50x.html { lokasi = / 50x.html (
root /usr/local/www/nginx-dist ; root / usr / local / www / nginx-dist;
} )

# Mengoper naskah PHP FastCGI server untuk mendengarkan pada 127,0 .0 .1: 9.000
location ~ \.php$ { lokasi ~ \. php $ (
fastcgi_pass 127.0 .0 .1 : 9000 ; fastcgi_pass 127,0 .0 .1: 9.000;
fastcgi_index index.php ; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/www/zeeboy/http$fastcgi_script_name ; fastcgi_param SCRIPT_FILENAME / home / www / zeeboy / http $ fastcgi_script_name;
include fastcgi_params ; termasuk fastcgi_params;
} )

location ~ /\.ht { lokasi ~ / \. ht (
deny all ; deny all;
} )
} )

Restart Nginx web server Nginx restart web server

# nginx -c /usr/local/etc/nginx/nginx.conf -t
# /usr/local/etc/rc.d/nginx restart

Test php with following sample script: Uji php dengan script contoh berikut:

php
phpinfo ( ) ;
?>
sedikit saja yang saya sampaikan,jika da yang tidak berkenan ataupun salah dalam pembuatan artikel ini saya mohon maaf.
Jika da yg salah atau kurang tlg ditambahin aja..


^_^

1 komentar:

  1. wah, mas nyahnyo ternyata punya blog jg to

    tuker link ya
    http://bongo90.wordpress.com

    BalasHapus


Blogspot Templates by Isnaini Dot Com. Powered by Blogger and Supported by Lincah.Com - Mazda Cars