次の方法で共有


Configuring PHP in Windows Azure Websites with .user.ini Files

I wrote a post a few weeks ago (Windows Azure Websites: A PHP Perspective) in which I suggested using the ini_set function to change PHP configuration settings in Windows Azure Websites. While that approach works, I briefly want to point out in this post that you can use a .user.ini file to configure PHP in Windows Azure Websites. If you are familiar with using .user.ini files, then you can just start using them. If you aren’t familiar with .user.ini files, the approach is detailed here: .user.ini files. Basically, you create a file called .user.ini that contains PHP configuration settings and put it in your root directory (or a subdirectory if you want the settings to only apply there). For example, let’s say I wanted to turn display_errors on and change the upload_max_filesize setting to 10 megabytes. Then the contents of my .user.ini file would simply be…

 display_errors = On
 upload_max_filesize = 10M

One “git push azure master”, and my custom PHP configuration settings are in effect for my site…almost. The one gotcha I ran into here that the frequency with which PHP reads .user.ini files is governed by the user_ini.cache_ttl setting, which is 300 seconds (5 minutes) by default. And, since this is a master setting in the php.ini file, you can’t change it. If, however, you want to see your changes in effect right away, you can simply stop and re-start your website.

One other thing worth noting here is that you cannot change PHP configuration settings that have mode PHP_INI_SYSTEM. To see a list of settings and their modes, see List of php.ini directives.

That’s it!

Thanks.

-Brian

Comments

  • Anonymous
    August 28, 2013
    Im not a Git person.  Can you explain how you were able to directly access the file system for the wordpress site, please? I don't see any ftp options. Thanks

  • Anonymous
    September 03, 2013
    Hi Chris, Git works by packaging up file changes from your local file system, pushing them to the remote web site, and then unpacking them to the file system there. So you would have a complete wordpress site locally, which you make changes to, then use Git to push the changes to the server. It only uploads a diff of the changes, so it doesn't even send complete files, only the changes to them. If you'd rather use FTP instead of Git to work with your web site, you can use the FTP or FTPS links listed on the dashboard for your web site in the Windows Azure portal. These should both be in the quick glance section, and provide direct access to the underlying file system on the server.

  • Anonymous
    November 21, 2013
    The comment has been removed

  • Anonymous
    November 27, 2013
    Mime Types are something that need to be configured at the Web Server level, this will require you to create a web.config file that is placed in your Web Site root. To configure a Mime Type you can follow the instructions listed in this article www.iis.net/.../mimemap.

  • Anonymous
    December 08, 2013
    Thanks for this. I used web matrix and adding this file to my wordpress on azure allowed me to upload my theme.