Jaa


Hosting WordPress in a Subfolder of Your Windows Azure Web Site

This post applies to Windows Azure Web Sites. These steps do not apply if you are using a Web Role.

Windows Azure Web Sites makes it quick and easy to create a WordPress blog hosted in Azure. However, if you create a WordPress blog using the Gallery in Windows Azure Web Sites, the blog becomes the root of your website. Many of our customers have asked about creating a WordPress blog in a sub-folder of a site so that it can be accessed with a URL such as www.mysite.com/blog. In this post, I’ll show you how you can host a WordPress blog in a subfolder of your site.

Here are the steps that we’ll use to add WordPress to a subfolder of an existing site. (I’ve used Roman numerals for these steps so that I can easily refer to them elsewhere in the post without your confusing them with one of the sub-steps.)

I.   Create a temporary WordPress site.

II.  Download the WordPress site using FTP.

III. Add the WordPress content to an existing site.

IV. Delete the temporary WordPress site.

V.  Link the MySQL database to the existing site now hosting the WordPress blog.

VI. Make a couple of changes to the MySQL database.

 

I. Create a Temporary WordPress Site

The first step in the process is to create a temporary WordPress site in Windows Azure Web Sites that you can then move to your existing site.

 

1. In the Azure Portal, click the New button to create a new website.

 

NewSite

 

2. Choose to create a new website from the Gallery.

 

SiteFromGallery

 

3. Select WordPress from the list of apps in the Gallery.

 

WordPressGallery

 

4. Proceed through the wizard to create the WordPress site.

 

II. Download the WordPress Site Using FTP

The next step is to download all of the files for the WordPress site to your local machine so that you can transfer them to the existing site. I use FileZilla, a free FTP client, to do this.

To open the site using FTP, you’ll use the information contained in the publish profile for the site. The publish profile is an XML file that defines the different methods that can be used to publish to the website using Visual Studio, Web Matrix, or Web Deploy. Each publish method is defined in the publish profile using a <publishProfile> section. One of these sections defines the URL, username, and password that you can use to access the site with an FTP client.

  1. PublishProfileFrom the WordPress site’s dashboard in the Azure Portal, click the Download Publish Profile link in the Quick Glance section.
  2. Save the publish profile to your local machine.
  3. Open the publish profile in Notepad or in another text editor.
  4. Locate the FTP publish profile for your site and use the URL, username, and password to log into the site with your FTP client. (See Bertrand’s blog post for details on FTP credentials and where they are located in the publish profile.)
  5. Log into the WordPress site you created in step I and copy the entire contents of the site/wwwroot folder to your local machine. (You can copy these files to any folder you choose.)

Bonus Information on Credentials

The credentials that you obtained from the publish profile are site-level credentials. They are specific to the website and if you share them with a co-administrator of your website, he or she can use them to access the site as well. In addition to the site-level credentials, you can also access the site using user-level credentials.

User-level credentials are tied to your Microsoft account (the account you use to sign into Azure.) Windows Azure Web Sites calls user-level credentials deployment credentials, and you can set them using the Reset Deployment Credentials link in the Quick Glance section.

Since deployment credentials are user-level credentials, you can use them with any of your websites. However, you will need to precede your username with the site name and a backslash. In other words, if my deployment credentials username is Jim, to use it to open a site named WordPressTest, I would use the username WordPressTest\Jim.

You can read more about user-level and site-level credentials in David Ebbo’s entry in GitHub.

III. Add the WordPress Content to an Existing Site

The third step involves adding a new folder to your existing site and then copying the WordPress files into that folder.

1. Open your existing site in your FTP client. (You’ll need to use the proper FTP credentials for the site. You can obtain those using the same steps you used in step II.)

2. Create a new directory to hold the WordPress blog. In this example, I’ve named that directory blog.

 

BlogFolder

 

3. Copy the WordPress files you downloaded in step II into the new folder you created in your existing website.

 

CopyFiles

 

IV. Delete the Temporary WordPress Site

You no longer need the temporary WordPress site you created in step I, so the next step is to delete that site. Be careful not to delete the linked MySQL database when you do this or you will break the new WordPress blog!

 

1. Select the temporary WordPress site in the Azure Portal.

2. Click the Delete button to delete the website.

 

DeleteWPSite

 

3. Make sure that the checkbox for your linked MySQL database instance is unchecked. You do NOT want to delete the linked MySQL database because the WordPress blog you copied in the previous step is still using the database.

 

DeleteConfirm

 

4. Click the Yes button in the lower-right corner of the Delete Confirmation dialog show above to delete the site and keep the MySQL database.

 

The final step is to link the MySQL database to the existing website that now hosts your WordPress blog.

1. From the Azure Portal, select the existing website that is hosting your WordPress blog.

2. Click the Linked Resources tab.

3. Click the Link a Resource link.

 

LinkedResources

 

4. Click the Link an Existing Resource link.

 

LinkExisting

 

5. Click the MySQL Database link.

 

LinkMySQL

 

6. Check the checkbox to agree to ClearDB’s legal terms and then click the Yes button to link the MySQL database to your website.

 

MySQLServer

 

VI. Making a Couple of Changes to the MySQL Database

