Archive for February, 2008

How to install PHP on Apache running under Vista

February 19, 2008

After finally getting Apache running on Vista after some serious brain dramage, I moved on to getting PHP running… certainly better than Apache, but only because of some helpful instructions from others… 

More incredible thanks to:
http://senese.wordpress.com/2007/06/06/install-php-5-under-apache-22-and-windows-vista/#comment-262,

 However, after carefully following the instructions, and reading thru the comments, I still had a big issue: 

I couldn’t get the php test ( phpinfo ) page to come up! I was getting an HTTP 500 error (internal server error) and finally decided to try one of the wierd fixes suggested on the post above. It worked!

Joe Orr’s suggestion to add a backslash to the end of the ini path fixed the problem! Seems kinda lame to me, but change

PHPIniDir “C:\PHP”
to
PHPIniDir “C:\PHP\”

UPDATE:So, it appeared everything was fine after the ending backslash was added… php loaded and I could successfully see the phpinfo page. However, for the next step, when I wanted to get mySQL loaded, it was apparent something was still seriously wrong. When examining the phpinfo page, I could not find the mySQL module loaded (or for that matter, any of the other extensions that should have).

 I carefully looked at the Apache configuration file, and the PHPIniDir was specified correctly as above, and the the php.ini file had the correct entries for mySQL:

extension=php_gd2.dll
extension=php_mysql.dll
extension=php_mysqli.dll

 After some hunting around I found some suggestions to look at the path that php was actually using –

at the very top of the phpinfo page there is an entry for Configuration  File (php.ini) Path. My showed ”C:\Windows”.  Right below it is an entry for “Loaded Configuration File” which also showed C:\Windows. Definitely not good.

Additionally, I checked the entry in the php core section  of the phpinfo page for “extension_dir” and it showed “c:\php5″. Also not good!

The solution? I know this sounds incredulous, but you have to change the Apache config file to have forward slashes!

So rather than use: 
PHPIniDir “c:\php\”

use :

PHPIniDir “c:/php/” 

Even tho the phpinfo page still shows the Configuration File Path to be “c:\windows”, now the Loaded Configuration File correctly showed “c:\php\php.ini”. Also phpinfo now correctly showed the entry for extensions:

 extension_dir c:php\ext.

The good news, now I could see the mySQL module lower down in the phpinfo page, so I knew I was good to go. I still had not loaded mySQL, but at least php would be able to talk to the server when I get it installed!

As a side comment, there was not any discussion in the post I linked to above about why or why not he chose to load the various php modules he did, and I didn’t take a lot of time to check them out. I did not load a few that seemed unnecessary, and it seems to still be working fine, tho its probably a good idea to load what he specified, or look though each one so you know what it is doing. 

Even though I am technical, and have been an on and off programmer for 30 years now, I still just don’t get why software companies (even open source ones) make it so darned ridiculous to get a “standard” configuration running.  Yes, I understand why we need all the great flexibility, but let’s face it, most of us have much better things to do with our time than figure out why a page won’t load because there is no backslash on the end of a configuration line!  (Update: or because in this case you use a forward slash not a backslash!) OK, I’m whining a bit, but I guess I’m due after a whole day just trying to get an Apache web server up and running on Vista…

I thought I would also pass on that I just ran into something called WAMP, which may be worth exploring if you have not yet got your install working, as it is supposed to install Apache/MySQL/PHP onto Windows all at once! Anyone have any experience with this? I’m  a little gun shy at this point after all the time spent (and the fact it is working) to want to chuck it and start over, just to get the mySQL piece. I’ll post on my mySQL experiences if I find that to be a pain too.

Happy installs!

Smitty

How to Install Apache Web Server on Vista – and Avoid Problems!

February 18, 2008

Ok, we all know Vista is a pain, but sometimes we gotta use it anyway. If you want to install Apache on Vista, hopefully these step by step instructions will help save you some of the brain damage I went through.

Thanks to other forums, in particular to:
http://senese.wordpress.com/2007/06/06/installing-apache-on-windows-vista/

Even after helpful forums, I still ran into some issues that I hoped I could clarify for others. There’s one remaining issue I haven’t been able to solve, and will post if I can fix it:

I can’t get Apache to listen on port 80. I get an error during install (in the command prompt which goes away) indicating that it can’t allocate port 80, but it doesn’t seem to post the details in the error logs I can view later. I’ve looked using the command “netstat –ao”, and there does not appear to be any applications bound to port 80. The only thing I can figure is something with my Vista firewall – just out of time and need to get some stuff done, so using another port number: 8080.


