News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[Unknown]'s Guide to Installing PHP and MySQL.

Started by [Unknown], November 16, 2003, 03:40:49 PM

Previous topic - Next topic

[Unknown]

A better version of this can be found here:
http://unknown.network32.net/tutorial.basic-server



Often people suggest that you use pre-built packages to install PHP, MySQL, and Apache.  And this is fine, and often a good idea.
However, if you're like me... you want cutting edge technology so you can have everything up to date.  These packages, on the other hand, are usually behind, and make it hard to control your own server.

So here I will post essentially two guides - one for IIS (Internet Information Services), and another for Apache.  While Apache is more powerful than IIS, I would recommend that *for some of you* IIS might be easier to use and configure.  I personally use it because I know that if it works on IIS it will work on Apache. (whereas Apache has features IIS does not.)

To quickly jump to a section, click one of these:
   - Installing PWS
   - Installing IIS
   - Installing Apache (recommended if you are experienced.)
   - Installing and Configuring PHP
   - Configuring PHP with IIS/PWS/Apache
   - Installing MySQL
   - Testing and Upgrading

After you've done all that, you might want to:
   - Learn something about MySQL

-[Unknown]

[Unknown]

#1
To install PHP and MySQL using IIS you will need one of the following versions of Windows:
- Windows 95, 98, ME, NT. (using PWS, which is a stripped down version of IIS.)
- Windows 2000 Professional, 2000 Server, XP Professional, 2003 Server.

Installing PWS

If you are using Windows 95, ME, or NT... you will need the NT Option Pack.  This "option pack" includes Personal Web Server - PWS - which will allow you to host yourself.  It can be found here:
http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk/default.asp
You will need to download this and run setup.

On Windows 98, it is included on the installation CD.  Insert your Windows 98 CD, and choose "Browse This CD."  Go into the folder "add-ons" and then "pws".  Now run setup.exe.
If you do not have your CD, you can download the option pack above, but beware it can be a long and annoying download.

You may also want to pursue this knowledge base article:
http://support.microsoft.com/support/kb/articles/Q246/0/81.ASP

Now that you have the setup started....
Go into the setup and click "Custom".  Now make sure Transaction Server and Personal Web Server are checked...which should be default... and click continue.
I would recommend using C:\Inetpub\wwwroot as your "WWW Service" directory, but it's really up to you.

And now you should be done.  Skip down past the IIS and Apache tutorials to "Installing and Configuring PHP".

-[Unknown]

[Unknown]

#2
Installing IIS

Installing IIS is remarkably easy.  Don't sweat it.
First, go to Start -> Control Panel.  Now select "Add or Remove Programs".  On the left, select Add/Remove Windows Components.  After it loads, scroll down to and highlight Internet Information Services (IIS) and click Details...
Make sure Common Files, Internet Information Services Snap-In, and World Wide Web Service are selected.  Now click install and wait, all should be fine in moments.

If you have Windows XP Home Edition

This gets tricky for the Home edition.  You'll have to have an install disk for XP Professional or one of the other OS's that do include IIS.  And here's a guide on how to do it:
http://www.developersdex.com/asp/message.asp?p=577&ID=%3C3c3c9b9d%2E518663173%40news%3E

But I do not recommend this.  If you are using Home, you most likely should just go ahead and use Apache.  It's better anyway.

Now that you're done - skip to "Installing and Configuring PHP".

-[Unknown]

[Unknown]

Installing Apache

First off, download the appropriate version from here:
http://httpd.apache.org/download.cgi

I would recommend Apache 1.3.* instead of Apache 2.0.* only because I've heard 1.3 is more stable - for PHP at least.  I am not sure though, so take your chances if you want.  You can always uninstall, right?  But, this is probably the file you want:
http://apache.towardex.com/httpd/binaries/win32/apache_1.3.29-win32-x86-no_src.exe

Once you have the installer up and running, click:
Next >, accept (do read it, please.), Next >, Next >..
Now type in a domain, I would recommend you use the default (hopefully?) or just something you know won't be a real domain.  Like "localdomain".  Server name might best be "localhost.localdomain".  Email can be whatever you want.  I also recommend STRONGLY that you run it as a service for best testing.
Now select Complete and continue.  Keep hitting Next and then Install.  Now hit Finish after a couple minutes or seconds.

Now open Internet Explorer or your favorite browser and type this into the location bar:
http://localhost/

If all was successful, it should show a test page with an Apache icon.

-[Unknown]

[Unknown]

#4
Installing PHP

This isn't really too hard.  There's not *that* much you have to do.  So go here:
http://www.php.net/downloads.php

