Step by step install Engine X (nginx) and php-fpm in FreeBSD

nginx Step by step install Engine X (nginx) and php fpm in FreeBSDNginx already in my list for almost 3 month but I don’t have time for play around with it. As usual freebsd ports is my preferable method to install software in FreeBSD icon smile Step by step install Engine X (nginx) and php fpm in FreeBSD

I’m lucky to get php-fpm ports from php-fpm site that work for php-5.2.3RC. After change it a bit for php 5.2.6 I can test it together with nginx stable from ports too.

Here’s my steps for install nginx with php-fpm using FreeBSD ports :

1. Install nginx

alamster# cd /usr/ports/www/nginx
alamster# make install

I choose :

HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_SSL_MODULE
HTTP_STATUS_MODULE

2. Install php

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

I choose :

CLI
CGI
SUHOSIN
IPV6
FASTCGI
PATHINFO

3. Install php-fpm, I choose it after see explanation from their website.

I just modify freebsd ports here to get it work with php-5.2.6.

alamster# wget http://alamster.googlepages.com/php5-fpm.5.2.6.tar.gz
–2008-08-04 01:08:10– http://alamster.googlepages.com/php5-fpm.5.2.6.tar.gz
Resolving alamster.googlepages.com… 209.85.173.118
Connecting to alamster.googlepages.com|209.85.173.118|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 11461 (11K) [application/octet-stream]
Saving to: `php5-fpm.5.2.6.tar.gz’

100%[======================================>] 11,461 6.05K/s in 1.8s

2008-08-04 01:08:15 (6.05 KB/s) – `php5-fpm.5.2.6.tar.gz’ saved [11461/11461]

Extract and delete

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

alamster# cd /usr/ports/lang/php5-fpm/ && make install

I choose :

CLI
SUHOSIN
PATHINFO

4. Configuring

update rc.conf

alamster# ee /etc/rc.conf

Add these lines :

nginx_enable=”YES”
php_fpm_enable=”YES”

save.

Edit nginx.conf

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

Find this lines in nginx.conf and adjust :

location / {
root /usr/local/www/nginx;
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/nginx$fastcgi_script_name;
include fastcgi_params;
}

Edit php-fpm.conf

alamster#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>

Run the services

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

alamster# /usr/local/etc/rc.d/nginx start

5. Testing

alamster# cd /usr/local/www/nginx

alamster# ee info.php

<?php
phpinfo();
?>

save.

Open this phpinfo url and see this part to check if nginx and php-fpm in the right track :

phf Step by step install Engine X (nginx) and php fpm in FreeBSD

CGI/FastCGI work as Server API

phf2 Step by step install Engine X (nginx) and php fpm in FreeBSD

nginx/0.6.32 work as webserver.

Great, I love FreeBSD ports icon smile Step by step install Engine X (nginx) and php fpm in FreeBSD