PHP Archives - RuslanY Blog Azure App Service Features and Best Practices Sat, 01 Jun 2019 22:21:50 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.16 https://ruslany.net/wp-content/uploads/2019/05/cropped-web-32x32.png PHP Archives - RuslanY Blog 32 32 How to warm up Azure Web App during deployment slots swap https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/ https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/#comments Wed, 30 Sep 2015 16:23:04 +0000 https://ruslanynet.azurewebsites.net/2015/09/30/how-to-warm-up-azure-web-app-during-deployment-slots-swap/ Azure Web App deployment slots are used to help roll out new versions of an app without downtime or cold start activation. New version is typically deployed to a staging slot, then after testing and final verification it gets swapped into a production slot. During the swap operation the Web App’s worker process may get … Continue reading "How to warm up Azure Web App during deployment slots swap"

The post How to warm up Azure Web App during deployment slots swap appeared first on RuslanY Blog.

]]>
Azure Web App deployment slots are used to help roll out new versions of an app without downtime or cold start activation. New version is typically deployed to a staging slot, then after testing and final verification it gets swapped into a production slot. During the swap operation the Web App’s worker process may get restarted in order for some settings to take effect. Even though the swap does not proceed until the restarted worker process comes back online on every VM instance, it may still not be enough for application to be completely ready to take on production traffic. This post explains how you can use the recently enabled Application Initialization Module to completely warm up your application prior to swapping it into production.

First of all it is necessary to explain the sequence of actions that happens when a staging slot is swapped into production. When the Swap button is clicked in Azure Portal or a corresponding management API is called:

  1. The App Settings and Connection Strings that are marked as “Slot” are read from the Production slot and applied to the site in the Staging slot. That causes the site’s worker process to be restarted for those changes to take effect and become visible as process environment variables;
  2. Then the site in the staging slot gets warmed up. To warm up the site an HTTP request is made to the root directory of the site to every VM instance where site is supposed to run. The warm up request has a User-Agent header set to “SiteWarmup”;
  3. After warm up has completed the host names for the sites in production and staging slots get swapped. Now the site that has been warmed up in the staging slot starts getting production traffic and the site that used to be in the production slot is now in the staging slot
  4. The site that is now in the staging slot gets updated with the App Settings and Connection Strings associated with the staging slot. That causes restart of that site, but it is not in production slot any more so restart is harmless.

Sometimes hitting the site’s root URL is not enough to completely warm up the application. For example it maybe necessary to hit all important routes in an ASP.NET MVC app or to pre-populate the in-memory cache. That is where the Application Initialization Module can help.

Let’s use a simple example to demonstrate how a Web App can be warmed up in the deployment slot during the swap operation. First let’s create a site and a staging deployment slot:

Next let’s set some slot settings on the App and its staging slot. These slot settings will cause the App’s worker process to restart during swap.

For the actual app code I used two simple PHP files: index.php and warmup-cache.php. The index.php is served when site’s root URL is requested. The warmup-cache.php is my “cache warmup” code that takes long time to run (emulated by sleep() command). In real application that can be the script that makes database queries to fill up the cache.

Finally I also have a web.config file which configures AppInit module:

<system.webServer>
  <applicationInitialization >
    <add initializationPage="/warmup-cache.php" hostName="appinit-warmup.azurewebsites.net"/>
  </applicationInitialization>
<system.webServer>

In the applicationInitialization section I can specify multiple URL paths that need to be requested in order to warm up my application. In my case I only need to hit one URL. Also notice that I can specify the host name to use for the warm up requests (this is optional and if not specified the “localhost” will be used as a host name).

The following steps are just for verification/debugging purposes. There is no need to perform them when using AppInit module. In fact enabling them for your production site may considerably slow it down.

To confirm that the warmup-cache.php is actually requested during the swap I will use Failed Request Tracing. It can be enabled from Azure Portal:

However, that will trace only failed requests. I need it to trace all requests. For that I add the following section to the web.config file:

<tracing>
  <traceFailedRequests>
    <clear/>
    <add path="*">
      <traceAreas>
      <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,Rewrite,iisnode" verbosity="Verbose" />
      </traceAreas>
      <failureDefinitions statusCodes="200-600" />
    </add>
  </traceFailedRequests>
</tracing>

The important attribute here is statusCodes which specifies that requests with status codes between 200 and 600 should be logged.

Now let’s run the swap command.

During the swap operation the application is restarted and the first warm up request is made to the root directory of the web app. That starts the AppInit module which makes a request to warmup-cache.php URL and waits until it completes. Only after that request competes the swap operation proceeds to the next step and swaps the host names so that the warmed up site starts getting production traffic. Because of that the swap operation takes longer time to complete.

After the swap completed we can analyze the Request Tracing logs to confirm that the warmup-cache.php URL has been hit prior to the swap. Note that we need to get those log files from the site in the production slot now.

Looking through the logs we can see the following:

  • The first warm up request is made to the web site. Notice the user agent value set to “SiteWarmup”:
  • Another log file shows that the appInit module has started and made an HTTP request to the warmup-cache.php around the same time. That request has the host name I specified in the web.config file. Also the user-agent is different.

    As expected that request took around 30 seconds.

That simple example demonstrates how to use IIS Application Initialization Module with Azure Web App deployment slots to ensure that the application in the slot is completely warmed up.

The post How to warm up Azure Web App during deployment slots swap appeared first on RuslanY Blog.

]]>
https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/feed/ 42
Azure Web Sites – Continuous Deployment with Staged Publishing https://ruslany.net/2014/03/azure-web-sites-continuous-deployment-with-staged-publishing/ https://ruslany.net/2014/03/azure-web-sites-continuous-deployment-with-staged-publishing/#comments Thu, 27 Mar 2014 21:04:08 +0000 http://ruslany.net/?p=12051 In the beginning of the year Windows Azure Web Sites team has released a preview of the Staged Publishing functionality. The Staged Publishing allows you to create a staging site slot where you can publish a new version of the website and then test it before swapping to the production environment. This feature together with Continuous … Continue reading "Azure Web Sites – Continuous Deployment with Staged Publishing"

The post Azure Web Sites – Continuous Deployment with Staged Publishing appeared first on RuslanY Blog.

]]>
In the beginning of the year Windows Azure Web Sites team has released a preview of the Staged Publishing functionality. The Staged Publishing allows you to create a staging site slot where you can publish a new version of the website and then test it before swapping to the production environment. This feature together with Continuous Deployment via GitHub, BitBucket or DropBox enables some very powerful deployment scenarios.

However the preview release did not provide the optimal experience for enabling Continuous Deployment (CD) for staging site. User had to configure a non-trivial workaround as described in blog post by Rick Rainey. Recently the Azure Web Sites team has released an update that fixes that problem and makes the setup of the CD with staged publishing very simple. This blog post describes how to enable CD from git repository located on BitBucket.

First, in order to use staged publishing you need to scale your web site to Standard mode:

After that you will be able to enable staged publishing:

When staged publishing is enabled you will see the staging site slot in portal.

Select it and then click on “Set up deployment from source control”:

In my case I created a repository on BitBucket where I have one simple php page just for demo purposes:

The repository gets synchronized with the staging site slot and then when I browse to it I get the result of executing the PHP script that was checked in to my repository.

The script detects whether it runs in production or staging slot by checking the Host header of the request:

<html>
<head>
<title>My first PHP page</title>
</head>
<body>
<?php
echo "<h1>Hello World! This is a new version!</h1>";

$host = $_SERVER['HTTP_HOST'];
$is_production = TRUE;
if (strpos($host, 'staging') !== FALSE)
{
$is_production = FALSE;
}

if ($is_production === TRUE)
{
echo "<h2>This code is running in production.</h2>";
}
else
{
echo "<h2>This code is running in staging.</h2>";
}
?>
</body>
</html>

Now that I have tested the script in staging environment I can swap it to production environment.

After that when I browse to the production site I get the expected result:

Now let’s assume that I want to deploy a new version of my script. I make a change in the script, check it in and push it to the BitBucket repository. After that I go back to the deployment history of my staging site and do a sync operation. That pulls my recent changes into the staging slot:

Now I can test how it works by browsing to the staging site:

Note that the production site at ruslanycd.azurewebsites.net is not affected while I am testing and debugging my staging site. Once I am done with verification I do the swap operation again and the latest change is now live in the production site:

The post Azure Web Sites – Continuous Deployment with Staged Publishing appeared first on RuslanY Blog.

]]>
https://ruslany.net/2014/03/azure-web-sites-continuous-deployment-with-staged-publishing/feed/ 1
PHP 5.5, WinCache 1.3.5 available in Azure Web Sites https://ruslany.net/2013/12/php-5-5-wincache-1-3-5-available-in-azure-web-sites/ https://ruslany.net/2013/12/php-5-5-wincache-1-3-5-available-in-azure-web-sites/#comments Wed, 11 Dec 2013 23:11:16 +0000 http://ruslany.net/?p=6713 The recent upgrade of Windows Azure Web Sites includes several PHP related improvements: First, the PHP 5.5 is now available. The PHP 5.4 becomes the default version used for newly created sites. Note that there is no SQL Server Extension support for PHP 5.5. Second, the latest version (1.3.5) of WinCache Extension for PHP  is used … Continue reading "PHP 5.5, WinCache 1.3.5 available in Azure Web Sites"

The post PHP 5.5, WinCache 1.3.5 available in Azure Web Sites appeared first on RuslanY Blog.

]]>
The recent upgrade of Windows Azure Web Sites includes several PHP related improvements:

First, the PHP 5.5 is now available. The PHP 5.4 becomes the default version used for newly created sites.

Note that there is no SQL Server Extension support for PHP 5.5.

Second, the latest version (1.3.5) of WinCache Extension for PHP  is used with all PHP versions available in Azure Web Sites (5.3, 5.4, 5.5). Note that with PHP 5.5 the WinCache extension relies on the the Zend Opcode cache and hence it has its own opcode cache disabled. This can be seen in the phpinfo() output:

All other cache types in WinCache Extension are still enabled (file cache, session cache, user cache).

The post PHP 5.5, WinCache 1.3.5 available in Azure Web Sites appeared first on RuslanY Blog.

]]>
https://ruslany.net/2013/12/php-5-5-wincache-1-3-5-available-in-azure-web-sites/feed/ 2
Azure Web Sites – WordPress plugin update bug fixed https://ruslany.net/2013/03/azure-web-sites-wordpress-plugin-update-bug-fixed/ https://ruslany.net/2013/03/azure-web-sites-wordpress-plugin-update-bug-fixed/#comments Wed, 20 Mar 2013 18:02:06 +0000 http://ruslany.net/?p=3021 Windows Azure Web Sites has recently been upgraded to a new version. Among all the improvements and bug fixes in the new version there is one change that fixes a known issue with update of WordPress plugins. There have been numerous questions about this problem at the Azure Web Sites forum. After the service upgrade the Windows … Continue reading "Azure Web Sites – WordPress plugin update bug fixed"

The post Azure Web Sites – WordPress plugin update bug fixed appeared first on RuslanY Blog.

]]>
Windows Azure Web Sites has recently been upgraded to a new version. Among all the improvements and bug fixes in the new version there is one change that fixes a known issue with update of WordPress plugins. There have been numerous questions about this problem at the Azure Web Sites forum.

After the service upgrade the Windows Azure Web Sites now uses a newer version of WinCache – 1.3.4. This version has a fix for for the plugin update problem. I tried it and was able to update all of plugins on my site without a problem:

Plugin Upgrade Works

Other PHP related changes in this release of WAWS include newer PHP version (5.3.19) and support for UTF-8 encoding for server variables REQUEST_URI and PATH_INFO.

The post Azure Web Sites – WordPress plugin update bug fixed appeared first on RuslanY Blog.

]]>
https://ruslany.net/2013/03/azure-web-sites-wordpress-plugin-update-bug-fixed/feed/ 5
PHP Troubleshooting in Windows Azure Web Sites https://ruslany.net/2013/01/php-troubleshooting-in-windows-azure-web-sites/ https://ruslany.net/2013/01/php-troubleshooting-in-windows-azure-web-sites/#comments Wed, 30 Jan 2013 19:26:09 +0000 http://ruslany.net/?p=2381 The need to diagnose and troubleshoot application’s failures often comes up during deployment to a hosting environment. Some configuration settings in hosting server may differ from what application expects. Often it is not as easy to figure out the cause of the problem in a hosting environment as it is on a development machine.  I found the following techniques useful when … Continue reading "PHP Troubleshooting in Windows Azure Web Sites"

The post PHP Troubleshooting in Windows Azure Web Sites appeared first on RuslanY Blog.

]]>
The need to diagnose and troubleshoot application’s failures often comes up during deployment to a hosting environment. Some configuration settings in hosting server may differ from what application expects. Often it is not as easy to figure out the cause of the problem in a hosting environment as it is on a development machine.  I found the following techniques useful when troubleshooting errors in PHP applications hosted in Windows Azure Web Sites.

1. phpinfo()

This is the most obvious, but very often the most helpful diagnostics tool. The output of this function provides a lot of information about the PHP runtime. Use it to determine what PHP extensions are enabled, what are the PHP configuration settings and what values are stored in server environment variables.

To use the phpinfo() function create a new php file that contains just one line:

<!--?php phpinfo(); ?-->

Name this file with some non-obvious name (don’t name it phpinfo.php) and upload it to the root directory of your site. Request this file from a web browser and analyze the output.

The output from phpinfo may expose security sensitive information! Always delete this file from the site’s root directory after you are done with it.

2. wincache.php

WinCache extension is by default enabled for PHP web sites. To check how opcode and user cache work and what is the current content of the cache use wincache.php script that can be downloaded from the wincache source code repository. Get the script and the edit it by specifying the user name and password that will be used to protect the access.

/**  * ======================== CONFIGURATION SETTINGS ==============================
* If you do not want to use authentication for this page, set USE_AUTHENTICATION to 0.
* If you use authentication then replace the default password.
*/
define('USE_AUTHENTICATION', 1);
define('USERNAME', 'someusername');
define('PASSWORD', 'somepassword');

After that upload it to the root directory of a website and request this page from a web browser. The output will look similar to below:

Always protect the wincache.phpscript by using the built-in authentication or other authentication mechanisms. Leaving this script unprotected may compromise the security of your web application.

3. PHP Error Log

PHP runtime in Windows Azure is configured to save application errors into a log file located in the /LogFiles directory under FTP root of a site.

