You are using a browser which is not compatible with CSS (for more information, see Tara's tutorial).
Because of this, it is possible that our website may not appear
correctly in your browser. We apologise for the inconvenience, and
recommend you upgrade your browser to one which is compatible with CSS.
For more information, please visit our Browser Upgrade page.
This is intended for the dial-up user, who pays for their access per minute lets say, but is applicable to anyone who does a lot of coding and designing for their site, and would like to test it immediately, instead of going through all the hassle of uploading etc.
If you have a website which you use with server-side thingamajiggies in it (PHP, Perl CGI, SHTML, mySQL etc.) then you will know that having to upload every time you change your code to test it is not only:
Wouldn't it be great if you could turn your own computer into a mini web server of its own, that would allow you to use your browser just like a real site to test it? Well, get ready folks, you can!
This tutorial is all about easily installing and setting up a fantastic web server just like your web host has. In fact, it'll be practically identical, but you have the easy option of not having to spend hours and hours pondering and configuring it for security etc. After all, you're the only one who's going to be using it!
There are two "sides" to this:
Now client side applications are like Javascript, DHTML and all that junk which the user has to spend precious nano-seconds processing on his/her computer. Might not sound a big deal, but what if the user has disabled Javascript? You'd be a bit stuck then, so get it processed server-side (php, cgi etc.). This means (you got it...) the server does all the hard work and sends the user a simple html page - which will work for every browser regardless of what they have and have not disabled. It means your pages load faster and are available to practically all your users, just the way you want it to look!
There's a whole lot of arguments about the differences, pros, cons etc. for client side and server side, and if you're that interested, you can look it up on a search engine...
It's also useful if using pre-made scripts like message boards, so you can test modifications and style changes without the risk of screwing up your site.
A few words before we start, on the syntax of this tutorial (read colors):
Perl/HTML/Apache code, altered Perl/HTML/Apache code, directories, files, links.
The main source for this tutorial was an article in the TLC Perl Articles website.
Right, let's begin! What do you need to do?
After each step, you can test each relevant component.
Wass this "Apache" business then? Well, Apache is the name of a supa-doopa webserver which most hosts use. A webserver is the thing that intercepts peoples requests (ie. i wanna see index.html) and gives them back useful stuff (ie. <html><head> etc.).
Why Apache? Well, like I said, Apache is used by the majority of hosts, and if you use a different server yourself (read on) you'll have to make sure you configure all your files so they are useable with Apache (not that that will be a huge job).
What other servers are there? Lots, Windows has built in IIS, but that really sucks - Personal Web Server etc. They just... suck. besides, Apache is open source as well, which is even better (although not very helpful for us in this tutorial).
So, this is how you easily install Apache on your computer.
NOTE: I use Windows XP, which is basically NT, so there may be differences between what I describe and what you see, in reference to services etc. If you're using Linux, well, if you are using Linux, you should be smart enough to figure it out yourself...
Download Apache (back to Apache top)
You can download lots of of Apache versions, not just the Windows ones. There are various Windows versions in MSI (Microsoft Installer) format (you should have this if Windows 2000 and above, and can download it from Microsoft for Windows 95 & 98).
The latest version available as of time of writing is 2.0.39 so if you're reading this and a newer version has come out, just apply everything later on equally. To minimise download times, choose the version which has no_ssl in it and don't get the one with src in it (this means no source included nor secure server stuff, which means a smaller file and the quicker to get this working)
Download Apache Win32 Platform (ie. windows users)
Download Apache All Platforms (unix etc. - there's lots!)
Remember to choose the latest version, with no src and no_ssl in it.
Install It (back to Apache top)
Run the install program, and click through, you should see a "Server Information" page. Now:
You get the idea - anything that asks you for server address, use localhost, email can be anything you like.
localhost = 127.0.0.1 which is the IP address for your computer (local... host). This means that when you type in localhost in your browser, you're trying to connect to yourself - when you have everything installed properly, this is the address you'll use to connect to yourself (http://localhost). You'll get an error if you try it and you've not a webserver running...
Keep all the defaults for paths and options, it will install to: c:\program files\Apache Group\Apache2 which you can change to c:\apache if you like, as it will be quicker to type when editing...
That should be done fairly quickly. Just click yes to most stuff. Make sure you don't run it yet, 'cos we need to change a teeny weeny bit of stuff in it.
If you are using Windows 2000, XP (ie NT) then Apache will install itself as a service which will run automatically in the background when you start your computer - a little icon will be in the system tray for stopping and starting the server (useful when you configure it later.)
If you are using Windows 98 or 95, it won't run as a service and you'll have to start the server manually via the start menu => programs option, it will pop up a nasty console box, but you'll have to live with it.
Modify it (back to Apache top)
Before you run it (make sure it's stopped if it first. If you got hasty and ran it already, you can Control-C the Apache box if you're on Windows 98 or just click on the Apache symbol on the system tray and tell it to stop the server if on NT (XP & 2000)) you have to modify it a little bit. Which is easy to do, and won't take long. Apache 2.xxx is easier and has less to modify...
Open up the httpd.conf file in Notepad or something from the c:\program files\Apache Group\Apache2\conf directory, or from the Start Menu option => Configure Server.
You should a whole bunch of these: # and some writing 'n' stuff. Scroll down until you see:
<Directory "C:/Program Files/Apache Group/Apache2/htdocs">
Then find just below that:
Options Indexes FollowSymLinks MultiViews
and change it to:
Options Indexes FollowSymLinks MultiViews +Includes
Make sure:
AllowOverride None
Looks like:
AllowOverride All
These make sure SSI and .htaccess work for you. If you don't want 'em, don't add 'em!
Scroll down a bit, and make sure:
DirectoryIndex index.html index.html.var
looks like:
DirectoryIndex index.html index.html.var index.shtml index.php
if you want your index file to be a php, you can add all sorts of things here, like home.htm etc. This means that when someone types in http://www.somesite.com they will get http://www.somesite.com/index.html or /index.php etc. If you don't set a valid option and have a file like mymainpage.htm then you'll get an error message (or worse) a directory listing...
Scroll down a whole lot more and find:
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"
Now if you have a cgi-bin in your public_html folder like:
index.html (file)
<images> (folder)
<cgi-bin> (folder)
then you need to change this to:
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/htdocs/cgi-bin/"
ie. the htdocs is the equivalent of your public_html folder... If you have no idea what I'm talking about, just leave it.
Some hosts have "anywhere CGI" enabled, so you can have this cgi-bin folder... other hosts have a cgi-bin they give you which isn't in the public_html directory: all in all, it's best to mimic your host's server as much as poss so it's all dead easy for you to use.
If you want to use PHP (if you don't, skip this), then we might as well add that it now, seeing as we are in the right place - add:
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php .php3
Action application/x-httpd-php "/php/php.exe"
just below the ScriptAlias /cgi-bin/ bit. Note that c:/php is the directory we're going to install PHP into, if you want to choose a different one, go ahead and change it, but remember for later.
Back to CGI... change:
<Directory "C:/Program Files/Apache Group/Apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
(just below the script alias) to
<Directory "c:/program files/apache group/apache2/htdocs/cgi-bin">
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
This makes sure CGI is executed in the cgi-bin directory
Scroll to find:
#AddHandler cgi-script .cgi
and change it to:
AddHandler cgi-script .cgi .pl
This makes sure .pl and .cgi are executed.
Make sure:
#AddOutputFilter INCLUDES .shtml
looks like:
AddOutputFilter INCLUDES .shtml
This makes sure SHTML is server-parsed.
You're done! Save the file and continue...
Test! (back to Apache top)
First, some explanations of the folder structure in your c:\program files\apache group\apache2, the only ones you need to care about are:
Right, first, start up Apache, either going into the Start Menu -> Apache httpd Server -> Start Apache in Console or by using the nifty system tray icon for NT users (start server/service)
For Win98 and 95: You should get a DOS box, saying: Apache/2.0.29 (Win32) running... if you get an error message, Apache have included a FAQ for when it doesn't work in the manual, above.
For XP, 2000 and NT: You won't see much, but the system tray icon should have a "play" icon on it...
You must have Winsock 2 installed too. Not necessary for any user above Win95. A search on Google for Winsock 2 should reveal some download locations.
Now the test. Open your browser and type in the address box: http://127.0.0.1/ - you should get an Apache page. If so - congratulations! You have your own Apache Web Server. If not, check back on above. A reboot helps if you just installed Winsock 2. You are seeing the default page which comes with the server, called index.html.xx in the htdocs folder.
If you changed DirectoryIndex to something obscure, you'll get an error message - if you get a 404 message - that means the server works! You just didn't put anything into it yet...
Now you can clear out the htdocs directory ready for your own files...
Again, there are lots of versions for different OS, but we're going to use ActivateState Perl for Win32. With MSI.
Download ActiveState Perl - All formats
Remember to download the latest version, as it gets updated pretty frequently.
Run the program you downloaded, accept all the license agreements etc. Keep the current settings, but change the root (ie the first tab) install directory to c:\usr - it will tack on the bin\perl bit so your path to perl will be: #!/usr/bin/perl which is pretty much exactly the same as it is on most hosts! Isn't that handy? This done, click next and untick the Create Perl file extension assosciation - this means when you open a .pl file it won't run perl, but continue as it did before. I have it run notepad so I can edit files.
Having installed it you can test Perl works:
Test PerlLet's see if Apache with Perl works! Copy and paste the following file and save it in your cgi-bin directory (c:\program files\Apache Group\Apache2\htdocs\cgi-bin etc.) as test.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello World";
Run it, and cross your fingers! Note: http://127.0.0.1/cgi-bin/test.cgi is the path in your web browser.
If it works - congratulations! If not, check the above, and if you're really struggling, ask for help in our forums. If you get an error message, check the ever-useful errors.log file for more info...
This is easy, make sure you followed the steps in editing the httpd.conf file as described at the beginning (adding ScriptAlias /php/ "c:/php/" etc.).
Ok, goto http://www.php.net and goto the downloads page. Goto your respective OS, and for Windows users, you want the ZIP package, NOT the installer version.
When it's downloaded, just extract the zip file to the directory you want (I used c:\php in the httpd.conf file).
Goto your php directory, and rename the php.ini-dist to php.ini and move it to your conf directory in the Apache folder. You don't need to change it, as in PHP 4+ mySQL support is built in.
This is easy, make a file called phpinfo.php with:
<?php
phpinfo();
?>
Save it, and stick it in the htdocs folder.
Type http://localhost/phpinfo.php in your browser and hit enter. You should get a nice page full of info - it worked! If not, you may need to restart your server, and if still you're having problems, look at the errors.log file for more info.
Goto http://www.mysql.com and goto the download area, download the file for your OS. It's very simple.
Run the setup file, install it where you like, doesn't make much difference.
Like I said before, for XP, 2000, NT users, like Apache, you get mySQL as a background service which automatically loads a traffic signal thingie in the system tray. Clicking on this will give you the mySQLadmin program - which is great.
I haven't tried mySQL on Windows 95 or 98, but you should run the mysqld.exe file in the c:\mysql\bin directory to start it. Then use the winmysqladmin.exe file for the mySQLadmin program.
If you're doing this, I'm taking a chance that you know enough about mySQL to configure your own my.ini, if not, the admin program has a tab for you, which will even do it for you!
You might want to change (in the "my.ini setup" tab of the admin program):
#bind-address=xxx.xxx.xx.x to
bind-address=127.0.0.1
I won't go into details over writing php databases, but a quick test is to fire up the mysql.exe in the c:\mysql\bin directory, which should log you on:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 3.23.51-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
ok, now type the following:
mysql> create database mydb; Query OK, 1 row affected (0.08 sec)
mysql> use mydb; Database changed mysql>
If you got as far as that, it worked! I'll leave it up to you do write the
message board...
If you have any problems with the above, think it's dumb, or think it's great, email me!
© 4WebHelp and Amadeus
its because the package you got from php .net is not the right one for Windows.
So you have to download the right package for Windows (but not the INSTALLER) from here : windows .php .net
Hope this help!
I also couldn't run .htaccess on it.
I tried googeling and trying a lot of explanations but nothing could really help.
But since done everything as explained here, my Site and .htaccess are now working very fine so I just want to thank U 4 putting this tutorial in the net.
You don't have permission to access /php/php-cgi.exe/index.php on this server.
can anyone please help me.
thanx 4 d tutorial..
bt i confirmed all d steps from your tutorial...
bt it gives me a error msg 403 forbidden: dont have permission to access /test.php.....
i also checked loadmodule, directory setup and all that bt it still doesnt work...
can anyone plz help me out...?
This saved me from wasting so much of time
<Directory />
Options FollowSymLinks
AllowOverride None
#Order deny,allow
#Deny from all
Order allow,deny
Allow from all
Satisfy all
</Directory>
could you please help any one.
1. Make sure the file is saved as a php document. Uncheck the "Hide fiile extensions for known file types" in the folder options of your computer. If the phpinfo.php file is saved as phpinfo.php.txt, rename the file and remove the .txt part. Confirm the changes with your OS.
2. Check your code in the httpd.conf file word for word. If it is perfect, it should work just fine.
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Cheers!
my forehead is bout caved in from banging on keyboard.
my solution for :
(You don't have permission to access /php/php.exe) error
is to add this to http.conf
<Directory "C:/php">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
I got the idea from this
<Directory "C:/Apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
There is no documents in apache or php setup instructions for this.
I hope they correct this oversight for other newbies.
Hope it helps
*****************************
Thanks DG... it helps a lot!!!!
You don't have permission to access /php/php-cgi.exe/date.php on this server
pls help me.
i m using Apache2.2 and windows 98
thanx...
my forehead is bout caved in from banging on keyboard.
my solution for :
(You don't have permission to access /php/php.exe) error
is to add this to http.conf
<Directory "C:/php">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
I got the idea from this
<Directory "C:/Apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
There is no documents in apache or php setup instructions for this.
I hope they correct this oversight for other newbies.
Hope it helps
Syntax error on line 296 of C:/Program Files/Apache/conf/httpd.conf:
ScriptAlias takes two arguments, a fakename and a realname
Line 296 of my httpd.conf reads: ScriptAlias /cgi-bin/ "C:/Program Files/Apache/cgi-bin/"ScriptAlias /php/ "c:/php/"
I have no idea what the error message really means or how to modify line 296. Can anyone help? Also, while installing Apache 2.2.2, I got this error message:
<OS 10048> Only one usage of each socket address <protocol/network address/port> is normally permitted. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Anyone have an idea how to interpret and solve these problems? Thanks!
(I also changed the php.exe to php-cgi.exe)
try this.....
<Directory />
Options FollowSymLinks
AllowOverride None
#Order deny,allow
#Deny from all
Order allow,deny
Allow from all
Satisfy all
</Directory>
what do you think is the problem, ive already followed your tutorial. pls help me!!
thanks!!
i followed many tutorials and finally yours too...
still the same problem... i get a 403: Forbidden message saying "Forbidden. You don't have permission to access /php/php.exe/test.php on this server"
ive granted full control to my windows user id for all files and folders in apache and php folders.
is there actually a solution fot this??? im out of ideas... can anyone pleaseeee help me
When I try to access phpinfo.php which i built and placed in C:\apache\htdocs\
i get: 403 Forbidden: Forbidden: You DOn't have permission to access /php/php.exe/phpinfo.php on this server.
When I try to acces test.cgi from http://localhost/cgi-bin/test.cgi which i placed in C:\apache\htdocs\cgi-bin
I receive: 500 Internal Server Error: Internal Server Error: The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, aaron@whatartist.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
I have revied the error log, but couldn't find the problem.
Any Thoughts?
I also changed the "php.exe" in the httpd.conf file to "php-cgi.exe"
Thanks so much... I hate IIS!!!
I want to use php, but I get this error...
What do I need to change?
Thanks
Changed the following line from
Action application/x-httpd-php "/php/php.exe"
to:
Action application/x-httpd-php "/php/php-cgi.exe"
and VOILA!!! It worked!!!
what is going on????
Thank you for a superb tutorial that any luser can follow!
Thats a great tutorial that you have made here, I have configuared php, mysql, apache and perl all work okay.
Except that when i try to run the the test for testing test.cgi i get the folowing message 403 Forbidden You don't have permission to access /test.cgi on this server.
Also please use the forums for problems of this nature. The comments area is for exactly that - comments - and is not designed for questions and answers.
PLZ HELP!
Quote:
Any idea what I am doing wrong.
Thanks in Advance.
Sounds to me, Sputnik that you've got a corrupt copy of MySQL, delete the one you have and re-download it, it should work then...
go to http://miniserver.sourceforge.net/
to download. A complete webserver with php, mysql and lots of other things in just 3MB... Works right out of the box!!
[Thu Feb 12 10:30:57 2004] [error] [client 127.0.0.1] script not found or unable to stat: C:/Program Files/Apache Group/Apache2/htdocs/cgi-bin
[Thu Feb 12 10:33:20 2004] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/cgi-bin
[Thu Feb 12 10:33:24 2004] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/cgi-bin
[Thu Feb 12 10:33:32 2004] [error] [client 127.0.0.1] script not found or unable to stat: C:/php/php.exe, referer: http://127.0.0.1
[Thu Feb 12 10:38:24 2004] [error] [client 127.0.0.1] script not found or unable to stat: C:/php/php.exe
[Thu Feb 12 10:39:54 2004] [error] [client 127.0.0.1] script not found or unable to stat: C:/php/php.exe, referer: http://localhost
thanks!!!
Any idea what I am doing wrong.
Thanks in Advance.
Glad this was of use.
I'm currently thinking about writing different installation tutorials for the two different version of apache (1 and 2) for windows and linux as well.
I will also cover a netbsd installation.
Eric
I am cutting my teeth on Perl/DBI/CGI and this gives me a local platform on which to run tests!
Many thanks for the jump start!
--Dietrich
Add a new comment