Now get the zip file for the latest PHP 4 for Windows.  PHP 5 is also available, but as of writing it's a bit too bleeding edge.
I recommend, personally, that you unzip it to C:\Program Files\.  However, most people just extract it to C:\.  It's your choice.
Rename the "php-4.x.x-Win32" folder to just PHP.  That will make life easier ;).  Less typing ;).

Configuring through php.ini

(if you're using NT or 2000, change "C:\WINDOWS" below to "C:\WINNT")

While the installer will do some of this for you, it's not as complete as the zip file and really botches up the whole process imho.  So we're gonna go and do it manually.  Bare with me, it's easy.
Okay, so go into your PHP folder - whereever you put it - and look for php.ini-recommended.  That's the one both I and they recommend ;).  Rename it to php.ini, and copy it into the C:\WINDOWS directory.  Now open Notepad, and tell it to open that file.  (you will have to select all.... or if Windows is still configured by defaults, just double click the file.)

You'll have to use Find a lot here.

------ This part is for IIS/PWS only!! ------
So hit Ctrl-F and type in ; cgi.force_redirect = 1.  When you find it, change it to cgi.force_redirect = 0.  Make sure that's the whole line.  This makes it so PHP won't make sure Apache is running when it executes php.exe - basically, it's very important for IIS/PWS. (you're removing the semicolon ;).)
Now scroll to the top again and continue.
------ Alright, the rest is for everyone again. ------


Now press Ctrl-F and type extension_dir = "./".  When you find it, change it to extension_dir = "./extensions/".  Next find ;upload_tmp_dir = and change it to upload_tmp_dir = C:\WINDOWS\Temp
Press Ctrl-F again and this time type session.save_path = /tmp and change it to session.save_path = C:\WINDOWS\Temp.
Scroll back to the top again, and hit Ctrl-F.  This time search for display_errors = Off and change it to display_errors = On

Okay, we're done editing php.ini.  Yea.

This last part differs from most instructions - so I'll tell you both, and you can decide.  I suggest that you copy "php4ts.dll" from the PHP directory into the "sapi" directory, but the PHP manual says to copy it into C:\WINDOWS\system32. (system on 95, 98, and ME.)  Windows will find it in both places, so it's really your choice - I prefer not to "pollute" my system32 directory.

Now, this part is important only if you're using NTFS.  You probably are if you are on 2000 or XP.  Go to the folder C:\WINDOWS\Temp and right click on it, and select Properties.  If you don't see a Security tab, close it and go to Tools -> Folder Options in the menu.  Go to the View tab, and uncheck the "Use simple file sharing" checkbox at the bottom of the list.  Now go to Properties again.

On the security tab, click Add... and type Everyone in the box.  Select them in the list, and make sure they have Modify, Read, and Write permissions.  You probably have to do this to the PHP folder too, but not in all cases.  (so try it if you have problems later.)

-[Unknown]

[Unknown]

#5
Whatever you're using... copy the file php4ts.dll from the PHP installation directory into PHP\sapi.  Then...

Configuring PHP - PWS

Open up the folder you put PHP in, and look in the "sapi" directory.  See the two .reg files in there?  Pick one, and open it with Notepad.  It will say [PUT PATH HERE] - change this to C:\\Progra~1\\PHP or C:\\PHP. (or where ever, just double up the slashes.)
Now save and double click the file.  Confirm it, and then open the Personal Web Manager (it should have installed a shortcut..) in which you should click Advanced, and then select <Home>, Edit Properties..., and check Execute and Scripts.

Configuring PHP - IIS

In IIS 6 (2003 Server), you will need to go to Web Service Extensions, right click the open area, and select Add...
Name it PHP or something, and add C:\Program Files\PHP\sapi\php4isapi.dll...
Check "Set extension status to Allowed" and click OK.

