Triển khai máy chủ web, Dịch vu IT, Giải pháp Công nghệ

Từng bước cài đặt X (nginx) và php-fpm trong FreeBSD

ITtoday-Nginx là một mã nguồn miễn phí mở máy chủ web, proxy ngược và IMAP/POP3 proxy server. Nginx đã phát triển thành một lựa chọn khả thi cho nhiều thổi phồng Apache. Nó đã phát triển trên Apache với các điều khoản của bộ nhớ thấp và ổn định.Dưới đây là chúng tôi hướng dẫn các bước để cài đặt Nginx với php-FPM sử dụng các cổng FreeBSD.

1. Cài Đặt Nginx

alamster# cd /usr/ports/www/nginx
alamster# make install
I choose :
HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_SSL_MODULE
HTTP_STATUS_MODULE

2. Cài Đặt PHP
alamster# cd /usr/ports/lang/php5
alamster# make install
I choose :
CLI
CGI
SUHOSIN
IPV6
FASTCGI
PATHINFO

3. Cài Đặt PHP-FPM
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. Cấu Hình
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 :
nobody –>
nobody –>
change nobody into www
www
www
Run the services
alamster# /usr/local/etc/rc.d/php-fpm start
alamster# /usr/local/etc/rc.d/nginx start

5. Chạy thử
alamster# cd /usr/local/www/nginx
alamster# ee info.php
phpinfo();
?>
save.
Open this phpinfo url and see this part to check if nginx and php-fpm in the right track :

CGI/FastCGI work as Server API

nginx/0.6.32 work as webserver.

Tất cả các bước để tiến hành cài đặt X (nginx) và php-fpm trong FreeBSD đã hoàn tất.

Chúc các bạn thành công!

Rate this post