Window搭建Wnmp开发环境

一、Nginx安装:

1、版本:nginx-1.9.4

2、下载地址:http://nginx.org/en/download.html

3、指定目录:D:\Wnmp\nginx-1.9.4

4、配置:

❶、打开D:\Wnmp\nginx-1.9.4\conf\nginx.conf,编辑如下内容:

# nginx.conf
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    include D:/Wnmp/nginx-1.9.4/conf/vhosts/*.conf;
}

 ❷、在D:\Wnmp\nginx-1.9.4\conf\目录下创建vhosts文件夹,在vhosts文件夹下创建www.example.com.conf文件,打开并编辑如下内容:

 1 # www.example.com.conf
 2 server {
 3     listen 80;
 4     charset utf-8;
 5     autoindex on;
 6     server_name_in_redirect off;
 7     server_name www.example.com;
 8     root G:/Example/www.example.com/;
 9 
10     location / {
11         index index.php index.html index.htm;
12         try_files $uri $uri/ /index.php$is_args$args;
13     }
14 
15     # redirect not found error pages to the static page /40x.html
16     error_page 404 /40x.html;
17     location = /40x.html {
18         root D:/Wnmp/nginx-1.9.2/html/;
19     }
20 
21     # redirect server error pages to the static page /50x.html
22     error_page 500 502 503 504 /50x.html;
23     location = /50x.html {
24         root D:/Wnmp/nginx-1.9.2/html/;
25     }
26 
27     # proxy the PHP scripts to Apache listening on 127.0.0.1:80
28     #
29     #location ~ \.php$ {
30     #    proxy_pass http://127.0.0.1;
31     #}
32 
33     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
34     location ~ \.php$ {
35         fastcgi_pass 127.0.0.1:9000;
36         fastcgi_index index.php;
37         fastcgi_split_path_info ^(.+\.php)(/.*)$;
38         fastcgi_param PATH_INFO $fastcgi_path_info;
39         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
40         include D:/Wnmp/nginx-1.9.2/conf/fastcgi_params;
41     }
42 
43     location = /favicon.ico {
44         log_not_found off;
45         access_log off;
46     }
47 
48     # icon
49     location ~* \favicon.ico$ {
50         expires 1m;
51     }
52 
53     # deny access to .htaccess files, if Apache's document root concurs with nginx's one
54     location ~ /(\.ht|\.git|\.svn|\.hg|\.bzr) {
55         deny all;
56     }
57 }

 ❸、启动Nginx:

 1 C:\Users\Yun
 2 λ d:
 3 
 4 D:\
 5 λ cd Wnmp\nginx-1.9.4\
 6 
 7 D:\Wnmp\nginx-1.9.4
 8 λ start nginx.exe
 9 
10 D:\Wnmp\nginx-1.9.4
11 λ tasklist /fi "imagename eq nginx.exe"
12 
13 Image Name                     PID Session Name        Session#    Mem Usage
14 ========================= ======== ================ =========== ============
15 nginx.exe                    13696 Console                    6      5,616 K
16 nginx.exe                     9084 Console                    6      5,348 K

效果:

 注意:此时的Nginx还不能动态载入PHP程序

二、PHP安装:

1、版本:php-5.6.12-nts

2、下载地址:http://windows.php.net/download/#php-5.6-nts-VC11-x86

3、指定目录:D:\Wnmp\php-5.6.12-nts

4、配置:

❶、打开D:\Wnmp\php-5.6.12-nts文件夹,将php.ini-development重命名为php.ini:

❷、打开D:\Wnmp\php-5.6.12-nts\php.ini文件,指定PHP扩展加载的文件路径:

1 ; Directory in which the loadable extensions (modules) reside.
2 ; http://php.net/extension-dir
3 ; extension_dir = "./"
4 ; On windows:
5 extension_dir = "D:/Wnmp/php-5.6.12-nts/ext"

❸、打开D:\Wnmp\php-5.6.12-nts\php.ini文件,开启PHP扩展:

 1 ;;;;;;;;;;;;;;;;;;;;;;
 2 ; Dynamic Extensions ;
 3 ;;;;;;;;;;;;;;;;;;;;;;
 4 
 5 ; If you wish to have an extension loaded automatically, use the following
 6 ; syntax:
 7 ;
 8 ;   extension=modulename.extension
 9 ;
10 ; For example, on Windows:
11 ;
12 ;   extension=msql.dll
13 ;
14 ; ... or under UNIX:
15 ;
16 ;   extension=msql.so
17 ;
18 ; ... or with a path:
19 ;
20 ;   extension=/path/to/extension/msql.so
21 ;
22 ; If you only provide the name of the extension, PHP will look for it in its
23 ; default extension directory.
24 ;
25 ; Windows Extensions
26 ; Note that ODBC support is built in, so no dll is needed for it.
27 ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
28 ; extension folders as well as the separate PECL DLL download (PHP 5).
29 ; Be sure to appropriately set the extension_dir directive.
30 ;
31 extension=php_bz2.dll
32 extension=php_curl.dll
33 extension=php_fileinfo.dll
34 extension=php_gd2.dll
35 extension=php_gettext.dll
36 ;extension=php_gmp.dll
37 extension=php_intl.dll
38 ;extension=php_imap.dll
39 ;extension=php_interbase.dll
40 ;extension=php_ldap.dll
41 extension=php_mbstring.dll
42 extension=php_exif.dll      ; Must be after mbstring as it depends on it
43 extension=php_mysql.dll
44 extension=php_mysqli.dll
45 ;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
46 extension=php_openssl.dll
47 ;extension=php_pdo_firebird.dll
48 extension=php_pdo_mysql.dll
49 ;extension=php_pdo_oci.dll
50 ;extension=php_pdo_odbc.dll
51 ;extension=php_pdo_pgsql.dll
52 ;extension=php_pdo_sqlite.dll
53 ;extension=php_pgsql.dll
54 ;extension=php_shmop.dll
55 
56 ; The MIBS data available in the PHP distribution must be installed. 
57 ; See http://www.php.net/manual/en/snmp.installation.php 
58 ;extension=php_snmp.dll
59 
60 extension=php_soap.dll
61 extension=php_sockets.dll
62 ;extension=php_sqlite3.dll
63 ;extension=php_sybase_ct.dll
64 ;extension=php_tidy.dll
65 ;extension=php_xmlrpc.dll
66 ;extension=php_xsl.dll

❹、打开D:\Wnmp\php-5.6.12-nts\php.ini文件,修改默认时区,此外为东八区时区,即中华人民共和国时区:

1 # php.ini
2 [Date]
3 ; Defines the default timezone used by the date functions
4 ; http://php.net/date.timezone
5 date.timezone = "PRC"

❺、启动PHP脚本:

1 C:\Users\Yun                              
2 λ d:                                      
3                                           
4 D:\                                       
5 λ cd Wnmp\php-5.6.12-nts\                 
6                                           
7 D:\Wnmp\php-5.6.12-nts                    
8 λ php-cgi.exe -b 127.0.0.1:9000 -c php.ini

❻、重启Nginx服务器,查看PHP进程:

1 D:\Wnmp\nginx-1.9.4
2 λ nginx.exe -s reload
3 
4 D:\Wnmp\nginx-1.9.4
5 λ tasklist /fi "imagename eq php-cgi.exe"
6 
7 Image Name                     PID Session Name        Session#    Mem Usage
8 ========================= ======== ================ =========== ============
9 php-cgi.exe                   7516 Console                    6     11,176 K

效果:

posted @ 2015-08-25 20:09  iYunBlog  阅读(405)  评论(0编辑  收藏  举报