NginX: Load Balancing, Failover, and Geo Location (Part 2)

NginX: Load Balancing, Failover, and Geo Location (Part 2)

On the previous post we were talking about simple dns failover using two nameservers / ip addresses, now we will move the conversation to the more exciting one, we will use frontend server to control the backend servers, here is the illustration.

One frontend server decides whether to put the visitor to the server A or server B, here i am using NginX as frontend and also NginX as backend server.

Why don’t you use another web server as the backend?

I like NginX, for me it is easy to understand NginX configuration than another web server. Before we start to configure it, install NginX on the frontend and backend servers. I’m using CentOS 5 by the way.

wget http://pkgs.serversreview.net/files/nginx-1.1.13.tar.gz
tar -zxvf nginx-1.1.13.tar.gz
cd nginx-1.1.13
useradd www
passwd www
./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/  --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-file-aio --with-mail_ssl_module --with-ipv6
make
make install

in the configurations above, as usual i am using “www” user and group for NginX. Next download NginX init script and make it executable.

(more…)

{ 0 comments }

Lighttpd, PHP with PHP-FPM, and MySQL Under Ubuntu Maverick

Lighttpd, PHP with PHP-FPM, and MySQL Under Ubuntu Maverick

It is time for Lighttpd the “Fly Light” webserver installation include PHP and MySQL under Ubuntu 10.10 Maverick, let’s go!

First, update repository list, install dependencies, and remove unneeded modules

apt-get update -y
apt-get install -y build-essential make automake patch cadaver bc netcat libgeoip1 libgeoip-dev fontconfig libfontconfig-dev libpam0g-dev libpam-devperm ldap-utils libldap-2.4-2 libldap2-dev libdb4.6 libxpm-dev libtool libaio-dev libltdl3-dev mcrypt libmcrypt-dev libmhash-dev unixodbc unixodbc-dev zip unzip nano perl openssl libssl-dev libdevel-repl-perl libperl-dev libpcre3 libpcre3-dev libjpeg62 libjpeg62-dev libpng-dev libtiff4 libtiff-dev libfreetype6 libfreetype6-dev libgmp3-dev aspell libaspell-dev libpspell-dev libiconv-ruby mlocate libc-client2007e libc-client2007e-dev uw-imapd tidy libtidy-dev libbz2-dev gamin libgamin-dev sqlite3 libsqlite3-dev libreadline6 libreadline6-dev e2fsprogs uuid-dev memcached libmemcache-dev
apt-get remove -y apache2 apache2-doc apache2-utils apache2.2-common bind9 php5 mysql-server curl libcurl3 libcurl-dev libidn11 libidn11-dev libxslt-dev

pkill apache2
pkill named
pkill sendmail-mta

Install additional modules

wget http://pkgs.serversreview.net/files/gd-2.0.33.tar.gz
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr --libdir=/usr/lib --with-png=/usr/lib --with-freetype=/usr/lib --with-fontconfig=/usr/lib --with-jpeg=/usr/lib --with-xpm=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/libev-4.04.tar.gz
tar -zxvf libev-4.04.tar.gz
cd libev-4.04
./configure --prefix=/usr --libdir=/usr/lib --with-pic 
make
make install

wget http://pkgs.serversreview.net/files/gnupg-1.4.11.tar.gz
tar -zxvf gnupg-1.4.11.tar.gz
cd gnupg-1.4.11
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget libidn-1.9.tar.gz http://pkgs.serversreview.net/files/libidn-1.9.tar.gz
tar -zxvf libidn-1.9.tar.gz
cd libidn-1.9
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/curl-7.21.6.tar.gz
tar -zxvf curl-7.21.6.tar.gz
cd curl-7.21.6
./configure --prefix=/usr --libdir=/usr/lib --with-openssl --with-libidn  --enable-ipv6
make
make install

wget http://pkgs.serversreview.net/files/libxml2-2.7.8.tar.gz
tar -zxvf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
rm -rf /usr/lib/libxml2*
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
rm -rf /usr/lib/libxslt* /usr/lib/libexslt*
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/lua-5.1.4.tar.gz
tar -zxvf lua-5.1.4.tar.gz
cd lua-5.1.4
sed -i 's/\/usr\/local/\/usr/g' Makefile
#if x86_64 then
#edit src/Makefile
#change CFLAGS= -O2 -Wall $(MYCFLAGS)
#with CFLAGS= -O2 -Wall -fPIC $(MYCFLAGS)
make linux install

