Install nginx dengan PHP pada Ubuntu

Nginx [engine x] adalah HTTP dan server proxy reserve serta proxy mail server yang ditulis oleh Igor Sysoev. untuk lebih detailnya silahkan googling aj.

Install PHP 5-cgi:

Login sebagai root / super user

#apt-get install nginx

#apt-get install php5-cgi

Membuat start-up script php-fastcgi :

#vi /etc/init.d/php-fastcgi

Inside, put:

#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS=”- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND”
RETVAL=0

start() {
echo -n “Starting PHP FastCGI: ”
start-stop-daemon –quiet –start –background –chuid “$USER” –exec /usr/bin/env — $PHP_CGI_ARGS
RETVAL=$?
echo “$PHP_CGI_NAME.”
}
stop() {
echo -n “Stopping PHP FastCGI: ”
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo “$PHP_CGI_NAME.”
}

case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage: php-fastcgi {start|stop|restart}”
exit 1
;;
esac
exit $RETVAL

Pastikan file php-fastcgi executable pada saat start-up:

#chmod 755 /etc/init.d/php-fastcgi

Jalankan PHP-CGI:

#/etc/init.d/php-fastcgi start

Jalankan di setiap start-up:

#update-rc.d php-fastcgi defaults

Sampai disini php-cgi telah selesai dan sudah jalan.

Tambah konfigurasi dibawah ini pada settingan nginx.conf atau site-available/default

location ~ \.php$ {

fastcgi_pass    127.0.0.1:9000;

fastcgi_index   index.php;

fastcgi_param   SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;

include         fastcgi_params;

}

Fastcgi_param  sesuaikan dengan lokasi dari DocumentRoot server.

Jalankan nginx:

#/etc/init.d/nginx start

Buatlah file test.php pada directory document root web server anda:

<?php

phpinfo();

Dan silahkan buka sesuai hasil pada address bar browser  http://ip-address/test.php.

About Sharing Data
Kami hanya ingin berbagi ilmu dan informasi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: