Sunday, September 16, 2012

IIS and PHP

It is quite handy to have PHP hook up with IIS server that I can develop PHP applications on a window platform. In this article, I am going to share the integration process and some useful tutorials.

The Specs of my computer

  • Window 7 Ultimate Service Pack 1
  • IIS (Internet Information Service) Version 7.5
  • PHP Version 5.3.17 VC9 x86 Non Thread Safe

1. Download/Install IIS and PHP

If you haven't had IIS server and PHP installed in your computer, ( The way I found I didn't have IIS in my computer is when I search  "iis", "Internet Information Services (IIS) Manager" is not on the list. )
The most handy way is go to http://php.iis.net/ , click on "Install PHP Now",
you will be prompted to download Microsoft Web Platform Installer. Using this installer, as it says, you are able to download "Internet Information Services (IIS), SQL Server Express, .NET Framework and Visual Web Developer" in a easier way.

If you already have IIS ( for example, you had installed ASP.NET development framework in your computer, then it is very likely that you already have IIS), you only need to install PHP
Download/Install PHP for Windows
http://windows.php.net/download/
Download PHP 5.3 VC9 x86 Non Thread Safe Installer is recommended.

2. Enable FastCGI Support in IIS

Start --> Control Panel --> Programs--> Turn Windows features on or off (under Programs and Features)
check CGI (under Internet Information Service --> World Wide Web Services)
























3. Change PHP Settings

After installation of PHP, edit the php.ini file. This file, in my case, is in c:\Program Files (x86)\PHP\

fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0

4. Create a handler mapping for PHP

Open IIS Manager (you can search "iis" and select Internet Information Services Manager),
and click on "Handler Mappings"
























Click on Add Module Mapping in the left action panel and filled in the following properties:
  • Request path: *.php
  • Module: FastCgiModule
  • Executable: C:\[Path to PHP installation]\php-cgi.exe
  • Name: PHP_via_FastCGI
Click on Request Restrictions, choose the Mapping tab, check "Invoke handler only if request is mapped to:", and select "File or folder".

  

5.  Launch/Test Web application

So far, the settings for IIS and PHP are finished. If you already has developed some web applications in PHP and you want to test it.

Add Web Application
Open IIS Manager --> right click on "Default web site" in the right connections panel --> choose "Add application" -->type in Alias and choose the Physical path, the directory in which your web pages reside --> click "OK"

Launch Web App
In IIS Manager, click on "Start" in the right actions panel (under the Manager Web Site section)
Then click on "Browse *:80 (http) in the right actions panel (under the Browse Web Site section)
The IIS welcome page appear, type in localhost/your_app_name/*.php

If You don't have web pages to test ......
You can fabricate a phpinfo.php page in the physical directory you set up for the application or 
in the C:\inetpub\wwwroot folder

[Notice] you might not have write permission to the directory C:\inetpub\wwwroot\ , to save a file in that folder, you have to change security properties of it.
The content of phpinfo.php

<?php
phpinfo();
?>

Type in the link to browse the PHP information 
localhost/phpinfo.php or localhost/your_app_name/phpinfo.php


Useful Tools / Tutorials

One tool that you can easily manage your PHP settings (instead of manually editing php.ini) is download PHP Manager for IIS
Which provides an easy way to manage PHP version, settings and install extensions in IIS.

Basically, I follow this tutorial 
"PHP, Microsoft IIS 7.0 and later" as the most important guideline.
http://www.php.net/manual/en/install.windows.iis7.php





----------------------------------
Add notes 2013/6/17
1. You might encounter error messages like "you do not have permissions to view this page" when you try to browse your webpage. Then, you need to change the permission of the folder where your web pages reside.
Right click on the folder, in the "Security" tab, Edit permission and add "IUSR", grant it Read, Execute rights.

2. In installing the PHP, when it asks you "Select the web server you wish to setup", choose "IIS FastCGI"















 

Sunday, February 12, 2012

Linsanity

This article has nothing to do with web technology. It is only a summary of what I read in a latest article about Jeremy Lin from Forbes. The original article is here

Jeremy Lin is an Asian-American, whose parents came from Taiwan. He was born in California and being educated in the USA all his life. His latest performance in NBA arouses a huge attention recently. Watching those video clips, I could not believe my eyes at all. It has been rooted in my heart that Asians is no way compatible with African-American or other America basketball players because of physical conditions. He is really an outlier but he is still shorter compared to other basketball players. To express my admiration for his outstanding basketball skills, and to remind me some of the most important things when odds are not in our side, I take notes from this Forbes article. Though success can not be replicated, but his story still can give us some hints about success.

1. "You've got to believe in yourself, even when no one else does"
2. "You never know when opportunities are going to arise in life. Often, they're when you least expect them"
3. "Before that (got his contract guaranteed by the Knicks), he could have been cut at any time"
4. "You've got to do your best to understand what your strengths are and then ensure that you're in a system( a job or organization or industry) that is a good fit for those strengths"
5. "We put people around us in boxes.....Do you know what your people (or even yourself) is really capable of?"
6. "...you find what your're good at and do it". "Always be a first-rate version of yourself. Instead of a second-rate version of somebody else"
7. "Stay humble"
8. "When you make others around you look good, they will love you forever. ...They (the Knicks players) are all working harder to share the ball with others. And it's beautiful to watch".
9. "Never forget about the importance of luck or fate in life."
10 ."There are not short cuts to hard work. Success is a by product of that. ....You can only control what you control".

All these words are extracted from the article "Just Lin, Baby! 10 Lessons Jeremy Lin can teach us......."

Monday, February 6, 2012

work recently

Recently I have been working on a customized production / inventory management system, utilizing techniques such as PHP, MySQL and JavaScript. By working on this project, accumulates my knowledge and skills in web development. There is nothing fancy here. Since this is an internal website, users are employees inside the company, which provide me a good chance to work closely with them and get immediate feedback. Most of the time, users come with their need and their thoughts about the platform. I am very glad to see that, a very small change to the page can greatly improve their work efficiency. It is also not uncommon that we need to fix bugs reported, to add a supervisor's sign off before processing further,... etc maintenance work.

For example, users are asking a features on a daily-use list to add on a check box for each item they are working on, which flags the item as problematic or not. This simple job facilitates the work around the co-workers in that team and supervisors can review the list to take the next step. We utilize an ajax request and make changes to the HTML DOM element using javascript, to give users an immediate response upon users checking the box.

Or we create a dashboard for information sharing among different teams. For example, different teams need to take actions after the ball entering into their court. Earlier, they are using emails to communicate the current status, which is less efficient and a waste of man power. We keep track of the status every time a critical action is taken and update the status on the dashboard and sending out system notifications to related teams.

These plain tasks streamline the process, cut off unnecessary work and increase people's performance.