wget http://pkgs.serversreview.net/files/valgrind-3.6.1.tar.bz2
tar -jxvf valgrind-3.6.1.tar.bz2
cd valgrind-3.6.1
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/libevent-2.0.11-stable.tar.gz
tar -zxvf libevent-2.0.11-stable.tar.gz
cd libevent-2.0.11-stable
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/gdbm-1.8.3.tar.gz
tar -zxvf gdbm-1.8.3.tar.gz
cd gdbm-1.8.3
./configure --prefix=/usr --libdir=/usr/lib
make
make install

(more…)

{ 0 comments }

Ubuntu 10.04.2 Lucid With NginX – PHP – MySQL

Ubuntu 10.04.2 Lucid With NginX – PHP – MySQL

My friend told me about my NginX Auto Installer, too bad because it only support CentOS, he really want to use my auto installer if it supports Debian or Ubuntu. As i said before, i’ve never tried OS other than CentOS, so last night i tried to install NginX, PHP, and MySQL under Ubuntu 10.04.2 Lucid, guess what? It was confusing me, why can’t this OS just give a standard name for their modules and packages? For example, on CentOS if we want to install PAM and PAM devel, then we’re just type

yum install pam pam-devel

but on Ubuntu

apt-get install libpam0g-dev libpam-devperm

Why not creating the normal name like ‘pam’ for package name and ‘pam-devel’ for development package name? I had to do googling for almost of those packages which i wanted to install because they have a ‘not normal’ name. :p

Okay, enough with the preamble story, here’s the result of my experiment.

Box: Ubuntu 10.04.2 Lucid 64bit with 256MB RAM OpenVZ

First update Ubuntu repository list and update existing packages

apt-get update
apt-get upgrade

Install dependencies

apt-get install -y build-essential make automake patch bc netcat libgeoip1 libgeoip-dev fontconfig libfontconfig-dev libpam0g-dev libpam-devperm slapd ldap-utils libldap-2.4-2 libdb4.6 libxpm-dev libtool libaio-dev libltdl3-dev libmcrypt-dev libmhash-dev unixodbc unixodbc-dev zip unzip nano perl openssl libssl-dev libdevel-repl-perl libperl-dev libpcre3 libpcre3-dev libjpeg62 libjpeg62-dev libpng-dev libtiff4 libtiff-dev libfreetype6 libfreetype6-dev libgmp3-dev aspell libaspell-dev libpspell-dev libiconv-ruby mlocate libc-client2007e libc-client2007e-dev uw-imapd tidy libtidy-dev libbz2-dev libmysqlclient15-dev

Because i want to build NginX, PHP, and MySQL manually from source, also i will update a few dependencies for PHP, so now remove the following packages and also stop apache and bind processes.

apt-get remove apache2 php5 mysql-server gnupg curl libcurl3 libcurl-dev libidn11 libidn11-dev libxslt-dev
killall -9 apache2
killall -9 named

Install GD Library

wget http://pkgs.serversreview.net/files/gd-2.0.33.tar.gz
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr --libdir=/usr/lib --with-png=/usr/lib --with-freetype=/usr/lib --with-fontconfig=/usr/lib --with-jpeg=/usr/lib --with-xpm=/usr/lib
make
make install

(more…)

{ 0 comments }

Ngiiinnxxxx

Ngiiinnxxxx

New update: Nginx 0.8.54 + PHP 5.3.5 has been posted

I’m doing this on my CentOS 5.5 64bit with 256MB RAM OpenVZ VPS, another / my way to install Nginx with the appropriate modul for hosting WordPress site or blog. Nginx version is still 0.8.53 because i’m using Epel Repository.

Download Epel Repository
32bit

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

64bit

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Update YUM

yum update

Install Nginx and required packages

yum install -y nginx patch libtool libmcrypt-devel libxml2-devel make automake gcc gcc-c++ sudo flex bison wget zlib-devel openssl-devel pcre pcre-devel pcre-devel gd-devel bzip2* libc-client-devel.x86_64

Start Nginx

chkconfig --add nginx
chkconfig nginx on
/etc/init.d/nginx start

Optional: Before starting Nginx, you have to stop and / or remove httpd

service httpd stop
yum remove -y httpd

Install MySQL

yum install -y mysql mysql-server mysql-devel
service mysqld start

(more…)

{ 0 comments }