If application does not work or returns a blank page – check this file as it may contain the details of an error. I also check this file from time to time for my live sites to make sure the site is running properly.

It is also possible to overwrite the default location of the error log file. For that create a file called .user.ini and add the following line to it:

error_log=D:\Home\site\wwwroot\php_errors.log

Upload this file to the root directory (wwwroot) of your web site.

4. PHP display_errors

PHP runtime directive display_errors is used to output the errors in the HTTP response. For production deployments it should be set to “Off” in order to not show error details to web site visitors. For development and debugging purposes you can temporary set it to On by using .user.ini file:

display_errors=On
html_errors=On
error_reporting = E_ALL

When application has an error it will be output in the web browser.

I usually turn display_errors off as soon as I got all the necessary information from the error output.

5. HTTP logs, Detailed Error Messages, Failed Request Tracing

By default HTTP logging, detailed error messages and failed request tracing are turned off for a site. To turn them on use the CONFIGURE page in Windows Azure Portal:

Once enabled the log files will appear in the following directories under site’s FTP root:

  •  HTTP log files will appear in the /LogFiles/http/RawLogs;
  • Detailed errors will appear in the /LogFiles/DetailedErrors;
  • Failed Request Tracing logs will be in /LogFiles/W3SVC#########/;

6. XDebug PHP Extension

Xdebug is a very popular PHP extension that helps with debugging and profiling of PHP scripts by providing a lot of valuable debug information. To enable Xdebug for a site in Windows Azure download the appropriate build of Xdebug extension from downloads page. If your site uses PHP 5.3 then download “5.3 VC9 (32 bit)”. If your site uses PHP 5.4 then download “5.4 VC9 (32 bit)”. Use 32 bit build even if your Windows OS is 64 bit. Do not use thread safe (TS) builds.

Upload the php_xdebug_####.dll file to /site/wwwroot/bin directory. If bin directory does not exist then create it. After that use the CONFIGURE tab in Windows Azure Portal to enable xdebug extension:

With xdebug enabled you will be getting more detailed error messages and call stack:

7. ClearDB stats

ClearDB service that provides MySQL database hosting is now integrated into the Windows Azure Portal. It is now possible to buy and manage your MySql databases from the portal. Also the billing is integrated, meaning that ClearDB charges will be billed on Azure subscription.

To access ClearDB management page use the ADD-ONS tab.

From there you can open the ClearDB query performance page as well as access other database management information

I wonder why the query performance chart shows such a light load on my database. I guess this maybe because of a wincache user cache which loads all the blog content in memory so there are very few or none database access operations.

The post PHP Troubleshooting in Windows Azure Web Sites appeared first on RuslanY Blog.

]]>
https://ruslany.net/2013/01/php-troubleshooting-in-windows-azure-web-sites/feed/ 5
phpMyAdmin on Windows Azure Web Sites https://ruslany.net/2012/12/phpmyadmin-on-windows-azure-web-sites/ https://ruslany.net/2012/12/phpmyadmin-on-windows-azure-web-sites/#comments Mon, 17 Dec 2012 17:48:47 +0000 http://ruslany.net/?p=1791 In my previous post about the migration of a WordPress site to Windows Azure I mentioned that I used phpMyAdmin to import existing blog data into a MySql/ClearDb database in Windows Azure. phpMyAdmin is a web based tool for administering MySql databases. It can be used to create tables, edit the data in tables, export/import/backup data and … Continue reading "phpMyAdmin on Windows Azure Web Sites"

The post phpMyAdmin on Windows Azure Web Sites appeared first on RuslanY Blog.

]]>
In my previous post about the migration of a WordPress site to Windows Azure I mentioned that I used phpMyAdmin to import existing blog data into a MySql/ClearDb database in Windows Azure. phpMyAdmin is a web based tool for administering MySql databases. It can be used to create tables, edit the data in tables, export/import/backup data and many other tasks. I found it to be an adequate tool for all MySql db administration needs in Windows Azure. This post describes how to install and configure phpMyAdmin on Windows Azure Web Sites.

1. Create an empty site

First you’ll need to create a new site in Windows Azure. 10 free sites are allowed per subscription and phpMyAdmin will work fine on a free site. Create an empty site using “Quick Create” option in Windows Azure Portal:

2. Link the site with a MySql database

If you already have a MySql database or need to create one then use the Linked Resources page to link that database with your site.

Once the database is linked get the connection string by using the “View conneciton strings” link on the site’s dashboard page:

You will need the information from this connection string to logon to the database via phpMyAdmin. It will looks similar to this:

Database=some-db-name;Data Source=some-hostname;User Id=some-username;Password=some-password

3. Download and configure phpMyAdmin

Get the latest version of phpMyAdmin from the offical site. Extract it to some temporary location on your hard drive. Create a new file with name config.inc.php in the same directory where examples, js, libraries, setup and themes directories are. Paste the following into that file:

