Freigeben über


Migrate Yii Framework Application to Azure Web App

1. Create a PHP Empty Web App on Azure:

   

 

   

 

 

2. Copy the contents from Yii framework application root to wwwroot, e.g.

   

 

   Note: In this example, framework and application (assets, themes, index.php, etc.) are all in wwwroot.

 

3. Turn on error log, so that you can watch for errors in php_errors.log during migration:

    If log_errors is default to "Off", create a .user.ini file in wwwroot, add this line in .user.ini:

    log_errors=On

 

4. Modify database connection criteria from main.php (in this demo, it is protected/config/main.php), link to right database.

 

5. If you have hiding index.php implemented, configure it in web.config (create web.config file under wwwroot if it is not there), add rewriting rules. Here is sample web.config:

 

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

  <rewrite>

  <rules>

    <!--# otherwise forward it to index.php-->

    <rule name="Imported Rule 1">

      <match url="." ignoreCase="false" />

      <conditions>

        <!--# if a directory or a file exists, use it directly-->

        <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" />

    </rule>

  </rules>

  </rewrite>

  </system.webServer>

</configuration>

 

6. Check index.php, validate the paths for $yii and $config. If you included any php functions, validate file path as well.

    Test your site <your-site-name>.azurewebsites.net, it should point to site home page, e.g.

   

Comments

  • Anonymous
    March 18, 2016
    I tried to migrate a Yii2 web app to Azure. I was not able to change write permissions on public/web (for dynamic asset generation) and runtime, so the application is not able to start. I was told that on a Web App it is not possible to change directory permissions, so a Yii app cannot be effectively deployed as an Azure web app. ¿Is there a solution?
  • Anonymous
    August 27, 2016
    I would like this answer too.
  • Anonymous
    December 26, 2016
    Did you checked for mail. I have also setup a website from Apache server to azure and my emails are not working. Have you tried it.?
  • Anonymous
    February 23, 2017
    Any guides on plugging in Application Insights to Yii?