Windows开发环境搭建

2016-08-13  本文已影响70人  山天大畜

安装Python

https://www.python.org/downloads/release/python-2710/


安装 Php

http://windows.php.net/download/#php-5.6-ts-VC11-x64

解压好了后,从php.ini-develope中拷出一份php.ini来,主要改动如下:

  1. ; extension_dir = "ext"去掉前面的注释符号,使其生效

  2. date.timezone="Asia/Shanghai"设置一下,以免运行过程中报date未指定时区的warning.

CGI 设置


cgi.force_redirect = 1(nginx:1,apache:0)

cgi.fix_pathinfo = 1(nginx:1,apache:0) 

cgi.rfc2616_headers = 1(nginx:1,apache:0) 

extension_dir = "G:/Service/php-5.6.11-Win32-VC11-x64/ext"

extension=php_gd2.dll

extension=php_mbstring.dll

extension=php_mysql.dll

extension=php_mysqli.dll

extension=php_pdo_mysql.dll

extension=php_pdo_odbc.dll

extension=php_pdo_sqlite.dll

max_input_time = -1

memory_limit = 4G

创建start_php-cgi.bat文件,用于启动php-cgi的脚本,放在php目录下:


@echo off

echo Starting PHP FastCGI...

RunHiddenConsole php-cgi.exe -b 127.0.0.1:9000 -c php.ini```

*其中RunHiddenConsole在[此处](http://www.supidea.com/file.axd?file=2010%2f5%2fRunHiddenConsole.zip)下载*

创建stop_php-cgi.bat文件,用于关闭php-cgi的脚本,放在php目录下:

```bat

echo Stopping PHP FastCGI...

taskkill /F /IM php-cgi.exe > nul

exit


安装Php-Redis扩展

http://pecl.php.net/package/redis/2.2.7/windows

根据phpinfo中的信息选择对应版本,拷贝到ext文件夹 ,注意phpinfo页面中的Compiler信息应该是MSVC11

在php.ini配置文件里增加:extension=php_redis.dll


安装Php-Mongo扩展

http://docs.mongodb.org/ecosystem/drivers/php/

根据php版本选择对应dll,重命名为php-mongo.dll,拷贝到ext文件夹

在php.ini配置文件里增加:extension=php-mongo.dll


安装Apache

http://www.apachelounge.com/download/

修改配置文件http.conf:


ServerRoot "G:/Service/Apache24"

Listen 80

LoadModule rewrite_module modules/mod_rewrite.so

# php5 support

LoadModule php5_module G:/Service/php-5.6.11-Win32-VC11-x64/php5apache2_4.dll

AddType application/x-httpd-php .php .html .htm

# configure the path to php.ini

PHPIniDir "G:/Service/php-5.6.11-Win32-VC11-x64"

DocumentRoot "G:/Sites"

<Directory "G:/Sites">

    Options Indexes FollowSymLinks

    AllowOverride all

    Require all granted

</Directory>

<IfModule dir_module>

    DirectoryIndex index.html index.php

</IfModule>

下载安装Visual C++ Redistributable for Visual Studio2015:

下载地址 下载地址

安装为服务:


httpd.exe -k install


安装 Nginx

http://nginx.org/en/download.html

添加为服务

下载微软的2个工具: instsrv.exe、srvany.exe:

http://www.veryhuo.com/uploads/soft/1003/nginx_installSrv.rar

将srvany.exe复制到nginx的安装(解压)目录下,然后运行:


instsrv Nginx D:\nginx\srvany.exe  

这样就安装了一个名为Nginx的服务。也就是将srvany.exe注册成一个服务Nginx。Net start Nginx时,肯定会运行srvany.exe

将配置导入到注册表:

Window register代码


Windows Registry Editor Version 5.00  

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]  

"Application"="D:\\nginx\\nginx.exe"  

"AppParameters"=""  

"AppDirectory"="D:\\nginx\\" 

写一个stop_nginx脚本来处理nginx停止的所有操作:


@echo off  

echo Stopping nginx service...  

net stop nginx  

echo Kill nginx process...  

taskkill /F /IM nginx.exe > nul 

如果想删除服务,使用命令:


sc delete Nginx 


安装MySQL

http://dev.mysql.com/downloads/windows/installer/5.6.html


安装PhpMyAdmin

http://www.phpmyadmin.net/

拷贝config.sample.inc.php为config.inc.php

修改内容:


$cfg['blowfish_secret'] = 'cdts_change'


安装MongoDB

https://www.mongodb.org/downloads

3.0目录下新建data和logs文件夹

bin文件夹下新建mongos.cfg文件,内容如下:


logpath=G:\Service\MongoDB\Server\3.0\logs\MongoDB.log

dbpath=G:\Service\MongoDB\Server\3.0\data

将mongodb注册为服务:


G:\Service\MongoDB\Server\3.0\bin\mongod --config

G:\Service\MongoDB\Server\3.0\bin\mongod.cfg --install

执行命令行,打开客户端:


G:\Service\MongoDB\Server\3.0\bin\mongo

创建用户:


use cgbrobit

db.createUser(

  {

    user: "cgbrobit",

    pwd: "123456",

    roles: [ { role: "readWrite", db: "cgbrobit" } ]

  }

)


安装Redis

https://github.com/MSOpenTech/redis/releases


上一篇下一篇

猜你喜欢

热点阅读