Home  >  Article  >  php教程  >  nginx学习之nginx+php的编译

nginx学习之nginx+php的编译

WBOY
WBOYOriginal
2016-06-06 20:02:201062browse

nginxphp的编译 apache一般是把php当做自己的一个模块来启动的. 而nginx则是把http请求变量(如get,user_agent等)转发给 php进程,即php独立进程,与nginx进行通信. 称为 fastcgi运行方式. 因此,为apache所编译的php,是不能用于nginx的. 注意: 我们编译的PHP 要

nginx+php的编译

apache一般是把php当做自己的一个模块来启动的.

而nginx则是把http请求变量(如get,user_agent等)转发给 php进程,即php独立进程,与nginx进行通信. 称为 fastcgi运行方式.

因此,为apache所编译的php,是不能用于nginx的.

 

注意: 我们编译的PHP 要有如下功能:

连接mysql, gd,ttf, 以fpm(fascgi)方式运行

./configure  --prefix=/usr/local/fastphp \

--with-mysql=mysqlnd \

--enable-mysqlnd \

--with-gd \

--enable-gd-native-ttf\

--enable-gd-jis-conv

--enable-fpm

编译完毕后:

1:

nginx+php的配置比较简单,核心就一句话----

把请求的信息转发给9000端口的PHP进程,

让PHP进程处理 指定目录下的PHP文件.

 

如下例子:

location ~ \.php$ {

           root html;

            fastcgi_pass   127.0.0.1:9000;

           fastcgi_index  index.php;

           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

           include        fastcgi_params;

 

       }

 

1:碰到php文件,

2: 把根目录定位到 html,

3: 把请求上下文转交给9000端口PHP进程,

4: 并告诉PHP进程,当前的脚本是$document_root$fastcgi_scriptname

(注:PHP会去找这个脚本并处理,所以脚本的位置要指对)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn