问题
I want to set up my IIS7
server in order to let it works with a web application written in laravel
(php framework).
I found something similar for CI
(link)
but it doesn't work on laravel
(of course I removed the index.php
redirection).
actually only home page works (www.mysite.com/public
)
anybody uses/d IIS7
with Laravel?
thanks in advance
回答1:
I created the web.config
file in root folder inside <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 this guide says
now everything works perfectly
回答2:
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.
<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:
Check your Handler Mappings in 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 :-)
回答4:
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>
回答5:
Just got it working after long hours of google and testing. Here is my steps:
laravel5 with 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
That's it, Happy Lavarel!
Reference: http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/
回答6:
If you want to be able to retrieve your $_GET variables do not use:
<match url="^(.*)$" ignoreCase="false" />
Instead use:
<match url="^" ignoreCase="false" />
回答7:
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>
回答8:
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.
Download Web Platform Installer
from internet 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.
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
<?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>
来源:https://stackoverflow.com/questions/14381950/setting-up-laravel-on-iis7