<!--?php
$cfg['blowfish_secret'] = 'some_string';  // use here a value of your choice
$i = 0;
/* First server */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'some-hostname';  // Replace with value from connection string
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
?-->

5. Upload phpMyAdmin files to Windows Azure

Multiple upload methods are supported. I used FTP with FileZilla. FTP hostname and username can be obtained from the site’s dashboard page in management portal. Once you connected via FTP, upload all the files into the /site/wwwroot/ directory.

6. Logon to MySql database

Browse to the newly created site. You should see the phpMyAdmin logon page:

Use the User Id and Password from the connection string to logon.

The post phpMyAdmin on Windows Azure Web Sites appeared first on RuslanY Blog.

]]>
https://ruslany.net/2012/12/phpmyadmin-on-windows-azure-web-sites/feed/ 23
RuslanY.net running on Windows Azure Web Sites https://ruslany.net/2012/10/ruslany-net-running-on-windows-azure-web-sites/ https://ruslany.net/2012/10/ruslany-net-running-on-windows-azure-web-sites/#comments Mon, 22 Oct 2012 15:30:36 +0000 http://ruslany.net/?p=1401 I have not been writing any blog posts for a while. That was because for the past two years I have been busy working in a team that develops the Windows Azure Web Sites – a scalable web hosting platform in Windows Azure. Now that the Windows Azure Web Sites (WAWS) is publicly available I … Continue reading "RuslanY.net running on Windows Azure Web Sites"

The post RuslanY.net running on Windows Azure Web Sites appeared first on RuslanY Blog.

]]>
I have not been writing any blog posts for a while. That was because for the past two years I have been busy working in a team that develops the Windows Azure Web Sites – a scalable web hosting platform in Windows Azure.

Now that the Windows Azure Web Sites (WAWS) is publicly available I decided to try to move my site from private hosting  to Windows Azure. My site uses WordPress (with MySql database), PHP 5.3, WinCache object and user cache, URL rewriting and many WordPress plugins. With all these different technologies (many of which are not developed by Microsoft), I thought it would be a good test of how WAWS is capable of running web sites that use open source technologies. Plus I expect that my site will be more reliable and available, comparing to my previous private hosting.

I was pleasantly surprised that the migration from private hosting to WAWS hosting was relatively quick and simple. The site has been running successfully in a Shared compute mode for a while now and none of the site’s functionality has been lost or altered. In this post I’ll explain the steps I took to move my site to WAWS hosting. Hopefully it will be useful to those who are planning to migrate their WordPress based site to WAWS.

1. Signing up and creating an empty site

The sign up process is straightforward and quick. If you have not signed up before then you can get a 90-days free trial, where you can try all the WAWS hosting options for free. Once you complete the sign up process you will end up at the Windows Azure Management Portal and start creating sites. In my case I started by creating an empty free web site http://ruslany.azurewebsites.net. It takes only a few seconds to create a new site.

2. Creating a MySql database

WAWS works in partnership with ClearDb to provide MySql databases. If you have a relatively small web application with light traffic then the free MySql database provided in Windows Azure should be enough for you. You can create the database by going to the Linked Resources page  and adding a new Linked Resource:

Create MySql DB

My site’s database was bigger than 20 Mb in size, so I had to purchase the Venus Service Plan on the ClearDB site.

3. Importing data to a MySql database

WAWS provides a web management interface for SQL Azure databases. But not for MySql databases. That was not a problem however, because there is a well known web application for administering MySql – phpMyAdmin. To import the content of my blog I created a new site under my subscription (10 free sites are allowed per subscription) and installed phpMyAdmin there. phpMyAdmin provides a simple way of importing MySql content into a database:

Import Db Data

Unfortunately, phpMyAdmin is not yet available in the Windows Azure Web Application Gallery, so I had to install it manually by following the quick install guide.

Important thing to note about importing data using phpMyAdmin. Import requires uploading a sql file to the server. If the sql file is big, you may run into the PHP limit for maximum allowed size of uploaded file. It is possible to increase the limit by following instructions at Configuring PHP in Windows Azure Websites with .user.ini Files.

4. Point WordPress to new database

Once database import is complete, it is necessary to reconfigure WordPress to use new database. The configuration is stored in wp-config.php file. Change the DB_NAME, DB_USER, DB_PASSWORD, DB_HOST variables to the values provided by ClearDB.

5. Uploading the site content

There are several ways to publish content in WAWS:

  1. FTP
  2. WebDeploy
  3. Git
  4. TFS

In order to simplify publishing, I recommend to set the publishing password to something you can remember. Otherwise you’ll have to use the randomly generated password that WAWS provided for your site.

Reset Publishing Password

FTP was good enough for my needs. The FTP host name and user name are available in the site dashboard page. You can use any FTP client. Filezilla works pretty well for uploading large content.

5. Configuring custom domains

After I uploaded content I just browsed to http://ruslany.azurewebsites.com/ and the site was up and running. Obviously I did not want to use this domain for my site, so the next step was to associate http://ruslany.net/ with this site.