Open up Internet Services Manager (2000) or Internet Information Services (XP, 2003.) from the Administrative Tools menu under Control Panel.  (it's in other places too.)  Right click on Default Web Site and open up Properties.  Click on the Home Directory tab, and change Execute Permissions to "Scripts only".  Next, select Configuration... click Add, and type the path to sapi\php4isapi.dll - like "C:\Program Files\PHP\sapi\php4isapi.dll".  (you can also browse for it.)  In extension, put .php and make sure both Script Engine and Check that file exists are checked.  Click OK several times and you should be set.

Configuring PHP - Apache

Go into the folder C:\Program Files\Apache Group\Apache\conf (or where ever you installed Apache.) and open up httpd.conf.  Search for #LoadModule mime_magic_module modules/mod_mime_magic.so and add just above it LoadModule php4_module "C:/Program Files/PHP/sapi/php4apache.dll".  Next search for AddModule mod_setenvif.c and add below it AddModule mod_php4.c.  Next, search for AddType application/x-tar .tgz and add below it AddType application/x-httpd-php .php

-[Unknown]

[Unknown]

Installing MySQL

This one's easy, folks.  First off, go to MySQL AB's website:
http://www.mysql.com/downloads/mysql-4.0.html#windows (you may have to scroll down to find the Windows download.)

Pick the one with the installer, and let 'er rip.  It's just a bunch of clicking next... and you're done.  It'll setup a WinMySQLAdmin program, but you can close it and remove it from the Startup folder if you want.

Now we should be ready for... testing!

-[Unknown]

[Unknown]

#7
Testing the whole deal out.

Before testing it or anything, you'll most likely have to restart.... so do that first.

Open up Notepad, and type in:
<?php
phpinfo();
?>


Now save it, using the filename for your specific server - in IIS and PWS, this is "C:\Inetpub\wwwroot\phpinfo.php" (unless you changed it..) and on Apache it's "C:\Program Files\Apache Group\Apache\htdocs\phpinfo.php".  Remember the quotes, those are important!

Now that you've done that, open up a new window in your favorite web browser.  Type in the location bar:
http://localhost/phpinfo.php

If everything went well, you should get a screen with a PHP logo and other fun stuff.

Upgrading to new versions

This is easy - don't worry.  For PWS, don't worry - they never plan to release a new version :P.  For IIS, it's easy... just upgrade to a new version of Windows.
For Apache, just install the new version over your old.  I would check the httpd.conf file to make sure it didn't undo anything, though.  PHP is just as easy - just extract the zip, and copy it's contents into your PHP directory - and remember to fix permissions if you're on NTFS.  MySQL is as simple as downloading the installer again and clicking Next a few times.

Happy goings!

-[Unknown]

Aquilo

alright!!!

well after going through your tut for IIS and making shure everything was right and it still failed to be accessable from the net I installed Apache over php and mysql and so far everything works great!

I would like to add one thing so .php files can be directory indexs too with out a .htaccess file in each directory

in httpd.conf find

<IfModule mod_dir.c>
    DirectoryIndex index.html
</IfModule>

and add DirectoryIndex index.php so it looks like this!
<IfModule mod_dir.c>
    DirectoryIndex index.html
    DirectoryIndex index.php
</IfModule>

thats my one cent!! ;D
thanks [Unknown]!

oh one other thing how can I make Apache add the trailling forward slash so something like
http://aquilo.homeip.net/community

will still go to
http://aquilo.homeip.net/community/

thanks again!!

zoki

Personally, I wouldn't bother using IIS at all.

[Unknown]

Quote from: Aquilo on November 17, 2003, 05:42:19 AM
well after going through your tut for IIS and making shure everything was right and it still failed to be accessable from the net I installed Apache over php and mysql and so far everything works great!

More is required for over the internet, but it should work locally.

Glad you got it working.

zoki, for the purposes of a personal server for testing, IIS can be easier.

-[Unknown]

Acf

thanx :-* i will try it when ive got some time to spare :)
Sigh...

Parham

I have to hand it to you Unknown, you're doing a great job with these, and at least getting some content in here while I'm busy doing my other things.  I wanted to thank you for that :)

blar

or use

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.htm
</IfModule>

Acf

some how the php doesnt seem to work :(

This what i see and not the phpinfo :(
<?php
phpinfo
();
?>



Does anyone know what i am doeing wrong??

*acf

ps: i am running windows 2000 pro.
Sigh...

[Unknown]

Quote from: </Acf> on November 23, 2003, 01:18:45 PM
some how the php doesnt seem to work :(

This what i see and not the phpinfo :(
<?php
phpinfo
();
?>



Does anyone know what i am doeing wrong??

*acf

ps: i am running windows 2000 pro.


Did you configure using IIS or Apache?

-[Unknown]

Acf

oeps sorry forgot to put that in my post.

Apache. :)
Sigh...

[Unknown]

Admittedly, I haven't tested that yet.... most of that was from the PHP manual somewhere.  Although it made sense.

Apache 1 or 2?  Did you remember to add AddType?  Have you restarted Apache (probably your whole computer..) since you changed the conf file?

-[Unknown]

Acf

Quote from: [Unknown] on November 23, 2003, 02:17:09 PM
Admittedly, I haven't tested that yet.... most of that was from the PHP manual somewhere.  Although it made sense.

Apache 1 or 2?  Did you remember to add AddType?  Have you restarted Apache (probably your whole computer..) since you changed the conf file?

-[Unknown]

I have rebooted my pc and now it works like a dream thanx [unknown] :) you are the greatest!  :-*
Sigh...

blar

if you open the file with the browser over the webserver you see the php code?

Advertisement: