IIS10与Laravel10环境配置
本篇旨在记录iis配置laravel项目相关步骤
1. 如果未启用iis相关功能,自行开启相关功能,如图所示

2. 初始化laravel项目参考我另一篇文章,本篇作为其姊妹篇,用iis作为服务器处理php(另一篇是用nginx作为服务器,php-cgi处理php脚本)
参考链接 https://www.cnblogs.com/swtjavaspace/articles/17667674.html
其次,打开链接( https://www.iis.net/downloads/microsoft/url-rewrite )滚动到页面底部,下载并安装微软官方出品的urlrewrite模块,如图

3.对laravel项目的public文件夹的权限进行修改,参照下图(图截早了,懒得改了,结论:win10测试通过,仅为 IUSR 用户添加完全控制权限即可)

4. 添加网站,如图所示

5. 复制粘贴如下内容到laravel项目的public目录下的web.config文件(没有就自己新建,其中的 scriptProcessor 属性值中的路径改为自己php-cgi.exe 的路径 )
1 <?xml version="1.0" encoding="UTF-8"?> 2 <configuration> 3 <system.webServer> 4 <handlers> 5 <add name="php-cgi" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="D:\dev_tools\php\php-cgi.exe" resourceType="File" /> 6 </handlers> 7 <rewrite> 8 <rules> 9 <rule name="Main Rule" stopProcessing="true"> 10 <match url=".*" /> 11 <conditions logicalGrouping="MatchAll"> 12 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 13 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 14 </conditions> 15 <action type="Rewrite" url="index.php" /> 16 </rule> 17 </rules> 18 </rewrite> 19 <defaultDocument> 20 <files> 21 <add value="index.php" /> 22 </files> 23 </defaultDocument> 24 </system.webServer> 25 </configuration>
6.打完收工,做个小修改,在laravel项目下的routes文件夹下web.php末尾添加hello 映射,浏览一下,大功告成
1 Route::get('/hello', function () { 2 return response()->json(["msg"=>"hello,world!","code"=>200,"data"=>[]]); 3 });


浙公网安备 33010602011771号