Monday, November 23, 2009  
Google
Web pcquest.com

CIOL Network sites

Search by Issue | Sitemap | Advanced Search

• For most updated version of DQ TOP 20 issue, visit dqindia.com • Ad : Play and Plug ERP by IBM
 Home > Developer

Deploying PHP Across Windows and Linux

The popular scripting language has become more versatile than ever before. Today, it's not just the domain of Linux and Apache fans, even Windows users can enjoy its benefits. Here, we compare it on three platforms.

Rakesh Sharma

Friday, May 01, 2009

Print Comment Email DiggDigg DeliciousDel.icio.us RedittReddit TwitterTwitter

PHP is one of the most widely used scripting languages for developing web applications. Since PHP has mostly been used for writing Open Source Web apps, it's only natural to form the opinion that it will only work on an Open Source platform, e.g. Linux and Apache. There's nothing wrong in believing that, because the LAMP (Linux, Apache, MySQL, with Perl/PHP) platform was and continues to remain very powerful. But the good news is that PHP is also available on other platforms and is not restricted to working with LAM alone. So the 'L' can be replaced with 'W' for Windows or 'S' for Solaris, the 'A' with 'IIS', and the 'M' with SQL Server. You can therefore imagine that lots of permutations and combinations can be formed due to this, giving web app developers more choice. It would be very difficult to say which platform is better at this stage, because a lot of it also depends upon the preference of web developers. So in this article, we'll concentrate on three PHP combos: The traditional PHP on Linux with Apache, PHP on Windows with Apache, and finally PHP on Windows with IIS. For now, we've kept MySQL constant.

Direct Hit!

Applies To: PHP developers
USP: Learn to deploy PHP on
various platforms
Primary Link: php.net
Keywords: PHP, Apache, IIS7

IIS7 provides extra features to PHP that Apache does not. For example, you can enable features like caching, HTTP redirection, role management and many more without making any changes to PHP. With the inclusion of fastCGI module, IIS not only provides a single thread environment for various extensions of PHP (which exclusively require a single threaded environment) but can also persist amongst various requests. This increases the performance and reliability. The new IIS7 manager tool allows you to manage PHP, ASP.NET applications and IIS7 from a single window. Hence, you get ease of manageability. IIS7 also supports web application installers, which let you deploy free applications with a single click, for example DotNetNuke, Wordpress, Drupal and so on. The web application installer also checks the system for pre-requisites and then automatically downloads the chosen application for the source site. During installation, if the downloaded application needs any configuration inputs then you are prompted for in the process.

There are a couple of all-in-WAMP solutions available, one of them is XAMP server, which installs Apache, MySQL and PHP in one shot on Windows as well as Linux­­­.

We tried all three scenarios in our lab and our experience with all of them was equally smooth. We'll take you through the process in this article, to help you understand it better. Then we will deploy various open source solutions for the three scenarios to see if there is actually any difference in functionality. Let's begin.

PHP on Linux with Apache
We used Debian 5 Linux for this, and setting up PHP and Apache on it was a breeze. All it required was to first install Apache using the # apt-get install apache2, followed by another single line command to install PHP and MySQL, viz. # apt-get install php5 mysql php5-mysql.

Make sure you have selected IIS FastCGI option while installing IIS7 web server on Windows Server 2008. While installing Apache make sure that you provide correct domain and host names, along with proper admin email IDs.

PHP on Windows with Apache
In Windows, if you want to run PHP over Apache, you have two choices. One is to download each individual component separately and install them one by one. This will obviously be a lengthy process, and will require manual configurations in Apache and PHP to integrate the three. You're likely to face several problems here. The other option is to download the WAMP server, which can easily be downloaded from www.apachefriends.org.

Choose the type of database you need. Multifunctional database should be chosen if you are not sure about the exact nature of transactions. After unzipping the PHP file on Windows Server 2008 you need to configure IIS7 for handling PHP web pages.

Installing applications on Windows is no rocket science, and doesn't require you to run any commands as you did on Linux. Simply run the setup file, follow the onscreen instructions, and you're done. You can install it as a service that runs in the background or otherwise. Once the installation is over, it automatically starts the application and you have PHP with Apache and MySQL on Windows configured and running. They're already integrated, so you can straightaway get to developing your applications on the platform.

PHP on Winodws with IIS
Let's now look at how to install and configure PHP and MySQL on Windows with IIS. We used Windows Server 2008 and IIS 7 for this purpose. You first need to install IIS7 by going to Windows Server Manager, and adding a role from the Actions menu. This starts off a wizard, where you need to check the web server (IIS 7) option. In the process, you'll need to choose the installation with fastCGI support, when asked. You can skip the additional component installation part when prompted as you won't require that. In a couple of minutes, IIS 7 web server will be up and running.

Next comes PHP, for which you'll need to download the PHP setup file and extract it in a folder in your 'c' drive, and rename the php. inirecommended file to php.ini. You'll need to make a few configurations in IIS to handle PHP files. For this, you'll need to open IIS Manager and select the server. On the right pane, open Handler Mappings. In the rightmost action pane, select Add Module Mapping. In the dialog box that comes up, enter *.php for type, FastCGI for module, C:\php\php-cgi-exe for executable and PHP_for_IIS in the Names field. For configuring PHP for MySQL, repeat the steps for the php.ini file in PHP installation on Windows with Apache.

Next, you have to configure PHP to work with MySQL. For this, open the 'php.ini' file and specify where the extensions are located on the system and uncomment the following lines:

extension_dir = "C:\php\ext"
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll

Once this is done, restart IIS7, and your WISP platform is up and running for action. We'd like to add one more point over here that the WISP platform offers several features that are otherwise not available if you use Apache instead of IIS7.

For example, you can enable features like caching, HTTP redirection, role management and many more without making any changes to PHP.

Deploying Joomla and Limesurvey
Once the platforms are ready, you would obviously like to deploy applications on them. Here again, there are quite a few Open Source apps available for all three. For this article, we tried two of them--Joomla and Limesurvey. Joomla is a powerful Open Source web content management application, while Limesurvey is a powerful online survey management application. Both are very widely used on the web. We hardly found any difference in setting up the applications on all three platforms. There were permission issues in some folders on IIS7, but similar issues were also faced on Linux.

We tried installing various components, modules and plugins of Joomla, all of which happened very smoothly, without any errors on all three platforms. The same story repeated with Limesurvey as well.

How they compare
Installation on Linux, ie Debian in our case, was pretty easy and even integration with MySQL was simple. The installation of PHP along with MySQL on Windows with Apache or IIS required some configuration changes before we could deploy anything else. The time taken for that was between 2 to 3 mins. So, it is only a matter of how comfortable you are on various platforms. If you like Linux then Apache is good, else if you are an IIS aficionado then PHP can be configured with it as well.

PHP is a very versatile language, which can be used on different platforms. Next issue, we'll try out a few applications on PHP and check out the performance on different platforms.

Page(s)   1  

Print Comment Email DiggDigg DeliciousDel.icio.us RedittReddit TwitterTwitter


Untitled Document



ZTE:Leading CDMA Technology


Extraordinary Networks:Freedom of Choice


   
 

 
 

Magazine Subscription | RQS | Contact Us | Team PCQuest | Advertising - Print | jobs@cybermedia