The final step in making your WordPress blog available in a subfolder of the new site is to make a couple of changes to the MySQL database. When you install WordPress, the URL of the WordPress site is added to the MySQL database. In order for your WordPress blog to work correctly in the new folder, you’ll need to change the URL in the database.

Note: Before you can make changes to the database, you’ll need to install MySQL Workbench and connect to the MySQL database. If you’re not sure how to do this, you can find out in this screencast.

1. Open the MySQL database in MySQL Workbench.

2. Expand the Tables node in the Object Browser, right-click on the wp_options table and click Edit Table Data as shown below.

 

EditTable

 

3. Change the siteurl and home fields so that they reflect the correct URL to the new WordPress site as shown below. (Note that I clicked the option_value column header in order to sort by that field.)

 

TableData

 

 

4. Click the Apply button at the bottom of the window to apply your changes.

5. Click Apply in the Apply SQL Script to Database dialog as shown below.

 

ApplyData

 

 

6. Once your changes have been applied, click the Finish button to complete the process.

 

You can now browse to your WordPress blog by browsing to the URL for the folder you created in step III.

Comments

  • Anonymous
    February 13, 2013
    Thanks for the nice tutorial

  • Anonymous
    May 10, 2013
    This actually doesn't work. Especially when you try to log into the admin. It still thinks the site is at the original URL so it breaks and wont let you log in. It also appears that the MySQL database isn't available inside the management portal? Would you mind adding a bit more info, about things like accessing the database/fixing it.

  • Anonymous
    May 12, 2013
    Hi, JedGrant. Thank you for the comment. In fact, I did leave off the steps involving modifying the MySQL data. I have added that information to the post. I apologize for the trouble. Let me know if you still can't get it working.

  • Anonymous
    September 04, 2013
    Hi Jim - Great tidbit here and worked out well for me with one change to the above steps. I deleted the 'temp' WordPress site I created before ever going to the actual site which creates the database tables, etc. So I had to re-do a few steps then run through the setup via the Word Press page on the 'temp' site and then I was able to delete, copy over files, etc. then access the MySQL database via Workbench.

  • Anonymous
    September 04, 2013
    One other thing I updated was to use index.php as a new default page on my existing site. I only had default.aspx listed.

  • Anonymous
    October 10, 2013
    hi jim, we really appreciate this post.. can u suggest .... my current site is hosted on cloud service, so how to connect word press DB from cloud service(step V) Thanks

  • Anonymous
    October 10, 2013
    I'm on the Windows Azure Web Sites team, so I don't deal with cloud services. Sorry. :)

    • Anonymous
      April 24, 2017
      WARNING - This information must be outdated. I was following the steps and deleted my worpress web app after ftping the data over, but there was NO OPTION to keep or reassign the database. Now everything I had in that site is gone. DONT FOLLOW THIS PROCEDURE!!!
  • Anonymous
    April 24, 2014
    Thanks for sharing. It was helpful

  • Anonymous
    May 18, 2014
    Jim, thanks for the excellent post. Do you know how to install Ghost into a subdirectory? I'd like to have both a site with Wordpress and another with Ghost for comparison.

  • Anonymous
    August 03, 2014
    Jim, would you recommend your method of placing the blog files into a subfolder above trying to host a Brandoo Wordpress site that uses SQL Azure  http://wordpress.brandoo.pl/ on a separate Azure VM pointing to blog.contoso.com and using IIS to do a 301 redirect to contoso.com ? Aside from the advantage that you do not have to pay for a separate server, are there any other plusses ? What about disadvantages, could having the wordpress (Brandoo) files in a subfolder instead of the root cause any issues when wanting to upgrade to a newer version of wordpress (Brandoo) ?

  • Anonymous
    February 05, 2015
    Thanks for the guide! To comment on your last step... if you wait to actually establish the wp site until you've moved it to its final destination, the wp install process takes care of everything and no need to modify the db

  • Anonymous
    March 08, 2015
    After following the above instructions I get the above error when trying to go to the new url (mydomain.com/blog)    The page cannot be displayed because an internal server error has occurred.

  • I copied all of the wordpress files to my existing website under wwwroot/blog

  • I linked my website to the newly created MySql db

  • I set SiteUrl and Home to point to mydomain.com/blog

  • I verified that if I add index.html to wwwroot/blog then going to mydomain.com/blog will display that page

  • I verified that my website is configured to serve index.php files

  • I verified that php version 5.6 is enabled for my website (under Configuration -> General)

  • I've restarted the website

  • I've deleted everything and tried it again from scratch Any suggestions? Thanks.

  • Anonymous
    April 16, 2015
    Thanks For Your valuable posting, it was very informative. Am working in<a href="http://www.excelanto.com">Cloud Erp In India</a>

  • Anonymous
    May 11, 2015
    For future reference, if you are building a Wordpress from scratch, you only need create the word press site in Azure, FTP the folder down and into the new directory, and link the resource. If you do this before logging into Wordpress for the first time, then the MySQL options table will end up with the correct URL as it doesn't create  that table until 'installing' wordpress through the Web GUI, and will map to whatever URL you have it at!

  • Anonymous
    January 23, 2017
    Hi, is there a way to do a similar thing, but with a nodejs express site running in a subfolder while the root is running a wordpress instance?