What are the differences between IIS and Apache for PHP hosting? - php

I have spent a fair amount of time working with PHP in both IIS and Apache server (Windows) configurations. I have seen suggested a couple of times that Apache is preferred over IIS.
I had been under the impression that one of the primary reasons for Apache over IIS was that performance under CGI through IIS was significantly slower. However, the support through Fast CGI seems to have fixed much of that issue.
Another issue is certainly licensing costs, but assuming that isn't an issue, what are the other differences, assuming a Windows-based platform?

You're right, IIS FastCGI nullifies any arguments about PHP on IIS being slower than Apache. Assuming a Windows Platform, leveraging IIS gives you all of the benefits that come with using IIS like: a brain-dead simple path to clustering; leveraging the Web Platform Installer to get a jumpstart on running common PHP apps like Drupal; and the ability to combine technologies like PHP and ASP.NET in the same website.

The most obvious answer is that if you work with other people, administrators who work with PHP are much more likely to have Apache experience rather than IIS experience. So in larger companies in particular we tend to support these trends because it reduces real and perceived knowledge burden and training cost. That is, we always use Apache for PHP, and we always run it on Linux because it is really easier to hire web admins who have supported PHP with Apache on Linux.
If its just you then obviously this doesn't apply. You're going to hear Apache suggested more because its what more people have used, but that doesn't necessarily mean anything to you. If you've got a lot of experience with both then you are in a better position to answer this yourself than the majority of people who you'll see opinions from.

Related

Should I move client to Lamp or develop on Wamp?

I have never developed for WAMP, the hosting guy for my new client says they are using Windows servers, they can setup PHP and MySQL for me, but they cannot switch to a *nix server.
He said there are some nuances from PHP on *nix Vs. win.
So my question is, if I have never programmed PHP on win, should I go through the hassle of switching hosts (since they cannot do *nix themselves), or are the differences slight enough that it shouldn't be too big a problem for me?
(side note: the state of the clients website has no effect since it is a static all-flash site and is going to be completely rebuilt)
Thanks!
I would suggest XAMPP which is a complete LAMP package which will install on either Windows or Linux.
You can do all your development on your local machine this way.
Edit to address the actual question: Before bringing this up with the client, here are some things to consider:
What is your relationship with the client? Is this a one project deal, or do you hope to continue working for them? Either way, do you want to get a good reference from them? Are you a long established service provider with a high level of trust, or a new face who has yet to prove themselves? How would they respond if you suggest that they change? Would they mind switching web hosts?
How comfortable are you working with Windows in general? Can you can use it with moderate skill and comfort?
What is your time frame for project completion? How long would it take to find a new hosting service and get set up? How will this impact your scheduled completion?
Ultimately, if you decide to raise the issue, the client has to decide whether they want to move to a new hosting company. Some factors to consider there include:
How long have they been with this host? How good or bad is the relationship between your client and their hosting company. What contractual obligations are in place between them? Would your client have to pay to leave?
After you finish the initial development, who is going to maintain and administer the system (you or someone at the client company), and which system do they know?
Now, if you want to use Windows, I'll mention that, in addition to XAMPP, the WAMP server, which will run on just about any modern version of Windows. I used it for a class (where it was required), and then on a development system for a project at work that ultimately ran on a Linux server. Both ran Windows XP. I don't recall needing to make any changes when copying the PHP from Windows to Linux, although I did stay away from any functions which would have been platform dependent. FWIW, I found WAMP very easy to set up, administer, and use.
I'd suggest to avoid windows hosting. There is no much difference for the PHP as it already multiplatform, but windows is not an option for the public host. Less performance, less security, less operability.
Also, note that they never administer php installation, so, it will be trouble in support.

what are the Advantages and disadvantages of running php on windows

the linux environment is natural to php,
what are the Advantages and disadvantages with run php on windows ?
Are there some limits in windows ?
what is the best (lamp/wamp) in term of performance ?
thanks
It's not so much that it is natural on Linux but the tendency was for developers to use PHP in the earlier days as the ASP on Linux. For years MS never even mentioned PHP and never gave it any support and so most development work happened in the Linux arena with the result that it is more advanced as it has simply had more development hours spent on it.
Again in the early days it was more difficult to get PHP running on ISS but apache makes it easier but then you need to install it. I rarely develop on Windows but i think the environment has changed for the better with more integration.
The emergence of packages such as XAMPP and WAMPP make installation and running a lot easier but as Karsten says not really for the production environment as they are not geared for it in performance and especially on the security level, because of this i also doubt if they are geared for performance, they are geared for ease of install and development.
Case sensitivity can be a problem if you develop in Windows and later move to Linux.
Well, there's the obvious problem of trying to compile PECL extensions on a Windows platform, and the problems associated with not having sendmail running and trying to use the mail function.
Other than that, as long as the source has been ported correctly, it should do fine.
There is an Site from Microsoft for this http://php.iis.net/
For good Performance also check out http://www.iis.net/expand/fastcgi
I can't give you performance statistics. Would guess that an extremely stripped-down version of Linux or BSD is best from that standpoint.
There are two main disadvantages of Windows. One is that you're likely to have to build some of the lesser-used extensions yourself, if you need them. (There are Windows builds of the common stuff - APC, etc. - available on the net for 32-bit, though. For 64-bit Windows... well, it's a jungle out there.) The other is that you're going to be in the minority, so expect all the things that go hand-in-hand with that. (If you run into configuration difficulty, for example, there will probably be fewer people able to help you.)
The advantage is that (especially if your favorite IDE is something like Visual Studio) you can run all your favorite Windows stuff on the machine. This is really only an advantage if this is, say, a development box - something you're going to use for other purposes as well, not just as a server.
If you are working in an windows environment, running your application/php scripts there makes a lot of sense if you want to debug locally.
I wouldn't use WAMP for production environments, because its nature is in linux imho.
XAMPP solves the sendmail issue amphetamachine is talking about by installing mercury mail.
It also comes with prebuilt xdebug, apc and memcache modules, which are for me the usual pecl compiled extensions.
An obvious problem with PHP on Windows/Apache is not being able to configure PHP APC for current versions of PHP. Hence, no way to create elegant file uploads with progress bar.
Most and main PHP developers (I mean, those that create the language) seem to work under Unix platform. Also, almost all Linux distros take care of building, packing and fixing PHP to suit their systems. And this also applies to auxiliary software like Apache. As a result:
There's always some functionality that doesn't work on Windows, e.g. strptime() or has more bugs.
Windows binaries are not optimized for your system. You can't even get 64 bit binaries unless you compile them yourself.
The MSI installers are not as polished as they should.
Installing PECL extensions is very complicate since there aren't official DLLs.
Of course, there's also Windows-only functionality in PHP, such as Windows only extensions or third-party extensions like the Microsoft SQL Server Driver for PHP, or functionality that's way easier to use under Windows, such as ODBC.
Talking about performance itself, it's difficult to make a fair comparison. The operating systems themselves have very different hardware requirements and it'd be misleading to compare optimized Unix builds with generic Windows binaries. My intuition says that the decision of choosing either platform should be based in other considerations, such as budget, required features or ease of maintenance.
There are many quirks across platforms with PHP, and I don't recommend switching between LAMP / BAMP / SAMP and WAMP / WIMP.
For one thing, permissions are completely different -> usually being a lot harder to work with in Unix/Linux (as Windows doesn't seem to care all that much about permissions as far as I have ever seen). This is a good thing, in my opinion, though (I'm relatively safety paranoid).
Here are a couple more things that differ:
http://php.net/touch (could't change windows directory modified times until 5.3)
http://php.net/flush (still can't flush or ob_flush from some win32 machines)
Both have system specific issues that were just SUPER recently worked out or haven't been fixed yet...

PHP, MySQL | Windows vs Linux

Well the title does the explaination. Which one is faster PHP/MySQL on Linux or on Windows.
Question 1
I know that MySQL is slower on Windows, because i tried to run a C++ program on Windows to access MySQL, it took a year every time it had to open a connection. When i ported the exact copy into the linux enviornment it was lightning fast.
Im not sure why the difference is, Maybe cause when we talk about Linux every thing is million times faster, but it would be good to know why such a massive difference.
Question 2
I have set up PHP on IIS and mySQL on Windows ive just tested a very small application on this setup and it seems fine. What i really want to know is that is there any performance issues for PHP in Windows rather than Linux?
Edit Windows Vista Was the OS i tried on Originally, Havent Tested W7. Fedora 10 was the Linux :D
They should be the same speed eventually. If you do an unscientific, unfair test, you might show a difference.
Process startup speed might be different. In particular, process startup might be slower on Windows. This shouldn't matter too much in production unless you're using a model which creates new processes on a very frequent basis, which will be inefficient on either.
Run a performance test of your actual application, with a large number of requests, over a significant length of time, on production-grade hardware. It's the only way to tell.
Needless to say, I can safely say that almost nobody chooses Windows vs Linux based on performance. Usually it's what they are capable of managing in production and have hardware / software support for.
If you're going to install 1000 boxes in production, Windows server licencing might get expensive (depending on your deal with MS). If you are only going to install a few, it probably doesn't matter (supporting the servers will be much more expensive).
Things are slowly getting better on Windows, with IIS 7 and PHP as a FastCGI ; see http://php.iis.net/
But I have never heard anything good about PHP + IIS6... Never worked in this configuration myself, though ; so I can't speak of experience.
One thing to consider is that Windows still (things are slowly getting better too) seems to be considered as a second-class citizen, when it comes to PHP...
And it's harder to get exactly the version of PHP you want (on Linux, you just recompile, and that's definitly not hard at all) ; even more for PECL extensions, btw...
As a sidenote : you can run PHP on windows with Apache ;-)
PHP is just about equally fast on Linux and Windows, variations among different functions.
PHP on linux used to support more functions Windows did not like pcntl_fork and socket_create_pair. It seems that with the release of version 5.3 those now works on both (from the PHP documentation).
I dont know about any speed difference between Apache on Linux vs IIS, or Apache on Linux vs Apache on Windows.
1) This is probably due to your mysql server trying to do a reverse lookup, and/or your DNS for localhost on the windows machine being incorrect.
2) PHP is the same speed, overall, however, the interface to it (apache module, cgi etc) may not be as fast.
Not sure what the issue was unless you had many of concurrent connections and/or were not running on windows server. There should be no noticeable speed difference between the two. There was something else going on in your program.

Apache vs. IIS PHP performance comparison

Does anyone know of any links to realistic performance comparisons of IIS vs. Apache for PHP hosting?
I am looking to utilise existing infrastructure for a change of technologies from .NET to a PHP application but I cannot find any information about PHP hosted on varying platforms. There is heaps out there about IIS vs. Apache in general, or ASP.NET vs PHP .. or any other language server vs server, language vs language but no server/language vs server/language.
My current direction is to use PHP with FastCGI.. looks pretty good. Just need to justify it or find a compelling reason to reject the big cuddly MS monster that I'm used to.
UPDATED
Windows environment would be Win2k3 running IIS6 with FastCGI serving the PHP extension. Also planning to use eAccelerator or similar script cache.
PHP Best Practices article -- Differences between PHP on WIMP and PHP on LAMP
Some of the differences you may encounter when developing with PHP on Win/IIS vs Linux / Apache.
The most obvious difference between WIMP and LAMP is definitely performance.
For years there has been an obvious performance advantage of LAMP over WIMP.
Only recently is their even a chance of closing that gap.
There are currently 2 projects underway that may help.
Currently available is IIS7 which is reported to have had PHP performance
enhancements built in with collaboration from the ZEND team.
An upcoming projects involves Microsoft engineers working with PHP engineers to get the next version of PHP (PHP5.3 which is not yet available at this time) to perform much better in IIS. This will no doubt make some progress toward WIMP catching up with LAMP in performance.
FastCGI on IIS will significantly increase the performance and will be comparable to that of LAMP. The difference will be in details, which are hard to pick and depends on what your configuration is and on what you scripts do. For example, file access on Windows is much slow than on Linux because of NTFS's ACL checks.
There is nothing particularly wrong with the Windows web stack. The only big reason I'd think of using Windows over Linux when human experience doesn't matter would be SQL Server. Otherwise WAMP, WIMP and LAMP perform comparably and performance differences won't show up until heavy load.

PHP website, should I develop into a Linux distribution instead of Windows?

In few months I start a project in PHP and I am hesitating to do like usual : develop on my Windows Vista 64bits machine. Since I know few things on Linux, I think it can be a good way to learn by working on a Linux distribution.
Do you think it's a good idea or not? I would run a VirtualBox with Ubuntu (on my Vista64bits). I was thinking to install XAMPP to be able to develop in PHP.
If you think it's a good idea, feel free to suggest me some tutorial about what I should know with Virtualizing an OS, or Linux/dev.
Update
I have build many website in PHP with Windows, the question is more about if it's a good way to start learning Linux by developing on it via a Virtual machine? I have 4 gigs rams, will it be smooth if I install Eclipse in the Virtual Machine? etc.
You should really develop on the same platform where you are going to deploy. I'm not saying it is bad to do differently, but it can save you some pain in the long run. OTOH, you might learn faster about platform differences that way. So, the main question is: do you want to have a production system running ASAP without much headache? Or, you want to spend some time and make some effort to learn how to develop cross-platform stuff?
And yes, there are differences. For example, case sensitive and case in-sensitive filenames. Then, some PHP functions use native C functions that have different implementation. For example, printf() does not produce the same amount of whitespace for some of the types. Resolution of time measurement (milliseconds vs microseconds) can be different, etc. Then, you have different ways filesystem permissions are handled. These are just some recent problems I've found that I can remember off the top of my head.
PHP should be the same on any platform - so where you develop shouldn't matter.
However, in my experience and observation,more sites running PHP are running on Linux than Windows.
Getting Apache and PHP setup on something like Ubuntu or Fedora is a cinch, and testing everything is pretty simple, too.
Also, when you go live with your site, what platform will it be running on? I prefer to do development on the platform it will be running on whenever possible.
Personally, I don't think that for local production you should be using a VM. Would you be running your IDE inside the VM too?
If you are aware enough of the pitfalls of moving between Windows and Linux environments (such as case sensitivity and permissions), you should have no problem developing on Windows and deploying on Linux.
Working on a Linux distribution is defnitely the easiest way to learn it. And setting up some servers and doing some dev work is an excellent start.
Virtualising Linux is also really easy. I've done it quite a few times and it's really obious. Also, going this way will ease you into using Linux, much better than just jumping in and finding out your wireless card is unsupported like I did :)
As for PHP development on Linux... I've done some PHP coding on Windows and on Linux and I can tell you there's very little difference between the two. I use Eclipse on both platforms and Apache &MySQL / XAMPP. The only major difference I've seen is that Linux is much more finicky about permissions and case.
PHP is not the same on all platforms, and until very recently the windows versions had problems which were not found in the Linux versions. Lots of useful features are *nix specific.
I would echo #Milan's sentiments about developing in the deployment environment. You learn a lot more about the deployment environment by doing so too.
On the VM issue, if you want all your Windows tools and your windows machine, setup a linux server in your VM (can have a GUI if you want, but you're going to mainly use it as a server). Set it up so that windows can view the apache install running in your VM and you use samba shares to access the vm's files like a drive in windows. That way, you develop in windows but are testing deploy / setup on a running linux server. While two devs at my shop run Ubuntu, a third needs to use Photoshop and various other bits of windows software all the time, so she uses this method of running a server in a VM but developing from windows.
Oh, and if you're running on Linux, don't use XAMPP! A few simple commands will have you up and running and you'll get a much better understanding of your deploy. XAMPP is fine, but it's for OS's that don't have Linux's package management.
while XAMPP works great, running Apache and PHP on Linux is a given; while on Windows it's something extra you have to do... and support. Also, most parts of the stack are far more optimised and mature for a POSIX environment. The database engine(s) performance is particularly sensitive to the available primitives.
Most OSS runs on windows, but it's a round peg whammed on a square hole.
On principle, I would advise against "learning by doing" in a real project - unless it it really small, or you have doen very similar projects before, so that the learning curve on project related issues would not be steep. In that case you may have ressources free for learning about the developing environment.
Generally I like the Linux environment better than Windows. Mainly because all the CLI tools you would need are provided and Bash beats cmd.ext any time. But with Cygwin I find even Windows a comfortable development environment.
Regarding PHP development I can't really see how it would be much different. Maybe there is some benefit in being forced to make the code more portable (things like line endings, forward slashes in filenames and such) if you use booth systems.
As a desktop or workstation there isn't much difference between the two. I find that the biggest differences lies in how you administer them, but hopefullt you have some other people doing that for you.
In my opinion you needn't to develop in a linux distribution.
Web Development can be done from any OS. I don't know, why you are programming for the web... as a professional? for your personal homepage?
I think, it's enough to get some free webspace running a PHP Server and to upload your files there... it doesn't take you much time and there are less things to manage.
a german student ;)
Use the OS your deployment server will be running, and it is highly probable to be linux. I have recently seen a deployment gone ultra bad cuz it was developed using wampserver and deployed on CentOS. With major differences in apache and PHP config. So know your deployment server and match it as closely as possible.
Try creating a development environment using VmWare Player. I have several Linux environments that I run on my Vista laptop. You could also just dual boot. I use Ubuntu, it is easy.
The side effect of developing inside a VM: more overhead and eventually the needs of additional tools to make the development more comfortable.
Often people need special tools for their development like Photoshop or some vector design tools not available on Linux. If the working copy of the project is inside the VM, it makes sense to have easy access to it. So you will setup SAMBA (which makes often problems with the login from XP) or setup SSL(SFTP)/FTP.
Also you must learn how to use networking with the VM (NAT, bridging, port forwarding).
On the other side, developing on another platform as the target can give some headache. I found myself often confused with .htaccess files for password protection, because oft the different path on Windows/Linux. If you forget to change this entries later on the production server, you have a problem...
A better solution: use the best of both worlds.
A VM eventually running later headless (no gui, more like a "remote server") with Ubuntu/Debian/FreeBSD) and only running the needed servers (Apache, MySQL, FTP, SSH...).
Eclipse or the other development tools on Windows/Mac.
5 years later: My opinion is to use the Linux solution. There are many advantages for using PHP in Linux. The primary reason is the level of help available from the community. PHP seems to be optimized for Linux environments as well.
There is also safety in numbers as an overwhelming number of sites are hosted and run with LAMP solutions. There are a wide range of frameworks and CMS' that run best on Linux with Apache2.
Make your life easier and start learning PHP straight away.

Categories