使用IIS 10设置laravel 5.4 [英] Setup laravel 5.4 with IIS 10

查看:143
本文介绍了使用IIS 10设置laravel 5.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to deploy laravel projects on our IIS 10, running on windows server 2016. What is the easiest and still secure way to do that?

推荐答案

这就是我的做法;我不确定这是正确的方法.

This is how I did it; I'm not sure it is the right way.

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

  • Install URL Rewrite module (https://www.iis.net/downloads/microsoft/url-rewrite)
  • Put repo in some folder E:/sites/helloworld
  • In IIS add a virtual directory called "helloworld" pointing to E:/sites/helloworld/public
  • Make sure folders bootstrap/cache and storage is open for writing.
  • Dont forget to make env file.
  • In your web.php route file put:

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

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

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

Add the file web.config in public dir and paste the rules:

<?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> 

您现在应该可以访问两个URL,这意味着laravel路由可以正常工作.如果您尝试其他不存在的路由,则会收到laravel异常.

You should now be able to access both URLs meaning laravel routing works as intended. If you try another non-existent route you will get a laravel exception.

这篇关于使用IIS 10设置laravel 5.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