使用IIS 10设置laravel 5.4

And*_*ers 2 iis laravel

我想在运行于Windows Server 2016的IIS 10上部署laravel项目。最简单且仍安全的方法是什么?

And*_*ers 5

我就是这样做的,我不确定这是正确的方法。

  • 安装URL重写模块(https://www.iis.net/downloads/microsoft/url-rewrite
  • 将仓库放入某个文件夹E:/ sites / helloworld
  • 在IIS中,添加一个名为“ helloworld”的虚拟目录,该目录指向E:/ sites / helloworld / public
  • 确保文件夹引导程序/缓存和存储已打开以进行写入。
  • 不要忘记制作环境文件。
  • 在您的web.php路由文件中:

    Route :: get('/',function(){return view('welcome');});

    Route :: get('/ also',function(){return view('welcome');});

在公共目录中添加文件web.config并粘贴以下规则:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
        <rules>
            <rule name="Rule 1" stopProcessing="true">
            <match url="^(.*)/$" ignoreCase="false" />
            <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
            </rule>
            <rule name="Rule 2" stopProcessing="true">
            <match url="^" ignoreCase="false" />
            <conditions>
                <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" />
            </rule>
        </rules>
        </rewrite>
    </system.webServer>
</configuration> 
Run Code Online (Sandbox Code Playgroud)

现在,您应该能够访问两个URL,这意味着laravel路由可以按预期工作。如果您尝试其他不存在的路线,您将获得幼虫。