一、新建IIS服务器

然后一直点击下一步,直到下图所示:

选择上如下图所选:

然后下一步安装上即可。
二、IIS服务器配置
新建网站如下图所示:

点击基本设置,按要求填写即可:

双击处理映射程序

弹出如下图所示:

点击添加模块映射,填写如下图所示:

接下来:

双击默认文档,添加index.php:

三、下载php,并配置
链接:https://windows.php.net/downloads/releases/php-7.3.17-nts-Win32-VC15-x64.zip,注意php-7.4对tp5.1支持有问题,所以最好用php7.3

把上面的复制一份,修改为php.ini
修改php.ini如下所示:
- zlib.output_compression = On //启用Gzip压缩
- max_execution_time = 30 //最大执行时间,按需改
- memory_limit = 128M //内存大小限制
- display_errors = Off //关闭报错
- error_log = e:\temp\php_errors.log
- post_max_size = 100M //最大POST大小,按需改
- extension_dir = "e:\PHP\ext" //ext文件夹位置
- cgi.force_redirect = 0
- cgi.fix_pathinfo=1
- fastcgi.impersonate = 1
- fastcgi.logging = 0
- upload_tmp_dir = e:\temp
- upload_max_filesize = 100M //最大上传大小,按需改
- date.timezone = Asia/shanghai //时区
- session.save_path = "e:\temp"
- session.auto_start = 0
- sys_temp_dir = "e:\web\temp\tmp"
开启扩展:
extension=xxxxx //去掉前面的分号以启用对应扩展
我打开了这些:curl、fileinfo、gd2、gettext、mbstring、exif、mysqli、openssl、pdo_mysql、xmlrpc
四、IIS url rewrite错误
win+R 输入 regedit
在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp位置
修改注册表
把MajorVersion的值改为9
下载:https://www.iis.net/downloads/microsoft/url-rewrite
并安装即可。
五、tp5的配置
在public文件夹下添加web.config,并填写如下内容。
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="已导入的规则 1" stopProcessing="true">
- <match url="^(.*)$" ignoreCase="false" />
- <conditions logicalGrouping="MatchAll">
- <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
- <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
- </conditions>
- <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
- </rule>
- </rules>
- </rewrite>
- <defaultDocument>
- <files>
- <add value="index.php" />
- </files>
- </defaultDocument>
- </system.webServer>
- </configuration>
如果:tp5报错:Non-string needles will be interpreted as strings in the future
修改错误:.\extend\XBase\Column.php
$this->name = (strpos($name, 0x00) !== false ) ? substr($name, 0, strpos($name, 0x00)) : $name;改为:
$this->name = (strpos($name, chr(0x00)) !== false ) ? substr($name, 0, strpos($name, chr(0x00))) : $name;
整个流程走下来,tp5可以完美运行到服务器上。
到此这篇关于windows server 2019开启iis服务器+tp5.1的配置的文章就介绍到这了,更多相关windows server 2019开启iis内容请搜索w3xue以前的文章或继续浏览下面的相关文章希望大家以后多多支持w3xue!