Free sites in WAWS are not allowed to have custom domains, so I had to upgrade my site to “Shared” compute mode.  Apart from custom domains support, there are other benefits of this mode: less restrictive usage quotas and no outgoing bandwidth limit.

Configuring custom domain is a straightforward process described in Windows Azure documentation. It is a good idea to associate both A record and the WWW CName with a site. In my case for example both http://ruslany.net and http://www.ruslany.net/ are associated with the site:

Custom Domains

Conclusion

There are a couple of minor limitations that still need to be fixed in WAWS:

  • An old version of Wincache extension is used which causes failures when upgrading plugins.
  • It would be nice to have phpMyAdmin available in the Web Application Gallery.

Other than that I am pretty happy with how my site is running in Windows Azure Web Sites so far. WAWS is capable and flexible enough to support all the custom configuration settings that my site uses.

  • Wincache object and user caches work well. They reduce load on the MySql database and make the response time faster.
  • URL rewriting is fully supported, so my site is still optimized for search engines and has pretty permalinks.
  • All the plugins work without problems.

As I find out more tips and tricks about hosting web sites in Windows Azure Web Sites I will write about them in this blog.

The post RuslanY.net running on Windows Azure Web Sites appeared first on RuslanY Blog.

]]>
https://ruslany.net/2012/10/ruslany-net-running-on-windows-azure-web-sites/feed/ 6
Install PHP applications with WebMatrix https://ruslany.net/2010/07/install-php-applications-with-webmatrix/ https://ruslany.net/2010/07/install-php-applications-with-webmatrix/#comments Fri, 09 Jul 2010 20:45:10 +0000 http://ruslany.net/?p=791 Microsoft has recently launched a beta release of a new project called WebMatrix. This is a complete web development stack that can be used to start developing and deploying web sites. One thing that may be not so obvious from all the existing announcements is the fact that WebMatrix has full support for installing, running and … Continue reading "Install PHP applications with WebMatrix"

The post Install PHP applications with WebMatrix appeared first on RuslanY Blog.

]]>
Microsoft has recently launched a beta release of a new project called WebMatrix. This is a complete web development stack that can be used to start developing and deploying web sites. One thing that may be not so obvious from all the existing announcements is the fact that WebMatrix has full support for installing, running and publishing PHP applications.

Here are the examples of how WebMatrix can be used to create and publish a PHP web site (using WordPress as a showcase).

Installing a PHP application

After installing and launching WebMatrix select “Site from Web Gallery” option and then pick WordPress:

Follow the installation steps as described in Download and Install a PHP application. As you proceed you will notice that WebMatrix downloads and installs the necessary components for running WordPress – the latest version of PHP 5.2 and MySQL. At the end of the installation process you will get a working instance of WordPress, that you can configure and customize further:

Notice the port number used in the URL. This is not the standard port 80 used by default in IIS. The site is not running on IIS that is included with operating system. Instead WebMatrix installs and uses IIS Developer Express, which is a developer-focused version of IIS that runs on all versions of Windows, starting from Windows XP. This is actually very cool because now it is possible to get the latest and greatest IIS features on Windows XP instead of using the good old IIS 5.1 as development web server :). But even if you already have Windows 7, you may still want to use IIS Developer Express, because with that you do not need to enable real IIS Web Server included with OS on your development machine.

Even though IIS Developer Express is a lightweight development server it comes with everything needed to run PHP applications, including the latest version of FastCGI module and URL Rewrite 2.0. This means that after you install WordPress with WebMatrix you can enable WordPress’ pretty permalinks by following the instructions at IIS URL Rewrite Module support in WordPress.

Note: By default WebMatrix and IIS Developer Express are not configured to run PHP even if PHP is already installed on the machine. To work this around  install any PHP application via WebMatrix UI. This way WebMatrix will configure IIS Developer Express to handle PHP requests. This is something that will be fixed in future releases of WebMatrix.

Modifying a PHP application

After the WordPress is installed there are several things you can do with it from within WebMatrix. For example you can edit the theme files by using the built-in editor:

You can check what kind of HTTP requests are made by Web Browser to load a typical WordPress page:

(Learn more about this feature at Using WebMatrix Beta: Analyze Your WebSite)

Also, you can check the WordPress database content by using the WebMatrix Database Manager:

And, finally, you can run the search engine optimization analysis and fix any SEO violations found within the application:

(Learn more about this feature at Using WebMatrix Beta: Make your Website SEO Friendly)

Publishing a PHP application

The last step is the publishing of the web application on a live web server. WebMatrix can publish the content to a web server by using various protocols: FTP, FTP/SSL and WebDeploy (note that FTP protocols cannot be used to publish MySQL database). You can pick a hosting provider from the list offered by WebMatrix or you if you know the publishing settings from your hosting provider you can manually enter them in WebMatrix.

