Home | Mirror | Search

第 13 章 nginx

目錄

1. port install
1.1. php
1.1.1. php-fpm
1.2. /etc/rc.conf
1.3. /usr/local/etc/nginx/nginx.conf
1.4. start
2. 編譯安裝 php 與 php-fpm
2.1. php-5.2.x
2.2. php-5.3.x
3. worker_processes
4. events
5. http 配置
5.1. X-Forwarded-For
5.2. server
5.2.1. VirtualHost (虛擬主機)
5.2.2. location
5.2.3. ssl
5.3. expires
5.4. access
5.5. auth_basic
5.6. autoindex
5.7. ssi
5.8. rewrite
5.9. gzip
5.10. Cache
5.11. stub_status
5.12. server_tokens
5.13. add_header
5.13.1. Access-Control-Allow
5.14. valid_referers
6. Proxy
6.1. request_filename + proxy_pass
6.2. proxy_cache
6.3. proxy_cache
6.4. expires
6.5. FAQ
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;
}
	

1. port install

# cd /usr/ports/www/nginx

# make install

HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_STATUS_MODULE
		

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
			
			

1.1.1. php-fpm

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

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

1.2. /etc/rc.conf

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

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;
        }

			

1.4. start

/usr/local/etc/rc.d/php-fpm start
/usr/local/etc/rc.d/nginx start
			
comments powered by Disqus