We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon on IIS - Working Contribution Solution

I recently wrote a solution for IIS because I know some users still program via Windows (This is better with new VS Code). For some XAMPP and WAMPP older machines, they become too slow, making them rely on internal solutions like IIS. I think this topic solves the person who needs it via IIS, in fact I think this code should be part of the Phalcon Dev build (i don't know how to do it) and it would be interesting to be part of Phalcon's Doc as IIS and Phalcon configuration, after installing phalcon.dll within PHP installed by Webmatrix or by WebPlataformInstaller.

The solution is simple. Installs on IIS machine (works from 6.5 and up). Along with IIS, it installs the desired database and PHP for IIS (whatever version that works with phalcon). The secret for this solution to work is to have URL Rewriter 2.0 installed, this is MANDATORY.

Manually download the phalcon DLL for your version of PHP and put it inside the PHP ext folder that is inside program files, depending on the version installed, it may be in the x86 folder or in the x64 folder. Running in cmd "php -v" helps identify the version and folder, or a file with phpinfo (); code.

Now is the solution: 1 - Create within the root folder of your project the web.config file as following code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="YourSite Static" stopProcessing="true">
                    <match url="([\S]+[.](ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf))" ignoreCase="true" />
                    <action type="Rewrite" url="public/{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="YourSite Rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUESTFILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUESTFILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="public/index.php?_url=/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

2 - Create inside the / public / folder of your project another web.config with the code:

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

Ready. Now it works within IIS quietly.



9.7k

XAMPP and WAMPP often create more problems than a straight installation of Apache, MySQL, and PHP. If a Windows user wants to use IIS because WAMPP does not work, I would first suggest removing WAMPP.

Working with IIS might be of use for companies locked into the Microsoft cloud.

edited Sep '17

Nice work, but I strongly believe virtualization is the way to go.

Full fledged GNU/Linux as dev environment = production and avoids nasty issues we see all the time here on the forums and on GitHub.

edited Sep '17

IIS and MSSQL is actually really fast. I had to do some contract work for a company whoes API ran on 1 server using IIS and their central database was MSSQL. They were getting about 500k hits on the api per hour and the database was handling all those requests with no caching and it was handling other requests from payments, their main website, helpdesk and forums.

I was surprised at how versitile IIS is. but IIS PHP modules are are far out of date. this was 2 years ago and they only provided 5.3. But i figured out how to manually install newer php into IIS.



9.7k

@Jake, Microsoft applications tend to have better defaults than what you see in MySQL, InnoDB, and Web hosting companies. MySQL used to have defaults set for a Pentium 0.5 from 1932. MSSQL and IIS had defaults closer to a real server. Microsoft products, out of the box, tend to be better than many Linux distributions and anything from Oracle.

When you start to tune, Microsoft experts are far cheaper than Oracle experts but not a lot better. A difficult to fix problem cannot be diagnosed by looking at the source code. I reported one problem and a solution to Microsoft. The same problem reappeared in every release. The third time I tried to report the problem and the fix, Microsoft wanted to charge me for "helping" me. Never again.

edited Jun '20

@Skymidt It works perfectly with IIS 10, thank you very much! Out of curiosity: have you tried Phalcon on Nano Server?