WordPress Sample files

by Sunitha Muthukrishna

Note

The Windows Web Application Gallery (WWAG) is being retired on July 1, 2021. We are no longer taking submissions via the Submission Portal. Please contact webpi@microsoft.com to make updates to your existing submission.

This is a set of sample files you could use with WordPress and the Web Deployment tool for deploying WordPress onto IIS. The files are annotated with comments that explain specific lines in the files you'll need to customize for your configuration.

Sample manifest.xml file

<msdeploy.iisapp>
  <!-- iisapp path identifies the subdirectory in the ZIP file which
  contains all of the application files 
  -->
  <iisApp path="wordpress" />
  <!-- dbmysql path identifies the SQL script file that will be executed
  for database setup.  In this app's case, the script is being used
  to create the database user for the application
  -->
  <dbmysql path="install.sql" /> 
   
  <!-- alias is used to make a copy of a distribution file to a location
  where it will be used.  Note that when you specify the Application
  name in the "to" attribute, you should specify the full path using
  the value of iisapp above for the root.  Alias doesn't actually
  copy the file within the package.  It creates an alias to the 
  original file using the new file's path and name.  This alias then
  gets copied to the file system as if it were a real file within
  the package
  -->
    <alias from="wordpress/wp-config-sample.php" to="wordpress/wp-config.php" />
 
  <!-- setAcl with a setAclResourceType of "File" is used to set the access
  privileges for a file within the application.  In this case, the 
  ACL is being set on the configuration file that was created after the
  alias above was copied to disk.  This will enable the application to
  write to the configuration file as needed.  
  We highly recommend setting Writable permission to only those directories that require this permission  setting.
  -->
  
  <setAcl 
    path="wordpress/wp-content"   
    setAclAccess="Modify"
    setAclUser="anonymousAuthenticationUser" 
    />
  <!-- setAcl with no setAclResourceType set will default to setting an ACL
  on a directory.  We are setting an ACL here for the files directory.
  This directory is used to store files that are uploaded for the 
  application
  -->
  <!-- NOTE - with setAcl, the setAclUser can be explicitly set, or you can
  use the alias 'anonymousAuthenticationUser'.  This should be used in
  all situations, unless your application has a dependency on a specific
  OS user for access to these resources.

  Modify access includes Read and Write as well.  For a full breakdown
  on user rights, check out this article on MSDN:
  http://msdn.microsoft.com/library/system.security.accesscontrol.filesystemrights.aspx
  -->

</msdeploy.iisapp>

Sample parameters.xml file

<parameters>

<!-- Prompts where to copy the content files and takes a web site path (such as "contoso.com/app"). -->
<parameter name="ApplicationPath"
description="Full site path you would like to install your application to(i.e. Default Web Site/joomla)."
defaultValue="Default Web Site/wordpress"
tags="iisapp" >

<parameterEntry
type="ProviderPath"
scope="iisapp"
match="wordpress" />
</parameter>

<!-- Setting ACL parameters for Wordpress content directory as mentioned in the manifest.xml -->

<parameter name="SetAclParameter1"
description="Sets the ACL on wp-content directory "
defaultValue="{ApplicationPath}/wp-content"
tags="Hidden" >

<parameterEntry
type="ProviderPath"
scope="setAcl"
match="wordpress/wp-content"/>
</parameter>

<!-- Database Parameters -->

<!-- Prompts the user for the database server name.-->
<!-- Note that this parameter has only one parameterEntry element. This parameter is used with the configuration file and the connection string. It is not used within the SQL script itself like the other parameters are. -->

<parameter name="DatabaseServer"
description="This is usually localhost or a host name provided by the hosting provider."
defaultValue="localhost"
tags="MySQL, dbServer" >

<!-- Parameter substitution -->
<parameterEntry
type="TextFile"
scope="install.sql"
match="PlaceHolderForServer" />
</parameter>

