windows+nginx+php安装教程

来源:互联网 发布:mac eclipse配置tomcat 编辑:程序博客网 时间:2024/06/11 18:40


本文转自:http://www.myhack58.com/Article/sort099/sort0100/2012/35580_4.htm

根据此教程的指点,我完成了windows+nginx+php安装,下面是我使用中的一些补充

第一部分:准备工作。(windows xp sp3

1.首先是下载软件。(我在安装的时候用以下版本失败了,成功:nginx-1.0.11.zip+php-5.2.16-nts-Win32-VC6-x86.zip

NGINX-1.3.8官网下载:http://nginx.org/en/download.html

PHP5.4.8版本下载地址:http://windows.php.net/download/

Mysql5.5.28版本下载地址:http://www.mysql.com/downloads/mysql/

2.安装mysql软件。

 

3.解压NGINXPHP到你自己安装位置。这里我多装在D盘。

NGINX目录D:\nginx

PHP目录D:\php

 

第二部分:安装nginx

1.打开D:\nginx目录,运行该文件夹下的nginx.exe

2.测试是否启动nginx。打开浏览器访问http://localhost http://127.0.0.1,看看是否出现“Welcome to nginx!”,出现的证明已经启动成功了。没有启动的话,看看80端口有占用没。

注意:该网站目录在D:\nginx\html

 

server {
Listen //
这里用了apache的同学一定要注意了,不可以再用80,改成8000ok

}

第三部分:安装php(这里主要讲nginx配置启动php,以cgi运行php假如系统里已经有安装好的PHP,那么可以忽略此步,启动fast_cgi里启动那个PHPok

 

nginx配置文件是conf文件夹里的nginx.conf

1.修改大概第43~45行之间的

 

        location /{            root   html;             index  index.htmlindex.htm;         }

修改网站文件的路径,以及添加index.php的默认页。

 

        location /{            root   D:/www;            index  index.html index.htmindex.php;         }

2.支持php的设置

 

修改大概在第63-71行的

 

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000         #         location ~\.php$ {         #    root           html;         #    fastcgi_pass   127.0.0.1:9000;         #    fastcgi_index  index.php;         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;         #    include        fastcgi_params;         #}

先将前面的“#”去掉,同样将root  html;改为root   D:/www;。再把“/scripts”改为“$document_root”,这里的“$document_root”就是指前面“root”所指的站点路径,这是改完后的:

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000         #         location ~\.php$ {             root           D:/www;             fastcgi_pass   127.0.0.1:9000;             fastcgi_index  index.php;             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             include        fastcgi_params;         }

 

3.D:/php下复制php.ini-development文件,并将文件名改为php.ini修改php配置文件php.ini,保存即可。

730; extension_dir = "ext" 先去前面的分号再改为extension_dir = "D:\php\ext"

919;date.timezone = 先去前面的分号再改为date.timezone =Asia/Shanghai

736enable_dl = Off 改为 enable_dl = On

743;cgi.force_redirect = 1 先去前面的分号再改为cgi.force_redirect = 0

771;fastcgi.impersonate = 1 去掉前面的分号

783;cgi.rfc2616_headers = 0 先去前面的分号再改为cgi.rfc2616_headers = 1

还有PDO哦,根据需要开启吧

extension=php_pdo.dll

extension=php_pdo_mysql.dll

 

880881行,去掉前面的“;extension=php_mysql.dllextension=php_mysqli.dll   (支持MYSQL数据库)

 

其他的配置请按照自己的需求更改。

 

第三部分试运行以及编辑运行配置文件

D:\php>php-cgi.exe -127.0.0.1:9000-c D:\php\php.iniF:\wnmp\phpphp-cgi.exe -127.0.0.1:9000c F:\wnmp\php\php.ini

 切记:一定要启动PHP FastCgi,不然是解析不了PHP滴哦,我在这居然浪费了不少时间。

D:/www下新建一个index.php

<?php phpinfo();?>

访问出现php的信息就说明php已经成功安装。

原创粉丝点击