May 26

I have been recommend by my friend to use nginx for my wpmu server and compare it with the wpmu apache server, hmm an interesting idea, but since there is no server that available i need to wait until i get my hands on the available remain server. Okay the question know what is nginx actually , and do i need to use Ubuntu as the OS, since i see alot of big domain using freebsd and nginx so why not if i am trying Freebsd, if you want anotehr review about nginx and another web server click here

What is nginx ?

a lightweight web server/reverse proxy and e-mail (IMAP/POP3) proxy, licensed under a BSD-like license

okay i will try to install nginx from FreeBSD ports

1. Go to nginx Freebsd port and start the installation

# cd /usr/ports/www/nginx

# make clean install

You will see a choice of module component, you can choose what ever you want. Here is my choice:

HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_SSL_MODULE
HTTP_STATUS_MODULE

2. Install php from the Freebsd ports

# cd /usr/ports/lang/php5
# make clean install

you will see another php module that you can pick for the php installation, i choose this module:
CLI
CGI
SUHOSIN
IPV6
FASTCGI
PATHINFO

3. Installing php-fpm

php-fpm – is a patch for php4/5 to greatly improve FastCGI SAPI usage in production, click here for more reference about php-fpm advantage/ features

#wget http://php-fpm.anight.org/downloads/freebsd-port/php-5.2.6-fpm-0.5.9.tar.gz

extract  move it to ports directory and delete the sourcecode

# tar xvzf php5-fpm.5.2.6.tar.gz –-directory=/usr/ports/lang && rm php5-fpm.5.2.6.tar.gz

move to php5-fpm ports directory and installed
# cd /usr/ports/lang/php5-fpm/ && make install

Again you will see list of module , and i choose:

CLI
SUHOSIN
PATHINFO

4. We need to configuring and update the nginx and php-fpm on rc.conf

# ee /etc/rc.conf

Scroll down and add :

nginx_enable=”YES”
php_fpm_enable=”YES”

5. We also need to configure nginx.conf on /usr/local/etc/nginx/nginx.conf and edit the root directory path and add php component

# ee /usr/local/etc/nginx/nginx.conf

location / {
root /usr/local/www/data;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/data$fastcgi_script_name;
include fastcgi_params;
}

i use /usr/local/www/data as my root directory that is why you need to set fastcgi_param SCRIPT_FILENAME to /usr/local/www/data$fastcgi_script_name if not you will found this error when you access your php file:

“No input file specified.”

6. We need to edit php-fpm.conf to specify the user and group for php-fpm

#ee /usr/local/etc/php-fpm.conf

Find these lines :

<!– <value name=”user”>nobody</value> –>
<!– <value name=”group”>nobody</value> –>

change nobody into www

<value name=”user”>www</value>

<value name=”group”>www</value>

7. Now you need tostart the nginx and php-fpm service

# /usr/local/etc/rc.d/php-fpm start
# /usr/local/etc/rc.d/nginx start

8. NOw  you just need to test your nginx and php-fpm by going to your file www root and create phpinfo page to see the php version
# cd /usr/local/www/data

ee test.php
<?
phpinfo();
?>

Now access it:

http://localhost/test.php

nginx1

nginx2