<parameter name="Automatic DatabaseServer"
defaultValue="define\('DB_HOST', '{DatabaseServer}'\);"
tags="Hidden, MySQL" >
<parameterEntry
type="TextFile"
scope="wp-config.php"
match="define\('DB_HOST', '[^']*'\);" />
</parameter>

<!-- Prompts the user for the database name. -->
<parameter name="DatabaseName"
description="Database Name for your application. Please note database name must start with a letter and must be in lowercase along. You can also use numerals and underscore(_)."
defaultValue="wordpressdb"
tags="MySQL, dbName" >
<!-- Parameter substitution-->
<parameterEntry
type="TextFile"
scope="install.sql"
match="PlaceHolderForDb" />

</parameter>

<!-- Prompts the user for the database name. -->
<parameter name="Automatic DatabaseName"
defaultValue="define('DB_NAME', '{DbName}');"
tags="Hidden, MySQL" >
<parameterEntry
type="TextFile"
scope="wp-config.php"
match="define\('DB_NAME', '[^']*'\);" />
</parameter> 

<!--Prompts the user for the database username. -->

<parameter name="DatabaseAdministrator"
description="This can be the default MySQL username root, a username provided by your hosting provider, or one that you created in setting up your database server. "
defaultValue="root"
tags="MySQL, DbAdminUsername" >

</parameter>

<!-- Prompts the user for the database user's password. -->

<parameter name="DatabaseAdministratorPassword"
description="Using a password for the MySQL account is mandatory for site security. This is the same password used to access your database. This may be predefined by your hosting provider. "
tags="Password, MySQL, DbAdminPassword" >

</parameter>

<parameter name="Database Username"
description="Username to access your Wordpress database"
defaultValue="joomlauser"
tags="MySQL, DbUsername">
<!-- Parameter substitution-->
<parameterEntry
type="TextFile"
scope="install.sql"
match="PlaceHolderForUser" />

</parameter>
<parameter name="Automatic Database Username"
defaultValue="define('DB_USER', '{DbUsername}');"
tags="Hidden, MySQL">
<parameterEntry
type="TextFile"
scope="wp-config.php"
match="define\('DB_USER', '[^']*'\);" />
</parameter>

<!-- Prompts for the database password and fills it into the database scripts.The MySQL tag indicates it is a parameter required for MySQL, the DbUserPassword tag indicates this is a Db password -->
<parameter name="Database Password"
description="Password for your Wordpress database"
tags="New, Password, MySQL, DbUserPassword">

<!-- Parameter substitution-->
<parameterEntry
type="TextFile"
scope="install.sql"
match="PlaceHolderForPassword" />
</parameter>

<parameter name="Automatic Database Password"
defaultValue="define('DB_PASSWORD', '{DbPassword}');"
tags="Hidden, MySQL">
<parameterEntry
type="TextFile"
scope="wp-config.php"
match="define\('DB_PASSWORD', '[^']*'\);" />
</parameter>

<!-- This is the hidden admin connection string used to run the database scripts. -->

<parameter name="ConnectionString"
description="Automatically sets the connection string for the connection request."
defaultValue="Server={DatabaseServer};Database={DatabaseName};uid={DatabaseAdministrator};Pwd={DatabaseAdministratorPassword};"
tags="Hidden,MySQLConnectionString" >

<parameterEntry
type="ProviderPath"
scope="dbmysql"
match="install.sql" />

</parameter>

</parameters>

Sample install.sql file

USE PlaceHolderForDb;

DROP PROCEDURE IF EXISTS add_user ;

CREATE PROCEDURE add_user()
BEGIN
DECLARE EXIT HANDLER FOR 1044 BEGIN END;
GRANT ALL PRIVILEGES ON PlaceHolderForDb.* to 'PlaceHolderForUser'@'PlaceHolderForServer' IDENTIFIED BY 'PlaceHolderForPassword';
FLUSH PRIVILEGES;
END
//

CALL add_user() //

DROP PROCEDURE IF EXISTS add_user //