When you publish the content the WebMatrix will show you the list of files and the database that will be uploaded to the server. Note also that during publishing the WebMatrix will replace the current database connection settings in wp-config.phpfile with the connection settings used on a hosting web server. WebMatrix will extract that information from the connection string that you specify in publishing settings:

(Learn more about publishng web sites at Using WebMatrix Beta: Publish Your WebSite)

Feedback and suggestions

The WebMatrix is a beta release and the WebMatrix team is open to any constructive feedback on how to improve the product. Do you have any suggestions or have you run into any problems when using WebMatrix? What PHP related features would you like to see in this product? Please let the team know by starting the thread on WebMatrix forum or by leaving a comment here.

The post Install PHP applications with WebMatrix appeared first on RuslanY Blog.

]]>
https://ruslany.net/2010/07/install-php-applications-with-webmatrix/feed/ 21
Slides and Questions from PHP on Windows Webcast https://ruslany.net/2010/04/slides-and-questions-from-php-on-windows-webcast/ https://ruslany.net/2010/04/slides-and-questions-from-php-on-windows-webcast/#comments Tue, 13 Apr 2010 19:11:56 +0000 http://ruslany.net/?p=737 On April 9, Mark Brown and I did a PHP|Architect webcast “PHP Performance On Windows”. The slides from the presentation have been published at the following link: PHP Performance on Windows – slides There were a number of question at the end of the webcast that we did not get to answer due to lack … Continue reading "Slides and Questions from PHP on Windows Webcast"

The post Slides and Questions from PHP on Windows Webcast appeared first on RuslanY Blog.

]]>
On April 9, Mark Brown and I did a PHP|Architect webcast “PHP Performance On Windows”. The slides from the presentation have been published at the following link:

PHP Performance on Windows – slides

There were a number of question at the end of the webcast that we did not get to answer due to lack of time. This blog post provides answers to those questions.

Q: Why is php_mssql.dll removed from php 5.3.2?
A: The reason why it was removed was because of an incompatible driver. The last SDK supported by Microsoft was not compatible anymore with VC6. Anyway, php_mssql.dll is not recommended to be used with SQL Server because there is a SQL Driver for PHP that is officially supported by Microsoft. You can get more information about the driver at Working with Microsoft SQL Server driver (php_sqlsrv.dll) for PHP on Windows.

Q: How can we have .htaccess file features work on IIS? Is there an alternative?
A: There are several options. If you just want Apache mod_rewrite rules to work on IIS, then you can import them from a .htaccess file. If you want complete support for all .htaccess features then you can try Helicon Ape from HeliconTech. Regarding PHP specific features in .htaccess file – for PHP 5.2 you could use htscanner PECL extension. In PHP 5.3 there is a new feature for per directory PHP configuration and .user.ini files.

Q: Do you have any numbers to compare iis performance with other web servers(apache, nginx, lighttpd)?
A: No, we do not have any numbers that can be shared. It’s difficult to come up with an objective test that compares web server technologies – there are too many variables and interpretations of the results and even if Microsoft ever produced such numbers they would probably cause a lot of controversy over the objectivity of those tests.

Q: Do you plan to implement wincache library for Zend Framework(Zend_Cache)?
A: WinCache team does not have plans for that, but there is already a PHP developer who is working on implementing this: http://github.com/juokaz/wincache.

Q: We have discussed here sugar CRM. Is Microsoft planning to do enhancement in sugar CRM functionality?
A: Microsoft works well with Sugar CRM development team and Sugar CRM add enhancements to their future versions to support new features from Microsoft, such as WinCache user and session cache for example. Microsoft, however does not contribute any code and does not work directly on any enhancements to Sugar CRM.

Q: Is Microsoft planning to develop any dll which can make PHP code to Intermediate language?
A: Assuming that the question is about .NET intermediate language – no, there are no plans for this.

Q: Would there be any tool in Microsoft development tool kit for PHP?
A: There are several projects in Microsoft that provide development tools and instructions for enabling interoperability between PHP and other Microsoft technologies. You can find more details about those projects here: http://www.interoperabilitybridges.com/.

Q: Is WinCache shared data accessible for CLI? Script A launches Script B, C and D … ?
A: Yes, you can access the shared data from CLI as long as you set wincache.enablecli = 1 in php.ini and all the CLI processes have the same parent process.

Q: Are the statistics results of WinCache the same in 5.2.13 as in 5.3?
A: If the question is about wincache.php statistics script then yes – the data presented by that script is the same regardless of the PHP version.

Q: Are there any security concerns with having wincache store session data in shared memory?
A: If you use different IIS application pools for different web sites (which is the recommended configuration), then WinCache ensures that those web sites can not access each other’s cache data. All caches, not just the session cache are not shared across IIS application pools.

