NginxWithPHP7

windows64平台下使用nginx和php7搭建php学习开发平台

一、在nginx官网http://nginx.org/en/download.html下载2016-06的稳定版Stable version for windows编译好的二进制包nginx-1.10.1.zip,解压到C:/nginx目录下,双击nginx.exe就能启动。打开网页浏览器,在URL地址栏里输入http://localhost,提示nginx启动成功。
二、在php官网下载php7 for windows64 的预编译好的ThreadSafe线程安全的二进制安装包,也是解压到C:/php7目录下,设置好配置文件直接就能使用。
三、配置php7和nginx

Nginx本身是不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用。FastCGI接口在Linux下是socket,(这个socket可以是文件socket,也可以是ip socket)。为了调用CGI程序,还需要一个FastCGI的wrapper(wrapper可以理解为用于启动另一个程序的程序),这个wrapper绑定在某个固定socket上,如端口或者文件socket。当Nginx将CGI请求发送给这个socket的时候,通过FastCGI接口,wrapper接纳到请求,然后派生出一个新的线程,这个线程调用解释器或者外部程序处理脚本并读取返回数据;接着,wrapper再将返回的数据通过FastCGI接口,沿着固定的socket传递给Nginx;最后,Nginx将返回的数据发送给客户端。

在C:/php7目录下复制一份php.ini-development,重命名为php.ini,然后用notepad++软件打开此文件,修改编辑php7的配置。

找到extension_dir,去掉分号,启用。并且修改为extension_dir = “C:/php7/ext”

cgi.force_redirect = 1
cgi.rfc2616_headers = 1
upload_max_filesize = 10M

extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_gmp.dll

extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll

extension=php_openssl.dll
extension=php_pdo_mysql.dll

extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
extension=php_shmop.dll

extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll

date.timezone =Asia/Shanghai

其余的配置保持默认,不要画蛇添足。

进入目录C:/nginx/conf,用notepad++软件打开nginx.conf文件。修改配置。

启用error_log logs/error.log;

“`
server {
listen 8888;
server_name localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   D:/PHP_WWW;
        index  index.html index.htm   index.php;
    }

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   D:/PHP_WWW;
    }

    location ~ \.php$ {
      root           D:/PHP_WWW;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  
      $document_root$fastcgi_script_name;
      include       fastcgi_params;

   }

其余保持默认。。。。

保存,退出。。重启nginx ,
启动网页浏览器,在URL地址栏输入http://localhost:8888

设置的D:/PHP_WWW为php文件的工作目录,nginx监听的端口号为8888

但是nginx不方便启动和关闭重启。
网上有使用RunHiddenConsole.exe的教程,请详细参考。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值