You can set up Apache, MySQL, and PHP on a Windows
operating system fairly easily. Why would you want to do this?
To be able to develop, test, run, customize php and database pages
before uploading to your webhost. This probably only applies
to us who have Unix based webservers not running Windows based stuff
like asp. For what I do, the 'nix side of things is just fine. A
lot less expensive. As in, free.
You can also set up Apache to run CGI scipts, but this
page focuses on PHP and MySQL.
I started off with a program called: FoxServ which
is pretty cool. It uses older versions of
Apache, MySQL, and PHP, in a package with a Control Panel applet that
runs all the services. However, I wanted to update to all
new versions, mostly to do it, and to try to keep abreast.
If you'd rather start off with FoxServ, there's nothing wrong with
it really, and it has an easy installation and interface built in,
but if you'd like something more current... read on.
It seems like it's a long set of instructions, but it's only one page. ;0) And it works.
First, download these programs:
PLEASE NOTE : If these particular files have been upgraded,
go with it. I don't really have the time to update every page on my site when
a program or past tip becomes dated. (for the guy who just
'yelled' at me because he can't find an older file) The main steps are the same.
Apache
Webserver
for Windows Get this file: apache_2.0.58-win32-x86-no_ssl.msi
PHP Get
this file:
php-4.4.2-Win32.zip
MySQL Get
this version: mysql-4.1.20 (there is an alpha verion 5 out, up to you)
NOTE: After you install this, you may receive the error: 'Client does not support authentication protocol requested'. It is because the newer versions of MySQL (4.1+) upgraded the process used to authenticate users. GO HERE for instructions on how to deal with that after the installations.
phpMyAdmin get
this file: phpMyAdmin 2.8.1.zip
MyODBC-3.51 Install this when you're done with the above.
I run SSL also,
and have generated my own secure certificates so I can develop and test .php driven catalog sites on my own computer. Saves countless hours once you get everything set up. This is a whole new side, so I'll not deal with that here. However, if you're interested, try here:
Apache / SSL / Win32 It's not really all that difficult, if you follow directions.
Install all programs before configuring
their respective config files, and we'll get to that later.
- Keep in mind, Apache is case sensitive on file
names, so ensure your folder and file names are like these below.
- Double click on the apache_2.0.58-win32-x86-no_ssl.msi file
to begin installation.
- Choose the Custom option so you can access
the installation path.
- Change the installation folder path
to: C:\ instead of
the default install path: C:\Program
Files\Apache Group\ and you can
run the whole localhost system closer to the root directory when
it's all installed. If
you've done this right, you'll see C:\Apache2 in your list
of folders under Drive C: in Windows Explorer, and it will have
the following sub-folders under that: bin, cgi-bin, conf, htdocs, and
more.
- Along the way, you'll encounter a screen asking for the Network Domain, Server Name and Admin Email. I used: 127.0.0.1 for Network Domain, localhost for Server Name, and my personal email address. The email address is used to send yourself emails when Apache encounters errors (while you're connected to the internet), so you don't really have to use your real address if you don't want to receive emails.
- When the Apache Installation is finished, it
will automatically start, and place a shortcut to the Apache
Webserver Control Monitor in your
Startup Folder and an icon in the System Tray, allowing you access
to the Services panel for starting and stopping Apache. The Monitor is NOT Apache, it is the 'control panel' for starting and stopping the Apache Service from the System Tray. I
don't particularly run php stuff all the time, so I put a bosh on
that by removing the Monitor from Startup Folder.
You can manually start the Monitor by running: C:\Apache2\bin\ApacheMonitor.exe. from Start / Run . Click on the Feather icon in the System Tray to Start and Stop Apache Services.
{ I made a small batch file to start the
services with one click. You can download it HERE. If
you don't use the same folder names that I do, you'll have to change
the path in the. bat file. I put this file in my C:\ directory,
so all paths are relative to that, all changeable. Then I made a
shortcut to the startup bat in my Start Menu. You can change
the icon of the shortcut, also. Mine is [creatively] the Apache
feather from the Apache.exe file in C:\Apache2\bin\. ;0) } There are a couple programs out there that will stop a program, not just the service, so you can create a bat file to stop the service, then invoke the stop program command, and it's all one click. ;) ( Name of program to stop programs: pskill ~~ For some reason, and I'm not sure why, Network Associates has called this a potential virus file. heh. Rename it to whatever you want, if you're the paranoid type, but it works well to kill programs ) Here's another .bat file using pskill to stop both services and then their control applets. I renamed pskill.exe to something else, then adjusted the batch file accordingly.
___________________________________________________
- Next, unzip the php-4.4.2-Win32.zip file
to a folder on your Desktop. Inside is another folder named php-4.4.2-Win32.
Rename the inner folder
to: php and move this entire php folder to C:\ so it looks like
C:|php
under Windows Explorer
___________________________________________________
- Unzip mysql-4.1.20-win.zip to
a folder on your Desktop.
Run the Setup file in the unzipped folder to begin MySQL installation.
Again make sure the default
folder MySQL installs to is: C:\mysql
I started using MySQL with a monitor program called: WinMySQLAdmin I notice it hasn't been included in the last few releases, so I have it up for download here: CLICK HERE FOR WINMYSQLADMIN
I place this in the c:\mysql\bin folder and use it in my startup scripts.
- Last, unzip the phpMyAdmin 2.8.1.zip file
to a folder and rename it:: phpMyAdmin and
move it to C:\Apache2\htdocs\
If you look at the contents of Drive
C:, you should now see these folders among the list:
C:\Apache2
|-bin
|-cgi-bin
|-conf
|-error
|-htdocs
|-phpMyAdmin
|-icons
|-include
|-lib
|-logs
|-manual
|-modules
|-proxy
C:\mysql
|-bench
|-bin
|-data
|-Docs
|-Embedded
|-examples
|-include
|-lib
|-scripts
|-share
C:\php
|-cli
|-dlls
|-extensions
|-mibs
|-opensll
|-pdf-related
|-PEAR
|-sapi
Now look at the Services window
(Control Panel / Administrative Tools), see that the Apache2
service is set
to Manual and the MySql service is set
to Manual. They
should start with the startup.bat file.
Installing PHP
Some extra DLLs are required for some PHP extensions.
There is a file called: install.txt in
the php folder that will help, but basically it says this:
- Navigate to the C:\php folder
containing the unzipped files.
- Copy the bundled dlls from
the C:\php\dlls directory
to your WinNT/System32 directory.
- Move the php4apache2.dll file
located in the C:\php\sapi folder up one
level to: C:\php
- Copy [C:\php] php.ini-dist to
the WinNT folder,
and rename it to [C:\WINT] php.ini
Now we can set the configuration files, pretty straightforward stuff.
- With both Apache and MySQL services Stopped,
navigate to the C:\Apache2\conf folder
and open httpd.conf with
any text editor. Use Search to locate this string: ServerRoot not
too far down. You'll want to make sure this is
set to:
ServerRoot "C:/Apache2"
exactly as it is, with no trailing slash.
- Search for the string: DocumentRoot and
make sure this is:
DocumentRoot "C:\Apache2\htdocs"
(This is where your website root directory will be
located. I have
my webfiles and folders under this directory, and all are accessed
with a browser by typing in: http://localhost/whateveryourfile.htm . http://localhost
is the root address)
- A little further down this file, you'll see the LoadModule lines.
Add this line to the END of the list:
LoadModule php4_module "c:\php\php4apache2.dll"
- Last edit is to search for : AddType and
add this line verbatim:
AddType application/x-httpd-php .php
- Save and Exit httpd.conf
- Modify C:\WINNT\php.ini in three places (you
can use Notepad):
1)Search for:
; Windows: "\path1;\path2"
;include_path =
Change to this:
; Windows: "\path1;\path2"
include_path = ".;c:\Apache2\include"
20 Search for this string:
doc_root =
and change it to this:
doc_root = "C:\Apache2\htdocs"
3) Below that you'll see
Directory in which the loadable extensions (modules) reside.
Just below that line, change the :
extension_dir=
to
extension_dir = "c:\php\extensions"
3) Save and Exit php.ini
- Navigate to C:\Apache2\htdocs\phpMyAdmin and
open config.inc.php with
favorite text editor.
- Do a Search for the string: $cfg['PmaAbsoluteUri'] and
make sure this is what it says:
$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin/';
- Search for this string: $cfg['Servers'][$i]['user'] and
put this line there to start:
$cfg['Servers'][$i]['user'] = 'root';
- The very next line: $cfg['Servers'][$i]['password'] is
where you'll add your Administrative password.
$cfg['Servers'][$i]['password'] = 'your_password_here';
Replace: 'your_password_here' with 'your password'
, quotes included.
- Save and Exit config.inc.php
For more information on Configuring phpMyAdmin, open up: C:\Apache2\htdocs\phpMyAdmin\Documentation.html
Starting up the Server to see if it works
It seems that both Apache and MySQL install themselves as autostart services. You really don't need this unless you're running the services all the time. So, I set them to 'Manual' in Administrative Tools / Services section.
First, please remember that if you make any changes to anything in the Apache, PHP, or MySQL programs, you must restart the service for the changes to show.
Second, remember that all slashes are forward -> / in Apache and your browser window, so copying a windows (backslash) path from Explorer into the browser won't work.
Here's
a zipped file
that contains a .bat file to start MySQL, ApacheMonitor, and Apache Server , one
click..
- If you have both green lights, open a browser and
type or paste this into the Address bar:
http://localhost/phpMyAdmin/phpinfo.php
Your browser should open a page displaying all of your Apache / PHP
/ MySQL basic information. If you get this page, you've done
everything right. If not... time to double check all
steps above, and possibly Google for more answers. These steps
worked for me, but I'm lucky. Also, if you're experiencing
very much weirdness on Windows XP with this page and Internet Explorer,
check this out.
-
Now, paste this into the Address bar:
http://localhost/phpMyAdmin/index.php
You should now be logged into your MySQL database administration frontend
where you can set the passwords and permissions for each user.
Easy Access to your localhost web based files
I made an index.html page for Control Central with a menu of
the links to phpMyAdmin,
PHP Info, and my other trial programs, like PHP-Nuke,
and a PHP powered email form, etc. so I can easily
access those files for testing live.
Place
this index.html file into
C:\Apache2\htdocs\ replacing
the original one (which is just a 'Welcome to Apache' splash
htm),
and
access it by typing:
http:\\localhost in
your browser's address line when Apache and MySQL are running.
If you can't import a .txt file to update your database after all
this, shut down the MySQL service, add this to your my.ini file
in the WINNT folder, restart MySQL and give it a shot.
Under : [mysqld]
add this:
set-variable=local-infile=0
I'm currently running:
- Apache/2.0.58
- PHP/4.4.2
- MySQL 4.1.20.-nt
- phpMyAdmin 2.8.1
- Perl 5.8.7.815
|