In any case, here’s the steps I used to succesfully install Apache 2.2 on Vista Home Basic:
I. First uninstall old installations of Apache Server. 1. There’s a few ways to run the unistall:

a. Re-run the Apache installer. It will go into unistall mode.

b. Start > Control Panel > Programs and Features

2. Delete remaining installation files.
I really strongly recommend deleting old files that Vista probably did not remove during the unistall. Delete the whole directory “Apache Software Foundation”.

a. It turns out this is a pain due to Vista permissions on the “Program Files” folder where Apache installs by default.

b. Run the command prompt in administrator mode (this is critical) by right clicking on Start>All Programs>Accessories>Command Prompt and “run as administrator”

c. There may be a much easier/smarter way to do this, but I had to go to each sub directory within “Apache Software Foundation” and “del *.*” then “cd ..” and then “rd ‘directory-name’” to get everything removed. Yes, it is a pain.

II. Now do a fresh install of Apache Web Server as follows:

1. Stop any other services that use port 80. Skype and IIS would be two examples. Set them up to use other ports. In Skype, go to Advanced Options > Connection and uncheck Use Port 80.

a. I used “netstat –ao” in the Command Prompt to show the process bindings to port numbers.

2. If you don’t like the incessant nagging from Vista, stop the User Account Control by Control Panel > User Accounts > Turn User Account Control on or off.
(You can always turn it back on if you want.)

3. Get the most recent version of the Apache Win32 binaries from http://httpd.apache.org/download.cgi and put it on your desktop. Rename it to “apache” (without changing the .msi extension, if that’s showing).

4. As before, run the Command prompt in administrator mode:

a. Right clicking on Start>All Programs>Accessories>Command Prompt and “run as administrator”

5. Change to your desktop folder directory “ cd desktop”

6. Run the installer in administrator mode:

a. At the prompt, type: msiexec /i apache.msi

b. This is critical, or you will have some other security/permissions issues later.

7. Answer the questions in the Apache installer dialogs.

a. I strongly recommend you do NOT use the default directory for the install. I chose “c:\apache”. Otherwise it will put the install in the Program Files directory and you will have serious permissions issues. You will not be able to use the Apache tools on the start menu to edit the configuration files! You will have to edit them manually in administrator mode using the command prompt, which is a pain…

b. If you are running a server live on the Internet, you will have to make sure all your domains are correctly specified. Ie, yourcomputer.yourdomain

c. If you are running a stand alone web server like I am, ( a test server or a development server) you can either leave the domain and server name blank, or you can enter “localserver”.

d. You must specify an email address. I made something up.

e. I first tried choosing to run in manual single user mode and specifiying a different port since I knew I was having issues on this port, but found this didn’t work well. So during my reinstall, I chose the default /all user mode on port 80.

8. After the install completes, I did get an error about port 80, and so I had to edit the Apache config file to change the port number due to the problem I listed at the beginning of this post.

a. I did this via Start Menu> All Programs> Apache HTTP Server 2.2> Configure Apache Server>Edit the Apache httpd Conf iguration File

b. Change the “Listen 80” to “Listen <portnumber>” I used “Listen 8080”.

9. Reboot.

10. Browse to http://localhost. It should say “It works!” If it doesn’t, check your httpd.conf file by going to All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Test Configuration. Follow the directions for fixing the configuration file.

11. I also wanted to setup the default directory for my webpages to something other than where Apache expects them. Who wants their website under the directory htdocs?! Anyway, I wanted them in my own directory elsewhere on my server so I brought up the configuration file as shown in step 13, and edited it as follows .

a. I changed DocumentRoot “C:/apache/htdocs/” to DocumentRoot “C:/localwebsites/siteXYZ/” where my site XYZ’s files were. (OK that really is not the name – but you get the idea!)

b. You also have to change the entry “Directory “C:/apache/htdocs/” to the same new directory: DocumentRoot “C:/localwebsites/siteXYZ/”

c. I copied the Apache index.html file from their htdocs directory into my “siteXYZ” directory, but you could use any index.html file you have to test the config file is setup correctly.

12. You can turn User Account Control back on if you want, via the control panel as before.

I have not addressed installing mySQL and PHP, but don’t want to clutter these instructions at this time.

Hope this helps!

Smitty