Q: Is it safe to write to the user cache assuming data disappears from the system after the cache times out? Is the content of the user cache in wincache 1.1 written to disk at all?
A: Normally the data in the user cache is deleted from the cache after the time to live interval, but the deletion happens on the main request processing thread. This means that if there are no requests to process, the entries in the cache may stay longer than the TTL. WinCache does not write user cache content to disk, but if memory pagefile is enabled on the server, then it may happen that the memory content will be stored by OS in a pagefile. If a maching (not just a process) crashes when user cache content is in the pagefile, then the content may be present on disk.

Q: Is the sqlsrv driver going to be compatible with PDO?
A: SQL Driver for PHP 2.0 will include PDO support.

Q: Is there any documentation on securely configuring php/FastCGI in a shared application pool environment on IIS6 so that websites?
A: Check the article about setting up PHP on IIS6 and look for the section called “Impersonation and file system access”. If this is not what you are looking for – let me know.

Q: When are we going to see PHP 5.3 in the WPI?
A: Web PI team is planning to add support for PHP 5.3 in near future. Most probably it will be possible to select which version of PHP to install from Web PI. This is because there are some PHP applications in Web PI that will never support PHP 5.3.

Thanks to all who has attended the webcast and asked interesting questions!

The post Slides and Questions from PHP on Windows Webcast appeared first on RuslanY Blog.

]]>
https://ruslany.net/2010/04/slides-and-questions-from-php-on-windows-webcast/feed/ 2
PHP on IIS: MonitorChangesTo setting in FastCGI https://ruslany.net/2010/03/php-on-iis-monitorchangesto-setting-in-fastcgi/ https://ruslany.net/2010/03/php-on-iis-monitorchangesto-setting-in-fastcgi/#comments Tue, 30 Mar 2010 21:36:54 +0000 http://ruslany.net/?p=710 PHP on Windows loads its configuration file php.ini during the startup of the process php-cgi.exe. When PHP is run on IIS via FastCGI the php-cgi.exe processes are re-used to handle many requests. If configuration settings in php.ini file get updated, those changes will not be picked up by php-cgi.exe processes until the processes are recycled … Continue reading "PHP on IIS: MonitorChangesTo setting in FastCGI"

The post PHP on IIS: MonitorChangesTo setting in FastCGI appeared first on RuslanY Blog.

]]>
PHP on Windows loads its configuration file php.ini during the startup of the process php-cgi.exe. When PHP is run on IIS via FastCGI the php-cgi.exe processes are re-used to handle many requests. If configuration settings in php.ini file get updated, those changes will not be picked up by php-cgi.exe processes until the processes are recycled or restarted by IIS FastCGI module. This means that any time you change the PHP configuration you have to manually recycle IIS Application Pools that use PHP. This post explains how to configure FastCGI in IIS so that PHP configuration changes take effect right away without the need to manually recycle or restart the IIS Application Pools.

The latest releases of the FastCGI Extensoin 1.5 and FastCGI update for IIS 7.0 have a new configuration setting monitorChangesTo that takes an absolute path to a file that FastCGI will monitor for changes. In case of PHP this means that you can set monitorChangesTo to a path to php.ini file, so that any time it is modified the FastCGI module will restart the php-cgi.exe to pick up the configuration changes.

Assuming that the PHP configuration file location is C:\PHP\php.ini, the instructions below describe how to use monitorChangesTo on different IIS versions:

IIS 5.1 and IIS 6.0

The FasCGI configuration is stored in a file %windir%\system32\inetsrv\fcgiext.ini. You can manually update it to use monitorChangesTo:

[Types]
php=PHP

[PHP]
ExePath=C:\PHP\php-cgi.exe
MonitorChangesTo=C:\PHP\php.ini

Alternatively you can use the configuration helper script %windir%\system32\inetsrv\fcgiconfig.js :

cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:PHP -MonitorChangesTo:C:\PHP\php.ini

IIS 7.0

You will need to install the FastCGI Update in order to be able to use monitorChangesTo in IIS 7.0 on Windows Vista and Windows Server 2008.

To configure this setting, use the command below:

%windir%appcmd.exe set config -section:system.webServer/fastCgi ^
/[fullPath='C:\PHP\php-cgi.exe',arguments=''].monitorChangesTo:"C:\PHP\php.ini" ^
/commit:apphost

IIS 7.5

In Windows 7 and Windows Server 2008 R2 you can use the same appcmd command as described above or you can use IIS Manager user interface for FastCGI settings:

Technical Notes

Below are the technical details that you need to be aware of when using this new feature in FastCGI module:

  • The file that monitorChangesTo is pointing to must exist on a file system. If it does not exist then FastCGI module will generate an error;
  • If the file is located on a network share then FastCGI module cannot use Windows file change notifications so it will switch to polling and will check the file for changes every 5 seconds;
  • If a relative file path is specified instead of an absolute path then FastCGI will assume that it is relative to the location of php-cgi.exe file.

The post PHP on IIS: MonitorChangesTo setting in FastCGI appeared first on RuslanY Blog.

]]>
https://ruslany.net/2010/03/php-on-iis-monitorchangesto-setting-in-fastcgi/feed/ 3