Macrotone Blogs

Macrotone blogs upon Joomla, our products and other matters.
Font size: +

Install IIS, PHP, MySQL & Joomla on Windows 7

iisWe had cause to investigate a problem with a Joomla component installed upon an IIS platform.  We usually use Apache as our web server, so were not totally familiar with the use of IIS, so this blog covers the installation, configuration and the basic options of IIS, PHP, MySQL and Joomla.

There is no intent to make use of such a setup upon a regular basis, and would anticipate only having to perform the task infrequently, hence the decision to document the steps.  We encountered a number of problems as we performed the set up, and we searched on the web in many placed before achieved our goal. For this reason this is somewhat long, but the benefit being that we have all the details in one location.

The installation is assuming the use of a local installation upon a single workstation.

 

Installing IIS

This is a standard Windows configuration.  Go to control panel

CaptureA

Open [Programs and Features]

Capture12

Open [Turn Windows Features on or off]

Click to Check the [Internet Information Services (IIS)] then Click [Details] and ensure that the components as indicated below are checked.

Capture 11 
We found that we had to enable the .Net Extensibility feature before we could get the PHP CGI feature to work correctly.  We found out the hard way and had to go back to turn the feature on, but now we know we can ensure it is set up at the start, before we install PHP.

Note:
We are not intending to make use of ASP or FTP services.

Click [OK] and wait a while whilst Windows performs its’ reconfiguration.

We should now have a directory named ‘inetpub’ located on our Drive (C:) or whatever the system drive is. Under that directory there is another folder named ‘wwwroot’ and it is here we locate all of our web pages.

Testing IIS

Using our familiar favourite Text Editor (notepad, nodepad2 or whatever), we typed “Hello World” then saved the file to c:\Inetpub\wwwroot\ and named it index.html. Then opening our web browser and typing in the address bar localhost/index.php we hit [Enter] key.

Attached Image

Having confirmed that IIS is working fine we can continue, if not then we have a problem and need to review the steps above to discover what we have done wrong.

Configuring IIS

Go to [Start Menu], Click [Run] and type: inetmgr then hit [Enter] key.  Alternatively go to Control Panel, Open [Administrative Tools], Open [Internet Information Services], which should also open the Internet Information Services Manager.

Right-Click on [Default Web Sites], Choose [Properties], the Properties dialog box will appears, Click Configuration and verify that it is pointing at c:\inetpub\wwwroot.  This path can be set to where ever it is desired to locate the web site.
We now configure the default document, which specifies which documents should load if one is not specified in the web site address entered in the browser address bar.
We want to add some defaults for php documents that will be used when we have installed PHP (below). We add two documents, index.php and default.php.  Click the Action add and enter the specific file names.  The end result will look similar to that shown below.

Capture 6

The Document that will be loaded automatically is the one that occurs first in the default Documents list, so we ensure that index.php occurs first in the list.


Installing PHP

We obtained the php file from http://php.net 

Note:  Non-thread-safe build of PHP is recommended when using IIS. The non-thread-safe builds are available at » PHP for Windows: Binaries and Sources Releases.

In the download page under windows Binaries Section, Click on [PHP 5.x.x] zip package (Make sure it’s php 5 or higher).  Select [download mirror], it will take a few minutes depending on the connection’s speed.  After downloading completed, create a directory on your C: drive (or system drive) or whatever you want and name it php (as an example), and extract the php zip file to the specified directory i.e. c:\php\.

Go to the extraction folder which is c:\php and search for “php.ini-recommended” or “php.ini-dist” or any other php ini file that you wish to use as a base.  Copy the file and name it php.ini.

Configuring php.ini

Note that PHP uses file-based session state by default. One can modify a number of additional session settings, including whether cookie or URL sessions should be used, and whether sessions are created on the first request or need to be explicitly created. We need to configure the sessions saving directory since we need also this for the Joomla installation. 

1. In Windows® Explorer, create the session subdirectory in the PHP installation directory.

2. Right-click the session directory, and select Properties.

3. In the Security tab, click Edit.

4. Click Add, and enter IIS_IUSRS for Enter the object names to select.

5. Click OK.

6. Select the Modify permission check box, and click OK.

 

Permissions for session folder

7. Click OK in the Session Properties window.

8. Open php.ini in the PHP installation directory, and set the session.save_path setting to the session subdirectory:

session.save_path = "C:\php\session"

9. Save and close the file.

10. Click Start, and then select Command Prompt.

11. Type runas /user:administrator cmd.exe to enable elevated permissions.

12. Type iisreset at the command prompt, and then press the ENTER key.

Open the php.ini file with any suitable text edit, you are familiar with. 

There are some settings that one has to change:

Do a quick search for “doc_root” and edit it to point to our Local host directory path:

doc_root = c:\Inetpub\wwwroot

Search for “extension_dir” and change the path to point to the ext directory which is placed in the php directory

extension_dir = “c:/php/ext”

After that we will uncomment some useful extension such as (php_mysql.dll) by removing the semicolon from the beginning of line

