在 IIS7 上设置 Laravel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14381950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
setting up laravel on IIS7
提问by Dario Rusignuolo
I want to set up my IIS7
server in order to let it works with a web application written in laravel
(php framework).
我想设置我的IIS7
服务器,以便让它与用laravel
(php 框架)编写的 Web 应用程序一起工作。
I found something similar for CI
(link)
我发现了类似的东西CI
(链接)
but it doesn't work on laravel
(of course I removed the index.php
redirection).
但它不起作用laravel
(当然我删除了index.php
重定向)。
actually only home page works (www.mysite.com/public
)
实际上只有主页有效 ( www.mysite.com/public
)
anybody uses/d IIS7
with Laravel?
有人IIS7
在 Laravel 上使用/d吗?
thanks in advance
提前致谢
回答by Dario Rusignuolo
I created the web.config
file in root folder inside <configuration></configuration>
:
我web.config
在根文件夹中创建了文件<configuration></configuration>
:
<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>
then copy the index.php
file of the public folder into the root folder of the project modifying the ../paths.php
into paths.php
as thisguide says
然后复制index.php
公用文件夹的文件到项目修改的根文件夹../paths.php
到paths.php
为这个指南说
now everything works perfectly
现在一切正常
回答by Danny Rowlands
I used the code below, redirect to index.php/{R:1}
rather than public/{R:1}
Works straight out of the box then with no path changes.
我使用了下面的代码,重定向到 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>
回答by Juan Antonio Tubío
Here is my working file, with two rules: (web site is pointing to public folder)
这是我的工作文件,有两个规则:(网站指向公共文件夹)
<?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>
回答by ken
Just got it working after long hours of google and testing. Here is my steps:
经过长时间的谷歌和测试,它才开始工作。这是我的步骤:
laravel5 with IIS 8.5
laravel5 与 IIS 8.5
- install window platform installer
- install php-5.6 with window platform installer
- install php-manager for IIS with window platform installer (optional)
- install Visual C++ Redistributable for Visual Studio 2012 (version x86)
Without this, FastCgi process excited unexpected (php_info() will not works) - install composer.exe
- export composer vendor bin path to path
set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
- run
composer global require "laravel/installer=~1.1"
- run
lavarel new app
- create new application in IIS and point to
<app>/public
- 安装窗口平台安装程序
- 使用窗口平台安装程序安装 php-5.6
- 使用窗口平台安装程序为 IIS 安装 php-manager(可选)
- 安装Visual C++ Redistributable for Visual Studio 2012 (version x86)
如果没有这个,FastCgi 进程会被意外激发(php_info() 将无法工作) - 安装composer.exe
- 导出作曲家供应商 bin 路径到路径
set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
- 跑
composer global require "laravel/installer=~1.1"
- 跑
lavarel new app
- 在 IIS 中创建新应用程序并指向
<app>/public
That's it, Happy Lavarel!
就是这样,快乐的拉瓦雷尔!
Reference: http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/
参考:http: //alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/
回答by bert
Check your Handler Mappings in IIS:
在 IIS 中检查您的处理程序映射:
- launch IIS
- click on your site
- go on 'handler mappings' (in IIS block)
- Search for Path PHP, Name = PHPxx_via_FastCGI (xx = php version)
- Double click it, click on request restrictions and click on tab 'Verb's where you choose All verbs. This will fix it :-)
- 启动 IIS
- 点击你的网站
- 继续“处理程序映射”(在 IIS 块中)
- 搜索路径 PHP,名称 = PHPxx_via_FastCGI(xx = php 版本)
- 双击它,单击请求限制,然后单击您选择所有动词的“动词”选项卡。这将解决它:-)
回答by gabrielgeo
If you want to be able to retrieve your $_GET variables do not use:
如果您希望能够检索您的 $_GET 变量,请不要使用:
<match url="^(.*)$" ignoreCase="false" />
<match url="^(.*)$" ignoreCase="false" />
Instead use:
而是使用:
<match url="^" ignoreCase="false" />
<match url="^" ignoreCase="false" />
回答by Gomes
Here is how I fixed it. open the config file, if the following mapping not exists, put these lines under
这是我修复它的方法。打开配置文件,如果下面的映射不存在,把这些行放在
<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>
回答by Sunil Kumar
To install IIS
on your windows, goto control panel -> uninstall programs
and press Turn Off Windows Features On/Off
link and click IIS
and select CGI
option.
要IIS
在您的 Windows 上安装,请转到control panel -> uninstall programs
并按Turn Off Windows Features On/Off
链接并单击IIS
并选择CGI
选项。
Download Web Platform Installer
from internet install PHP and SQL drivers for IIS
Web Platform Installer
从网上下载install PHP and SQL drivers for IIS
Open IIS
from programs add Website. and for public folder point point to Public
folder in the laravel/lumen project.
IIS
从程序打开添加网站。和公共文件夹点指向Public
laravel/lumen 项目中的文件夹。
for Laravel and Lumen projects. Create project from composer in any accessible folder. got to public
folder in the folder structure and create web.config
file with below contents i obtained this from laracasts
用于 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>