【问题标题】:setting up laravel on IIS7在 IIS7 上设置 laravel
【发布时间】:2013-01-01 03:52:33
【问题描述】:

我想设置我的IIS7 服务器,以便让它与用laravel(php 框架)编写的网络应用程序一起工作。

我为CI (link) 找到了类似的东西

但它不适用于laravel(当然我删除了index.php 重定向)。

实际上只有主页有效(www.mysite.com/public

有人在 Laravel 中使用/d IIS7 吗?

提前致谢

【问题讨论】:

    标签: php mod-rewrite iis-7 virtualhost laravel


    【解决方案1】:

    我在<configuration></configuration> 的根文件夹中创建了web.config 文件:

    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <handlers accessPolicy="Read, Execute, Script" />
        <rewrite>
            <rules>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="public/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
    

    然后将公用文件夹的index.php文件复制到项目的根文件夹中,将../paths.php修改为paths.php,如this指南所说

    现在一切正常

    【讨论】:

      【解决方案2】:

      我使用下面的代码,重定向到index.php/{R:1} 而不是public/{R:1} 直接开箱即用,没有路径更改。

      <rewrite>
          <rules>
              <rule name="Imported Rule 2" stopProcessing="true">
                  <match url="^(.*)$" ignoreCase="false" />
                  <conditions logicalGrouping="MatchAll">
                      <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                  </conditions>
                  <action type="Rewrite" url="index.php/{R:1}" />
              </rule>
          </rules>
      </rewrite>
      

      【讨论】:

        【解决方案3】:

        检查 IIS 中的处理程序映射:

        1. 启动 IIS
        2. 点击您的网站
        3. 继续“处理程序映射”(在 IIS 块中)
        4. 搜索路径 PHP,名称 = PHPxx_via_FastCGI(xx = php 版本)
        5. 双击它,单击请求限制,然后单击选项卡“动词”,您可以在其中选择所有动词。这将解决它:-)

        【讨论】:

          【解决方案4】:

          这是我的工作文件,有两条规则:(网站指向公共文件夹)

          <?xml version="1.0" encoding="utf-8"?>
          <configuration>
            <system.webServer>
              <rewrite>
                <rules>
                  <rule name="RewriteRequestsToPublic">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    </conditions>
                    <action type="Rewrite" url="/{R:0}" />
                  </rule>
                  <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php/{R:1}" appendQueryString="true" />
                  </rule>
                </rules>
              </rewrite>
            </system.webServer>
          </configuration>
          

          【讨论】:

          • 谢谢!为我工作!另外,我必须将 index.php 移动到根路径。
          【解决方案5】:

          经过长时间的谷歌和测试后,它才开始工作。这是我的步骤:

          带有 IIS 8.5 的 laravel5

          1. 安装window platform installer
          2. 用window平台安装程序安装php-5.6
          3. 使用窗口平台安装程序为 IIS 安装 php-manager(可选)
          4. 安装Visual C++ Redistributable for Visual Studio 2012 (version x86)
            没有这个,FastCgi 进程会意外兴奋(php_info() 将不起作用)
          5. 安装composer.exe
          6. 导出作曲家供应商 bin 路径到路径
            set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
          7. 运行composer global require "laravel/installer=~1.1"
          8. 运行lavarel new app
          9. 在 IIS 中创建新应用程序并指向&lt;app&gt;/public

          就是这样,快乐的拉瓦雷尔!

          参考:http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/

          【讨论】:

            【解决方案6】:

            如果您希望能够检索您的 $_GET 变量,请不要使用:

            &lt;match url="^(.*)$" ignoreCase="false" /&gt;

            改为使用:

            &lt;match url="^" ignoreCase="false" /&gt;

            【讨论】:

              【解决方案7】:

              这是我修复它的方法。 打开配置文件,如果以下映射不存在,将这些行放在

                <rewrite>
                  <rules>
                    <rule name="Imported Rule 1" stopProcessing="true">
                      <match url="^(.*)/$" ignoreCase="false" />
                      <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                      </conditions>
                      <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
                    </rule>
                    <rule name="Imported 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>
              

              【讨论】:

                【解决方案8】:

                要在 Windows 上安装 IIS,请转到 control panel -&gt; uninstall programs 并按 Turn Off Windows Features On/Off 链接并单击 IIS 并选择 CGI 选项。

                从网上下载Web Platform Installerinstall PHP and SQL drivers for IIS

                从程序添加网站打开IIS。而公用文件夹指向 laravel/lumen 项目中的Public 文件夹。

                用于 Laravel 和 Lumen 项目。在任何可访问的文件夹中从 composer 创建项目。到文件夹结构中的public 文件夹并创建具有以下内容的web.config 文件我从laracasts 获得了这个

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

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 2012-10-19
                  • 1970-01-01
                  • 2017-12-17
                  • 2012-01-27
                  • 1970-01-01
                  • 2010-09-30
                  • 1970-01-01
                  • 1970-01-01
                  相关资源
                  最近更新 更多