Dec
20
2008

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

4,842 views

1. Install nginx

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

choose :

HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_SSL_MODULE
HTTP_STATUS_MODULE
.....

2. Install php

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

choose :

CLI
CGI
SUHOSIN
IPV6
FASTCGI
PATHINFO
.....

3. Install php-fpm freebsd ports

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

Extract and copy

# tar xvzf php-5.2.6-fpm-0.5.9.tar.gz
# cp -R ./php-5.2.6-fpm-0.5.9 /usr/ports/lang/php5-fpm
# cd /usr/ports/lang/php5-fpm
# make install

choose :

CLI
SUHOSIN
PATHINFO
.....

4. Configuring

update /etc/rc.conf

Add these lines :

nginx_enable="YES"
php_fpm_enable="YES"

save.

edit /usr/local/etc/nginx/nginx.conf

Find this lines in nginx.conf and adjust :

root /usr/local/www/nginx;

location / {
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 /usr/local/etc/php-fpm.conf
Find these lines :

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

change nobody into www (or your www user)

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

Run the services

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

5. Testing

# cd /usr/local/www/nginx
# nano info.php

<?php
phpinfo();
?>

save.

done.

Compatible with Apache's log file format

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

Written by Pipo in: Developer,Software |

1 Comment »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Page 1 of 11

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes