Instalasi Nginx
Linux, Ubuntu, Webserver January 28th, 2010
Apa sih nginx? Nginx adalah webserver sama seperti Apache dan Lighttpd, mungkin bedanya seperti yang saya cari di paman google, klo nginx banyak yang bilang lebih powerfull n lebih cepet, dibandingkan dengan Apache ataupun Lighttpd.
Disini saya akan melakukan instalasi Nginx di LinuxMint 8 (Helena) yang merupakan turunan dari ubuntu 9.10 (Karmic Koala).
Yang pertama kita Instalasi Nginx terlebih dahulu
sudo apt-get install nginx
atau bila kita ingin menggunakan source code
sudo wget http://sysoev.ru/nginx/nginx-0.6.36.tar.gz
tar -xzvf nginx-0.6.36.tar.gz
cd nginx-0.6.36.tar.gz
sudo apt-get install build-essential
./configure
make
sudo make install
untuk settingan di ubuntu ataupun turunannya
./configure –conf-path=/etc/nginx/nginx.conf \
–error-log-path=/var/log/nginx/error.log –pid-path=/var/run/nginx.pid \
–lock-path=/var/lock/nginx.lock –http-log-path=/var/log/nginx/access.log \
–http-client-body-temp-path=/var/lib/nginx/body –http-proxy-temp-path=/var/lib/nginx/proxy \
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi –with-debug –with-http_stub_status_module \
–with-http_flv_module –with-http_ssl_module –with-http_dav_module
make
sudo make install
Setelah itu jalankan nginx
sudo /etc/init.d/nginx start
Agar setiap booting nginx dapat langsung berjalan
sudo update-rc.d nginx defaults
Untuk melihat apakah nginx telah berjalan ketikkan localhost pada browser.
Selanjutnya kita install paket php
sudo apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
kemudian edit file /etc/php5/cgi/php.ini
sudo gedit /etc/php5/cgi/php.ini
Ubah cgi.fix_pathinfo = 0 menjadi 1
[...]
cgi.fix_pathinfo = 1
Kemudian install
sudo apt-get install spawn-fcgi
gunakan perintah berikut untuk menjalankan php cgi
sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
tambahkan perintah di pada /etc/rc.local
[...]
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
[...]
edit file nginx.conf
sudo gedit /etc/nginx/nginx.conf
edit bagian berikut
[...]
worker_processes 5;
[...]
keepalive_timeout 2;
[...]
Selajutnya mengubah path file default sesuai keinginan kita
sudo gedit /etc/nginx/sites-available/default
[...]
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
location / {
#root /var/www/nginx-default;
root /home/vq/public_html;
index index.php index.html index.htm;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /images {
root /usr/share;
autoindex on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
#root /var/www/nginx-default;
root /home/vq/public_html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/vq/public_html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /\.ht {
deny all;
}
}
[...]
Terakhir kita tinggal melakukan restart nginx
sudo /etc/init.d/nginx restart
Untuk melihat apakah php-nya sudah berjalan
sudo gedit /home/vq/public_html/info.php
isi file info.php dengan kode berikut
Selamat Mencoba!
Sumber:
http://akhsan.web.id/index.php/2009/12/21/how-to-install-nginx-webserver-mysql-dan-php-di-ubuntu/
http://how2forge.com/installing-nginx-with-php5-and-mysql-support-on-ubuntu-9.04
http://wiki.debian-community.org/planets/id/feeds/Planet_Indonesia/nginx__44___dari_nol/
About
