Heim  >  Artikel  >  Backend-Entwicklung  >  Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程

Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程

WBOY
WBOYOriginal
2016-06-23 13:39:22910Durchsuche

准备篇

一、环境说明:

操作系统:Windows Server 2012 R2

PHP版本:php 5.5.8

MySQL版本:MySQL5.6.15

二、相关软件下载:

1、PHP下载地址:

http://windows.php.net/downloads/releases/php-5.5.8-nts-Win32-VC11-x86.zip

2、MySQL下载地址:

http://cdn.mysql.com/Downloads/MySQLInstaller/mysql-installer-community-5.6.15.0.msi

3、Visual C++ Redistributable for Visual Studio 2012 Update 4(x64)下载地址(安装PHP需要此插件):

http://download.microsoft.com/download/9/C/D/9CD480DC-0301-41B0-AAAB-FE9AC1F60237/VSU4/vcredist_x64.exe

4、Visual C++ Redistributable for Visual Studio 2012 Update 4(x86)下载地址(安装PHP需要此插件):

http://download.microsoft.com/download/9/C/D/9CD480DC-0301-41B0-AAAB-FE9AC1F60237/VSU4/vcredist_x86.exe

5、Microsoft Visual C++ 2010 可再发行组件包 (x86)下载地址(安装MySQL需要此插件):

http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe

6、Microsoft URL 重写模块 2.0下载地址(IIS8.5伪静态需要此插件):

http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi

安装篇

一、安装IIS8.5

服务器管理器-添加角色和功能 

下一步

选择:基于角色或基于功能的安装

下一步

选择:从服务器池中选择服务器

下一步

选择:Web服务器(IIS)

添加功能

下一步

下一步

确保CGI被选中,其他的角色服务根据需要选择,如果不知道如何选择,建议选择全部功能。

下一步

安装

正在安装中

显示安装成功,点关闭。

可以看到角色和服务器组中已经有了IIS

点开始按钮,打开IE浏览器,输入http://127.0.0.1/会看到下面的界面

IIS8.5已经安装完成。

二、安装PHP

1、安装Visual C++ Redistributable for Visual Studio 2012 Update 4(x86)

双击vcredist_x86.exe

安装

正在安装

安装完成,关闭

2、安装Visual C++ Redistributable for Visual Studio 2012 Update 4(x64)

双击vcredist_x64.exe

按照上一步的操作默认安装即可

安装完成后,点关闭

3、安装php-5.5.8-nts-Win32-VC11-x86.zip

解压php-5.5.8-nts-Win32-VC11-x86.zip文件

重命名文件夹为php,把php文件夹拷贝到C盘根目录

打开C:\php

复制php.ini-production为php.ini

用记事本打开php.ini

做如下修改:

extension_dir = "C:\php\ext"   #设置php模块路径

date.timezone = PRC   #设置时区为中国时区

register_globals = On  #开启GET数据调用

short_open_tag = On  #php支持短标签

cgi.force_redirect = 0  #开启以CGI方式运行php

fastcgi.impersonate = 1;

cgi.rfc2616_headers = 1

以下php扩展模块,根据需要选择开启,取消前面的分号为开始相应扩展模块

extension=php_curl.dll

extension=php_gd2.dll

extension=php_mbstring.dll

extension=php_exif.dll

extension=php_mysql.dll

extension=php_mysqli.dll

extension=php_sockets.dll

extension=php_xmlrpc.dll

extension=php_pdo_mysql.dll

最后,保存退出

4、配置IIS支持PHP

打开:控制面板-系统和安全-管理工具-Internet Information Services(IIS)管理器

双击左边“起始页”下面的计算机名称

找到中间的IIS部分,打开“处理程序映射”

点右边的“添加模块映射”

请求路径:*.php

模块:FastCgiModule

可执行文件(可选):C:\php\php-cgi.exe

名称:FastCGI

最后,确定

点“是”

双击左边“起始页”下面的计算机名称

找到中间的IIS部分,打开“FastCGI设置”

右键选中:C:\php\php-cgi.exe然后选择编辑

监视对文件所做的更改:C:\php\php.ini

环境变量,点旁边的"..."

点“添加”

Name:PHP_FCGI_MAX_REQUESTS

Value:1000

确定

确定

双击左边“起始页”下面的计算机名称

找到中间的IIS部分,打开“默认文档”

点右边的“添加”

名称:index.php

确定

可以看到默认文档中已经有了index.php

选择右边操作下面“上移”选项,把index.php移到最上边

5、测试php程序是否正常运行

打开:

C:\inetpub\wwwroot

新建一个index.php文件

内容如下:

phpinfo();

?>

最后,保存退出

在浏览器里面打开http://127.0.0.1/

出现下面的界面,说php程序可以正常运行。

6、开启Zend OPcache,加速php执行效率

用记事本打开C:\php\php.ini文件, 在最底部增加以下代码

[Zend OPcache]

zend_extension = "C:\php\ext\php_opcache.dll"

opcache.memory_consumption=1024

opcache.optimization_level=1

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4096

opcache.revalidate_freq=60

opcache.fast_shutdown=1

opcache.enable=1

opcache.enable_cli=1

最后,保存退出

在浏览器里面打开http://127.0.0.1/,可以看到Zend OPcache配置选项

三、安装MySQL

双击打开mysql-installer-community-5.6.15.0.msi

选择第一项Install MySQL Products(安装MySQL)

选中“I accept the license terms”(我接受许可条款),点Next

选中“Skip the check for update (not recommended)”(跳过检查更新),点Next

选中“Custom”(自定义安装)

Installation Path(安装路径):C:\Program Files\MySQL\

Data Path(数据库存放路径):C:\ProgramData\MySQL\MySQL Server 5.6\

Next

确保“MySQL Server 5.6.15”被选中,点Next(其他的组件可以选择安装)

这里全部选中,安装所有组件

Execute (执行)

选中“我已阅读并接受许可条款”

点安装

完成

Execute (执行)

Next

Execute (执行)

Next

Next

Config Type(配置类型):

Developer Machine(开发服务器)

Server Machine(普通服务器)

Dedicated Machine(专用服务器)

这里选择第二项:Server Machine(普通服务器)

勾选“Enable TCP/IP Networking”(开启TCP网络端口)

Port Number(端口):3306

勾选“Open firewall port for network access“(打开防火墙端口网络访问)

Next

MySQL Root password:输入密码

Repeat Password:重复输入密码

设置好之后,点Next

Windows Server Name(Windows服务名):MySQL56

勾选:“Start the MySQL Server at System Startup“(在系统启动时启动MySQL服务器)

Next

Next

Next

点Finish(完成)

关闭此窗口

打开MySQL安装路径

C:\Program Files\MySQL\MySQL Server 5.6

复制my-default.ini为my.ini

进入C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MySQL\MySQL Server 5.6目录

打开MySQL Server 5.6 Command Line Client

输入安装时候的MySQL root账号密码,回车,登录到MySQL控制台

exit(退出)

MySQL安装完成

四、配置IIS8.5支持伪静态

双击安装Microsoft URL 重写模块rewrite_x64_zh-CN.msi

安装

正在安装

完成

在:控制面板\系统和安全\管理工具\Internet Information Services (IIS)管理器中可以看到”URL重写“

在:网站根目录下新建文件web.config,添加伪静态规则代码即可实现网站静态化

至此,Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程完成。

原博文地址:http://www.osyunwei.com/archives/7378.html

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn