I’ve been having some problems with PHP and Apache 2 on windows recently. I would be doing some development work and refreshing the page to test progress and after some short time Apache would stall and require a restart. I tracked the problem down to using the binary module that comes with PHP. If that module was removed from the Apache configuration, the webserver would be just fine – but without PHP running.
So, I took a look at cygwin to see whether PHP could be made to work with it. I already had the Apache 2 webserver package installed, so all I needed was PHP. Looking at the official PHP packages, there is no support for PHP. After some searching around the net I found a blog called Cygwin Ports. This is linked to a sourceforge project and it has a PHP 5.2.5 package for cygwin.
Installing packages from Cygwin Ports was as easy as adding the URL ftp://sourceware.org/pub/cygwinports to the cygwin server list. So, I followed the instructions for including their package, installed PHP and wrote a quick test script using only phpinfo():
<?php phpinfo(); ?>
I typed http://localhost/index.php and Success!
The next step was to get something more complex working, specifically CMS Made Simple. But I’ll leave that for next time.
Very useful !
Thanks a lot !
____________________
Saguenay-IT, (IT Outsourcing, SOA, PHP, ASP, Flex, ActionScript, JavaScript…)
Hi Gareth,
For the installation, I followed everything as mentioned at
http://www.mail-archive.com/cygwin-ports-general@lists.sourceforge.net/msg00234.html
but my index.php which contains phpinfo() does not work.
Is there anything else that I should pay attention to?
Thanks.
Assuming you are using the Apache webserver, double check your apache.conf and make sure you have the correct directives. Here is a good reference: http://www.alt-php-faq.org/local/2/
If all looks ok, check your error.log for any messages indicating the problem.
sunsite.dk seems to be dead.
You should now use ftp://sourceware.org/pub/cygwinports
Saggi, thanks for the updated URL. I’ve modified the post.
FYI, cygwin setup tells me ftp://sourceware.org/pub/cygwinports has a corrupt setup.ini, assumes it’s a corrupt mirror, and won’t connect to it.
I suggest trying again in a few days and see if it has resolved itself. If not, get in touch with the cygwinports project to ask for help.
What do they mean here http://sourceware.org/cygwinports/ when they say that every time we update our installation we must visit our preferred Cygwin mirror and then the Cygport repository? If I don’t need anything from the Cygport repository, what do I do when I am there? If I just need something from the Cygport repository, what do I do when I visit my preferred Cygwing mirror and I have nothing that I want to download from there?
The previous post was one point only, perhaps a small point. In general, what is missing is a good documentation for the installation of the CygwinPort PHP package. Here are the items I expect in this documentation:
1- On which versions of Windows the package has been tested.
2- The exact description of the packages to extract from Cygwinports: the name of each package that we need to check (i.e., have a cross in the corresponding box) and whether we want the source or the binary.
3- What actions must be done with these packages. This includes the 5 steps here http://sourceware.org/cygwinports/ (which should be clarified as pointed out in the previous post). It should also include the answer provided to Min by Gareth.
I went through the installation the best I can on Windows Vista and I cannot manage to have Apache recognize my php file as a script. Also, when I call php.exe from a cygwin shell or from a command prompt, I got a long list of warnings that dll’sare missing.
I came across your article on how to install PHP for cygwin and was baffled by the corrupt setup.ini problem that Colin mentions as well.
Quite by chance, I stumbled across the Cygwinports FAQ on the sourceware website and the instructions provided there worked perfectly – http://sourceware.org/cygwinports/
Short version – the cygwin setup now accepts only signed setup.ini files and the sourceware file isn’t. The sourceware FAQ tells how to fix this
I finally have PHP working inside Cygwin!