extension = php_mysql.dll

We can uncomment all extensions we need, but for our purposes the mysql file is the only one we desire.

We intend to use FastCGI with our site so we need to change a few other variables whilst we are here as well.  Search for and change the values as follows:

a.Set fastcgi.logging = 0
FastCGI logging should be disabled on IIS. If it is left enabled, then any messages of any class are treated by FastCGI as error conditions, which will cause IIS to generate an HTTP 500 exception.

b.Set fastcgi.impersonate = 1.
FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.

c.  Set cgi.fix_pathinfo=1
The cgi.fix_pathinfo provides PATH_INFO/PATH_TRANSLATED support for Common Gateway Interface (CGI). Setting this to 1 will cause PHP CGI to fix its paths to conform to the specification.

d.  Set cgi.force_redirect = 0.

e.  Set open_basedir to point to a folder or network path where the content of the Web site(s) is located.

f. Set error_log=”C:php_errors.log”   to help with troubleshooting.

Now save the file as php.ini to the folder c:\php\
Note:
The default path that Windows search for php.ini file is c:\windows\, so we will also copy the php.ini file to the windows folder.

We now need now is to add php directory to windows paths. To do that, right-click on [My Computer] icon, Choose [properties], Click [Advanced] Tab and then click [Environment Variables]. 

 
Capture 7

For User Variables click [New] and type PHPRC in the [Variable name] field, c:\php\ in the Variable Value field then hit [Ok].  This means that we do not use the php.ini file located in the Windows directory as default, instead we use the  file pointed to by this system variable.


Capture 9

For System Variable click on [Path] Variable, click [Edit], at the end of [Variable Value] field add a semicolon ( ; ) and the path to php folder “c:\php\”, hit [Ok]..
Hit [Ok] again on Environment Variables dialog box

Configuring IIS to work with php

Open IIS Manager again (Start => Run => type inetmgr, Hit [Enter] Key)

Follow these steps to create an IIS handler mapping for PHP in IIS Manager user interface:

  • In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";

  • In the IIS Manager user interface select the server node in the "Connections" tree view;

  • In the "Features View" page open the "Handler Mappings" feature;

  • In the "Actions" pane click "Add Module Mapping...";

  • In the "Add Module Mapping" dialog enter the following:

    • Request path: *.php
    • Module: FastCgiModule
    • Executable: C:\[Path to PHP installation]\php-cgi.exe
    • Name: PHP_via_FastCGI
  • Click "Request Restrictions" button and then configure the mapping to invoke handler only if request is mapped to a file or a folder;

  • Click OK on all the dialogs to save the configuration.

Create IIS handler mapping for PHP : Add Handler Mapping
 

The end result looks like in the following display.

Capture 5

Now, go back to IIS Manager, right click on our [Local Server] which has the same name of our computer.  Choose [All Tasks], [Restart IIS…].  Click [OK]   [Alternatively use an elevated command prompt as described earlier.) After Server restarting we can test that it is configured successfully.

Testing php on IIS

Using our favourite text editor we entered the following as a single line:

<?php echophpinfo(); ?>

Saving the file as (phpinfo.php) to our Server root path (c:\Inetpub\wwwroot\).  We then opened the web browser and typed localhost/phpinfo.php in the address bar and hit [Enter].
One should see the php version and php logo at the top  as shown below, along with all other information about php.   Since it was displayed we could conclude that IIS was configured correctly with php.

Capture 2


If the above page is not displayed then php is not integrated successfully.


mysqlInstalling Mysql

Go to http://www.mysql.com/downloads.  Search for the community edition download link and click on it.  We chose the GUI installer.  Effectively this is a cut down summary of the document on the mysql web site.  After installation of the GUI version, the installer will have added its own Start Menu item under MySQL.

Files that are generated by MySQL Installer grant full permissions to the user that executes MySQL Installer, including my.ini.  This does not apply to files and directories for specific products such as the MySQL Server data directory in ProgramData, that is owned by SYSTEM.

After the installer itself has been installed and started, the following screen is displayed:

 

mi-welcome-win

 

There are three main options:

  1. Install MySQL Products - The Installation Wizard.

  2. About MySQL - Learn about MySQL products and features.

  3. Resources - Information to help install and configure MySQL.

We obviously choose to use the installation wizard. A license agreement screen is presented (not shown) which has to be agreed to before proceeding.

If you are connected to the Internet, then the Installer will search for the latest MySQL components and add them to the installation bundle. Click Connect to the Internet to complete this step, or otherwise check the Skip checkbox and then Continue.

If you chose "Connect to the Internet," the next page will show the progress of MySQL Installer's search for available updates. When the search is complete (or if you opted to skip the search), you will be taken to the Choose Setup Type page:

 

mi-choose-setup-type-win

Determine the option most compatible with your preferences by reading the Setup Type Description descriptions.

The Installation and Data paths are also defined here, and a caution flag will notify you if the data path you define already exists.

After you select a setup type, the MySQL Installer will check your system for the necessary external requirements and download then install missing components onto your system.

The next window lists the MySQL products that are scheduled to be installed:

mi-installation-progress-win

As components are installed, you'll see their status change from "to be installed" to "install success."

After all components are installed, the next step involves configuring the products. The Configuration Overview window displays the progress and then loads a configuration window if it is required.

The ideal MySQL Server configuration depends on your intended use, as explained in the next window. Choose the description that most closely applies to your machine.

You may enable TCP/IP Networking here as otherwise only localhost connections are allowed.

Checking the "Advanced Configuration" option provides additional Logging Options to configure. This includes defining file paths for the error log, general log, slow query log (including the configuration of seconds it requires to execute a query), and the binary log.

 

mi-mysql-server-configuration-choice-win

Next, choose your account information. Defining a root password is required, whereas it's optional to create additional users. There are several different predefined user roles that each have different permission levels. For example, a "DB Admin" will have more privileges than a "DB Designer.".

mi-mysql-server-configuration-setup-win

Note

If the MySQL Server is already installed, then the Current Root Password will also be needed.

Next, configure the Windows Service Details. This includes the service name, how the MySQL Server should be loaded at startup, and how the Windows Service for MySQL Server will be run.

mi-installation-configuration-win-service-details

Note

When configuring Run Windows Services as ... using a Custom User, the custom user must have privileges to log on to Windows as a service. And the Next button will be disabled until this user is given these user rights.

On Microsoft Windows 7, this is configured by loading the Start Menu, Control Panel, Administrative Tools, Local Security Policy, Local Policies, User Rights Assignment, then Log On As A Service. Choose Add User or Group here to add the custom user, and then OK, OK to save.

The final configuration step is available if the Advanced Configuration option was checked, and it includes configuration options related to log file names.

After the MySQL Installer configuration process is completed, you may save the installation log, and then load MySQL Workbench if the Start MySQL Workbench after Setup option is checked, or desired. 

Testing MySQL

We carried out the following tests:

  1. We opened the command prompt by clicking on [Start Menu], [Run], type (cmd) and hit [Enter] Key and were presented with a command prompt window.
  2. We navigated to the directory where the MySQL binaries were located/installed.
  3. cdC:\Program Files\MySQL\MySQL Server 5.6\bin 
  4. We now typed the command: mysql –u root p  (This command passes root as user name to MySQL and prompts for the password.)
  5. Type your root's password and hit [Enter] Key.
  6. Now enter the command: show databases.
  7. The output should as displayed in the screen shot below. 

    Capture1

Type quit closing MySQL Command Line window.

Testing php with MySQL

We created our phpinfo.php file in our wwwroot folder earlier so we enter localhost/phpinfo.php in your web browser address bar and hit [Enter] Key.  Then we scrolled down the page and we found the mysql section as below:

Capture 3

Notes

If the above is not shown check the following

  1. Ensure that the file named (libmysql.dll) is present in the php directory.
  2. Check that file php.ini has been copied from the php directory to the Windows directory as mentioned in the configuring php.ini file section above and/or the environment variable is set.
  3. Check that the entry for the extension = php_mysql.dll is uncommented in the php.ini file.
  4. Try to restart your local server [Start Menu], [Run], type (inetmgr), Hit [Enter] Key, right click on your [Local Server] which has the same name of your computer, Choose [All Tasks], [Restart IIS…].[Ok]   or from an elevated command prompt type ‘iisreset’.

joomlaJoomla installation.

Go to http://www.joomla.org and search for download link (we are going to install Joomla 2.5.17) and click on it to download it.

Once downloaded we can extract the file to our inetpub directory: c:\inetpub\wwwroot.

Using our web browser we can then enter the address http://localhost/index.php to fire up the Joomla installer. Our readers will be familiar with the Joomla installer so we do not go into details of the installation here.

Several problems were encountered requiring us to set the correct permissions upon the files and directories under the wwwroot directory. These were required for the installer to be able to create the required directories. We eventually opened up the permissions very wide, which is not a problem for us since this was intended  to be a single isolated installation, not open to general usage. This is not desirable for a server machine, and a more appropriate approach should be used. Note that we had to restart the IIS server after the permissions has been changed, otherwise it didn’t appear to pick up our changes.

We had several problems getting the Joomla installer to work and had to run it several times, and even then it continued to hang (spin) on the configuration step. Knowing that this step was creating a configuration.php file, we created an empty file, which the install populated, even though we stopped the web page at this point. We then removed the installation directory (from c:\inetpub\wwwroot) and the Joomla installation could be checked.

Testing Joomla installation

Testing consisted of entering the Joomla web site, displaying documents etc. On the admin side we could install the component that we wished to test out and change settings, create menu items etc..

Discussions forum migration to Kunena (Part 4) SEF...
Discussions forum migration to Kunena (Part 3) Ima...
 
Go To Top

Joomla! Debug Console

Session

Profile Information

Memory Usage

Database Queries