Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

第 16 章 nginx

目录

16.1. port install
16.1.1. php
16.1.1.1. php-fpm
16.1.2. /etc/rc.conf
16.1.3. /usr/local/etc/nginx/nginx.conf
16.1.4. start
16.2. 编译安装 php 与 php-fpm
16.2.1. php-5.2.x
16.2.2. php-5.3.x
pkg_add -r nginx

location / {
        root   /usr/local/www/nginx;
        index  index.html index.htm;
}

location ~ \.php$ {
        root           html;
        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;
}
	

16.1. port install

# cd /usr/ports/www/nginx

# make install

HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_STATUS_MODULE
		

16.1.1. php

ports 安装 php-fpm 适合 php-5.2.10, 高于这个版本请跳过这节, 采用编译安装。

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

extensions

# cd /usr/ports/lang/php5-extensions/
# make install
# ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini
			

php-fpm - FastCGI Process Manager

homepage: http://php-fpm.org/downloads/freebsd-port/

			
# tar xvzf php-5.2.10-fpm-0.5.13.tar.gz --directory=/usr/ports/lang
x php5-fpm/
x php5-fpm/files/
x php5-fpm/Makefile
x php5-fpm/distinfo
x php5-fpm/pkg-descr
x php5-fpm/pkg-plist
x php5-fpm/files/php-fpm.sh.in
x php5-fpm/files/patch-scripts::phpize.in
x php5-fpm/files/patch-TSRM_threads.m4
x php5-fpm/files/patch-Zend::zend.h
x php5-fpm/files/patch-Zend_zend_list.c
x php5-fpm/files/patch-Zend_zend_list.h
x php5-fpm/files/patch-ext_standard_array.c
x php5-fpm/files/patch-ext_standard_basic_functions.c
x php5-fpm/files/patch-ext_standard_dns.h
x php5-fpm/files/patch-ext_standard_image.c
x php5-fpm/files/patch-php.ini-dist
x php5-fpm/files/patch-php.ini-recommended
x php5-fpm/files/patch-main::php_config.h.in
x php5-fpm/files/patch-main_SAPI.c
x php5-fpm/files/patch-acinclude.m4
x php5-fpm/files/patch-configure.in

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

16.1.1.1. php-fpm

				
                        Unix user of processes
                        <value name="user">www</value>

                        Unix group of processes
                        <value name="group">www</value>
				
				

16.1.2. /etc/rc.conf

vim /etc/rc.conf
php_fpm_enable="YES"
nginx_enable="YES"
			

16.1.3. /usr/local/etc/nginx/nginx.conf

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

        location / {
            root   /www;
            index  index.html index.htm index.php;
        }

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

			

16.1.4. start

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