Swen De Bentzmann
Swen De Bentzmann

Reputation: 41

Error 500 when deploying Symfony 5 app on IIS

so I am currently facing a problem.

I am trying to deploy my symfony application on a Microsoft server.

I am therefore facing a error 500, see the screen

1

2

And the web.config file

<configuration>
<system.webServer>
<defaultDocument>
<files>
    <clear />
    <add value="index.php" />
</files>
</defaultDocument>
    <rewrite>
        <rules>
            <rule name="Rewriter" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions>
                    <add input="{R:1}" pattern="^(index\\.php|favicon\\.ico)" ignoreCase="false" negate="true" />
                    <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}" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

I did point my site to the public file.

The Anonymous authentication is enabled.

clear cache in dev and prod already done

It seems to find the page but can't access it or something. If anyone has any leads it might help, as I've been at it for 3 days. Thanks

EDIT 1 :

When I type this url

http://192.168.1.87:89/login

He recognises that he has to call her controller

[2021-08-06T12:49:37.795538+00:00] request.INFO: Matched route "login". {"route":"login","route_parameters":{"_route":"login","_controller":"App\Controller\DynamicConnectionController::index"},"request_uri":"http://192.168.1.87:89/login","method":"GET"} []

Maybe it's a problem with PHP not being properly configured?

Edit 2

Solution by samwu

Change activity time to 600 and restart server.

Didn't work

3

Edit 3 :

Finally, ichanged the web.config to

<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Rewriter" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="./index.php" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

And i made the change as suggested samwu, and know i have a new error, this time concerning Mysql.

PHP Warning: Uncaught PDOException: PDO::__construct(): Error while reading greeting packet. PID=12136 in C:\inetpub\wwwroot\lasernet\Symfony\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:39

And

Next PDOException: SQLSTATE[HY000] [2006] MySQL server has gone away in C:\inetpub\wwwroot\lasernet\Symfony\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:39

And

PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot\lasernet\Symfony\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 42

However my mysql database is well accessible, the database works correctly when I run the Symfony application locally.

Upvotes: 0

Views: 915

Answers (1)

samwu
samwu

Reputation: 5205

This problem should be caused by FastCGI timeout, try the following steps to solve the problem:

  1. Open iis manager.
  2. select a fast CGI setting feature.
  3. select your version php-cgi.exe and click on edit from the action pane.
  4. set the 600 activity time out value.

After doing all the changes, you need to restart iis server and try again.

Upvotes: 0

Related Questions