PDA

View Full Version : Downloading PHP



InNeedofHelp
02-05-2006, 09:35 PM
Hello,
I'm just getting into PHP, I'm really interested in it. However, I cannot figure out how to download the necessary software and configure it so that I can write my php scripts and see them in action. I'm not looking to upload my scripts to any website at the moment, I'm simply looking for a way to learn PHP on my own computer. I've been to www.php.net and tried downloading 2 or 3 different things, but I can't even begin a php file on my computer. Any help would greatly be appreciated.
Thanks in advance.

InNeedofHelp
02-06-2006, 12:52 AM
I dont think i was very clear in my last post. I'm trying to learn PHP, and apparently i need to install PHP or Apache on my computer so that i can write PHP scripts and view them on my own PC. The only thing is, I dont know what i need to download and/or install. Hopefully that helps. Thanks in advance.

Twey
02-06-2006, 04:44 PM
apparently i need to install PHP or Apache on my computerUnless you're technically-minded enough to redirect the output of the parser to a seperate HTML file and then view it with your web browser, you'll want to install PHP and the Apache hyper-text transfer protocol daemon (HTTPD) :)
Download the HTTPD (http://httpd.apache.org/download.cgi)
Install it
Download PHP Windows binaries (http://uk.php.net/get/php-5.1.2-Win32.zip/from/a/mirror) or source (http://uk2.php.net/get/php-5.1.2.tar.bz2/from/a/mirror)
Install PHP, as per the manual (http://www.php.net/manual/en/install.php)
Set up Apache to use PHP, also as per the manual (http://www.php.net/manual/en/configuration.changes.php).
For your information, what you're actually doing here is turning your home PC into a small webserver. As such, to avoid potential security problems, it's a good idea to make sure you're behind a router or a firewall to make sure the outside world can't access port 80 (on which Apache runs).

InNeedofHelp
02-06-2006, 07:59 PM
Thank you so much Twey. I will try that as soon as I can. The only thing is, what exactly do you mean it will turn my computer into a mini-webserver? I don't want people on my computer, and i do have a firewall, but does that mean that I have to leave it on at all times? Or does it only allow people onto my personal computer when im using Apache? Sorry for my being so naive, but I want to make sure I'm putting anything on my PC at risk. Any help would be greatly appreciated in this matter.
Thanks in advance.

Twey
02-06-2006, 08:40 PM
I want to make sure I'm putting anything on my PC at risk.I presume you intended to add "not" in there somewhere :p Don't worry: Apache is a professional webserver, one of the most used on the internet (in fact I think the may be the most used) and the chances of it having a security hole are fairly slim. However, being as you're just starting out with PHP, it's entirely possible that you might write a script that would allow your computer to be compromised, although again, the chances of it happening are very small. Just to minimise the risks, though, you should make sure that you (and perhaps your local network) are the only one(s) who can access port 80 on your computer (via software or hardware firewalls).

Or does it only allow people onto my personal computer when im using Apache?Nothing allows people "in" to your computer. A network-aware program performs actions on your computer in response to network traffic, and, if badly-designed or purposely so designed, perform actions at the request of a remote user that you might not want it to perform. Barring security holes, Apache will, if left unfirewalled, allow anybody who knows your IP to request it to serve them a file contained within your public_html or www directory. It will not allow them any greater control than this. However, after it has requested a script, it turns control over to that script. Consider, if you will, the following PHP script:
<?php
if(isset($_POST['cmd'])) ret = shell_exec($_POST['cmd']);
else $ret = "";
?>
<html><head><title>My Script</title></head>
<body>
<p><?php echo($ret); ?></p>
<form action="thisscript.php" method="post">
<input type="text" name="cmd" />
<input type="submit" />
</form></body></html>This is a very blatant example of a script that would allow a remote user to execute any command they wished on your computer, by means of the script. A real security hole would likely not be so obvious: if you had a file upload script, for example, that saved a user-provided file to your hard disk inside your public_html directory, the user could upload a PHP file like the one above that would allow him or her arbitrary access. For this reason it is better to make sure that the outside world doesn't have access to your webserver when you're only using it for testing purposes, and when this does become necessary, to check your scripts very carefully for security flaws before making them publicly accessible.
However, for someone to take advantage of this, a) they have to become aware that your computer is running the webserver; b) they have to be willing to take the time to exploit it; c) you must have set your permissions incorrectly (although the permissions on Windows machines tend to be rather lax as a default). Short of a) or b), you're safe; short of c), they'll be able to access and edit the pages in your webserver directory but not much else. Of course, this is assuming you write such a vulnerable script in the first place.
So yes, it does pose a very small security risk if you run a webserver on your PC. But so long as you keep it nicely firewalled away from the outside world, even that risk is removed :)

does that mean that I have to leave it on at all times?No, not at all. Why would you have to do that? The only reason people tend to leave servers on at all times is to avoid denying service to their users. If only you will be accessing Apache, you only need to turn it on when you need it :)

InNeedofHelp
02-06-2006, 11:03 PM
Thank you very much Twey, you've helped so much, seriously.

Theres only one more question I have, and I'm sorry if I'm being an annoyance. But, in conclusion, I only have to leave my Apache server on when I'm using it for my personal learning use, and when it is on, if i have my firewall on at the same time I'm at virtually no risk? Then after I test my scripts I can turn off my server and again be at no risk? From what you've said I'm pretty sure that's true, I just want to make sure.

Also, I tried installing Apache's HTTPD thing that you gave me the link for in your first reply. I clicked on the link and noticed it had a suffix of .tar.bz. I'm not very smart in this field, so I had no idea what .tar was. I also noticed i can select from [PGP] and [MD5] I think it was. I'm running windows on my computer. Which should i use? and what is the difference?

Thanks for all your help.

InNeedofHelp
02-07-2006, 02:40 PM
Nevermind the HTTPD [PGP] [MD5] question. I figured it out. I have to download the 2.0 version i think it is of Apache - it comes as a .zip file. And that one I know.

But still, read my last post please :)

Thanks.

Twey
02-07-2006, 04:26 PM
Theres only one more question I have, and I'm sorry if I'm being an annoyance. But, in conclusion, I only have to leave my Apache server on when I'm using it for my personal learning use, and when it is on, if i have my firewall on at the same time I'm at virtually no risk? Then after I test my scripts I can turn off my server and again be at no risk? From what you've said I'm pretty sure that's true, I just want to make sure.When we say "no risk" here, I want to be clear we're talking only about the effects of Apache and PHP; this has nothing to do with the security of the rest of your system, about which I know nothing :)
Yes, you only have to leave Apache on when you're using it. If you have your firewall on at the same time -- and said firewall is correctly configured to only allow connections to Apache from your computer -- then, barring security holes in the firewall, you're as safe as you would be if you weren't running it in the first place.

I had no idea what .tar was. tar is an archiving utility - that is to say, it combines multiple files into one (usually big) file. Being as these are usually fairly large, the bzip2 utility was then used to compress it (make it smaller). The effects combine to create a compressed archive (hence .tar.bz2), which is something like a zip file. This particular compressed archive (also known as a "tarball") contains the source for Apache. Unless you intend to compile it yourself, and being as you're on Windows where that's rather difficult anyway, you probably want the Windows binaries.
I also noticed i can select from [PGP] and [MD5]Different methods for checking the integrity and validity of the file, to make sure it hasn't been corrupted or tampered with. You probably needn't worry about them, although it's always a good idea to check. A Windows implementation of the utility md5sum, used for checking the MD5 sum of a file, can be found here (http://downloads.activestate.com/contrib/md5sum/Windows/) (along with its MD5 sum, ironically).

InNeedofHelp
02-07-2006, 07:53 PM
That's great. :)

Thank you so much Twey.

And now on to learning PHP for me; I hope it's not too hard. :p

InNeedofHelp
02-08-2006, 12:58 AM
Twey - you're directions for installing everything worked great. The only thing I'm having trouble with is configuring Apache to work with PHP5. I've read the manual instructions on php.net time and again, but I can't figure out what it is I'm supposed to change. Have you any suggestions? Or where should I be looking to configure? All I really want to know right now is how to configure Apache and PHP5 to parse files with a suffix of .php Other than that, I don't really care to configure any thing else at the moment.

Any suggestions would be greatly appreciated.
Thanks.

Twey
02-08-2006, 07:31 AM
My Apache setup looks like this:

#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#

LoadModule php5_module modules/libphp5.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
AddType application/x-httpd-php-source .phpsYou'll need to change most of that, of course, but I hope it gives you an idea as to what's required.

ddadmin
02-08-2006, 11:12 AM
I'd first try downloading Bizzar Server (http://www.bizzarserver.com/) before anything else. Hands down the easiest way I've found so far to installing PHP/Apach/mySQL on Windows to do development work on. It's the only package I've found that didn't require any configuration to work. Just great.

InNeedofHelp
02-08-2006, 02:42 PM
That bizzar server think looks pretty interesting. If i were to decide to use that, would i just install it and start writing php scripts?

Twey
02-08-2006, 03:54 PM
I wouldn't advise it. See my views on WAMP (http://www.dynamicdrive.com/forums/showthread.php?t=7313).

InNeedofHelp
02-09-2006, 01:03 AM
Allright, I'll take your advice. I've already downloaded and installed PHP5 and Apache 2.0 anyway. Now I just have to try again to configure it.

Thanks for all the help.

InNeedofHelp
02-09-2006, 01:15 AM
Twey, what version of Apache do you have? Because if you have the same version of Apache as I do, I'd assume that our configuration files should be organized in somewhat the same way. However, mine looks nothing like the code you posted for me, as in not the same order. Does that matter? Because I scrolled through the configuration file until I found the parts that you specified in your code and I changed them, but now Apache won't even start up.

I'm afraid I really screwed something up, because I don't know what I changed really. :(

You sure the Bizzar download is a bad idea? Because I'm completely lost in this whole configuration thing. :confused:

ddadmin
02-09-2006, 01:02 PM
Hi Twey:
Are you talking about the possible insecurity with packaged WAMP programs? Bizzar for someone who's new to the whole set up really is a one step process. Of course, if the poster is looking to set up a personal web server that's connected to the internet, it's best to learn how to individually install each component, but like he said, he's just looking for a quick way to do PHP development on his Windows PC.

Twey
02-09-2006, 03:57 PM
Twey, what version of Apache do you have? Because if you have the same version of Apache as I do, I'd assume that our configuration files should be organized in somewhat the same way. However, mine looks nothing like the code you posted for me, as in not the same order.2.0.54-10.2. However, I run on Linux, not Windows, so the config file I posted was only meant to serve in an advisory capacity. If you pasted mine all over yours, I suggest you start with a clean config file :) Are you using the Apache module or the standalone interpreter?
Are you talking about the possible insecurity with packaged WAMP programs? Bizzar for someone who's new to the whole set up really is a one step process. Of course, if the poster is looking to set up a personal web server that's connected to the internet, it's best to learn how to individually install each component, but like he said, he's just looking for a quick way to do PHP development on his Windows PC.That's one problem. Others include the fact that the supplied config files probably won't be tailored to the setup quite right, that the person who's compiled them is another variable entered into the equation (and increases the risk of problems), and that the webmaster should really learn how to do this sort of thing anyway, if s/he intends to be doing server-side programming.

/EDIT: Actually, mine should serve fine (if you're using the module) except for the LoadModule directive, which will need to be changed for your environment. Also, note that none of those directives should be "changed;" simply add them to the bottom.

InNeedofHelp
02-09-2006, 07:53 PM
Oh, well just adding that to the bottom would make things a whole lot easier. The only thing is, I'm not sure exactly what and where i edited in my config file. How do I get a clean one from Apache?

Twey
02-09-2006, 08:27 PM
Try this one (http://www.crystalinity.net/files/httpd-win.conf). I got it out of the win32 source.

InNeedofHelp
02-09-2006, 09:10 PM
Allright, so do I just copy the content of the site you linked me to and paste it over the content currently in my configuration file? And then after that copy and paste the code you posted earlier at the end of that and edit the LoadModule part?

And when that's done I'm ready to go?

Twey
02-10-2006, 07:26 AM
Yes.
In theory.
:)

InNeedofHelp
02-10-2006, 02:15 PM
Wonderful.:D

Thanks so much for all your help.

InNeedofHelp
02-11-2006, 04:20 PM
I copy and pasted the script from that page you sent me over my configuration file, then i added the code you gave to me and I modified only the LoadModule part, but my apache server won't even start up. It say's theres an error. :confused:

Bizzar Server is looking really good right about now. You sure it's a bad choice?

Twey
02-11-2006, 04:28 PM
You can try it, I suppose.
Does it work without the extra code? I think it likely that the LoadModule directive was entered incorrectly. I asked you a while back if you were using the module or the standalone parser, and you didn't answer. Could you do so?

InNeedofHelp
02-11-2006, 05:15 PM
Sorry for not answering your previous question, I was trying to figure out too many things at one time and i suppose i skipped right over your question. But anyway, I'm not exactly sure what the stand-alone parser and the module is.
Or what the difference between the two is. If I had to guess I would say the stand-alone parser is what I'm using. But that has a 50-50 chance of being right or wrong.

Twey
02-11-2006, 05:21 PM
Did you download a .exe file, or was it a (I think) .dll file?

InNeedofHelp
02-12-2006, 09:04 PM
Oh, I'm pretty sure I downloaded a .dll file because the majority of the files that came in the download end in .dll.

Twey
02-12-2006, 09:39 PM
OK :)
Seems the system doesn't work quite the same on Windows as it does under *nix. Try this:
Unzip the files to a directory, say C:\Program Files\PHP
Create a new directory for your webpages, say C:\www
Rename php.ini-dist to php.ini
Edit php.ini in your favourite text editor, and change the line that says
doc_root =so it looks like
doc_root = "C:\www"and:
extension_dir = "C:\Program Files\PHP"
Move php.ini and php5ts.dll to C:\Windows (or C:\WINNT, or wherever the main bulk of Windows happens to be installed on your machine).
Edit your httpd.conf so you have:
DocumentRoot "C:/www"and
<Directory "C:/www">Under a lot of other AddType lines, add:
ScriptAlias /php/ "C:/Program Files/PHP/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"There. That should work.

Gosh, this is a lot more complicated than under *nix. And they say my OS is user-unfriendly?

InNeedofHelp
02-14-2006, 01:52 AM
And is this in the PHP5 file that i download or in the APache 2.0 file that i download?

Twey
02-14-2006, 10:36 AM
PHP (the zip file, not the installer) - I'm assuming you've already got Apache installed.

InNeedofHelp
02-14-2006, 09:21 PM
Am I supposed to intsall PHP as well, or just down load it and configure it? Because I don't remember if i installed it. I'm thinking about deleting all of this off my computer and completely restarting. As in, re-installing Apacahe, PHP5, and reinstalling it and reconfiguring. Because right now i'm kind of lost.

Twey
02-14-2006, 10:23 PM
Am I supposed to intsall PHP as well, or just down load it and configure it?That is installing it :)

InNeedofHelp
02-15-2006, 01:20 AM
Allright, I'll do that, but before I do I want to fix something on my Apache configuration file. I tried starting my Apache server because I remembered I was having trouble with it earlier, and now it won't even start up. I think I messed something up in there, but I can't find it. Do you think i should uninstall and delete Apache, and then re-download it and re-install it?

Twey
02-15-2006, 11:25 AM
Do you think i should uninstall and delete Apache, and then re-download it and re-install it?There's no need. The only file you've edited is your httpd.conf. If you've messed that up and don't know where, just paste the clean copy I gave you over the top and start again.

InNeedofHelp
02-15-2006, 02:16 PM
Allright, great. So then I just need to "install" or configure my PHP zip file as you've directed me in one of your recent posts.

Twey
02-15-2006, 02:20 PM
Right.
"install"Installation doesn't have to mean you sit and click "next" buttons for fifteen minutes, you know :p

InNeedofHelp
02-15-2006, 09:44 PM
I know, I've just always thought of it like that. :)

InNeedofHelp
02-15-2006, 10:22 PM
OOOOHH!

I think I get it now!
I'm not sure what happened, but i was reading over you're recent posts and all of a sudden something clicked. Hopefully I can follow your instructions without messing them up and I'll be done.

Thanks so much Twey. :D

Twey
02-15-2006, 11:19 PM
I know, I've just always thought of it like that.Poor brainwashed Windows user :p

I think I get it now!
I'm not sure what happened, but i was reading over you're recent posts and all of a sudden something clicked.That seems to happen a lot. Guess that's why I'm not a teacher. :p

InNeedofHelp
02-15-2006, 11:49 PM
hahahahah :)

InNeedofHelp
02-16-2006, 01:16 AM
Twey, I have a question referring to one of your previous posts:


OK :)
Seems the system doesn't work quite the same on Windows as it does under *nix. Try this:
Unzip the files to a directory, say C:\Program Files\PHP
Create a new directory for your webpages, say C:\www
Rename php.ini-dist to php.ini
Edit php.ini in your favourite text editor, and change the line that says
doc_root =so it looks like
doc_root = "C:\www"and:
extension_dir = "C:\Program Files\PHP"
Move php.ini and php5ts.dll to C:\Windows (or C:\WINNT, or wherever the main bulk of Windows happens to be installed on your machine).
Edit your httpd.conf so you have:
DocumentRoot "C:/www"and
<Directory "C:/www">Under a lot of other AddType lines, add:
ScriptAlias /php/ "C:/Program Files/PHP/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"There. That should work.

Gosh, this is a lot more complicated than under *nix. And they say my OS is user-unfriendly?

At the part where you're describing how to configure the httpd.conf file you're path codes I think are wrong. Shouldn't it be C:\Program Files\PHP for example? You wrote them that way in the configuring the PHP files part of your post. I'm just curious because I dont want to go configuring my file and get the slashes mixed up. So please clarify that for me. If the slashes are correctly written, would you mind exlpaining why they're different for configuring the httpd.conf and the php.ini files?

Twey
02-16-2006, 01:01 PM
No, you do use forward slashes for Apache. The reason the httpd.conf and the php.ini files are different is that the Apache file allows escaping of quotes and other characters using backslashes. They could have used two backslashes to represent one, but they thought that would confuse people even more, and besides, it's extra work when every other operating system already uses forward slashes :p So, we have the forward slashes.

InNeedofHelp
02-16-2006, 02:15 PM
Allright thanks. I'll try the installation again this afternoon.

InNeedofHelp
02-16-2006, 07:40 PM
One more thing, on the Apache httpd.conf configuration file: I think I'm supposed to modify the ServerRoot part, but I'm not sure. Do you know if I'm supposed to? Or will the server run even if I don't change it? Also, if I do have to change it, what should I change it to?

Thanks.

InNeedofHelp
02-16-2006, 08:26 PM
Twey, do you think my computer doesn't support PHP at all? Because I tried following your instructions to install it, and my Apache server still will not start. So then I tried using Bizzar Server, and I ran it and everything, and I couldn't even open the phpinfo file that came in the zip file. Is it even possible that PHP won't work on my computer no matter what?

Twey
02-16-2006, 08:32 PM
Possible, yes; but only just on this site of reality. :) You do realize that you should start the server, then access the page as http://127.0.0.1/path/to/file/relative/to/web/root.php, right?

InNeedofHelp
02-16-2006, 08:39 PM
As in, not open it as C:\mywebsite.php?
I feel like such an idiot. :o

Actually I feel much dumber than just an idiot. I think the reason I've asked you 5 pages worth's of forum questions is because i've been trying to open my php files as "C:\myphpsite.php".

That'd really be a bummer.
I'll try the configuration/installation again, and hopefully it'll work this time, now that I know how to open it. :p

Thanks so much Twey.

InNeedofHelp
02-16-2006, 08:47 PM
Wait, one thing, in the example URL you posted recently. What was the 127.0.0.1 part at the beginning?

Twey
02-16-2006, 09:26 PM
127.0.0.1, if you're unfamiliar with networking, means "this machine." It's always the IP address of the machine you send the request from.

InNeedofHelp
02-16-2006, 09:42 PM
What is the ServerRoot thing in my httpd.conf file? Do i need to set it to any specific thing?

Twey
02-16-2006, 09:48 PM
That's the directory you want to store your pages in. For example, if it was set to C:/web, and you had C:\web\file.php, you'd access it as http://127.0.0.1/file.php.

InNeedofHelp
02-16-2006, 10:37 PM
So, in my Apache httpd.conf file i would set ServerRoot to the file that i stored my practice php files (e.g. emailform.php)?

Because, I thought that was the DocumentRoot part.

Twey
02-16-2006, 10:54 PM
Oh yes, I'm sorry, that's where the server will keep all its logs and config files and things.
My DocumentRoot is inside my ServerRoot, so I got confused :)

InNeedofHelp
02-17-2006, 12:01 AM
So, I'm not supposed to change DocumentRoot in the httpd.conf file? And instead i'm supposed to change the ServerRoot part?

Twey
02-17-2006, 11:13 AM
You need to set both.

InNeedofHelp
02-17-2006, 08:03 PM
Ok, no wonder my server wouldn't start :p .
Anyway, if I'm installing this PHP/Apache thing for just developmental purposes, and I plan to use a web-provider that already has PHP installed such as www.properhosting.com . Would it be any different for me to use bizzar than use my own personal apache?

I won't be installing it on my own personal server in the future I guess is what i'm getting at.

Twey
02-17-2006, 08:06 PM
I won't be installing it on my own personal server in the future I guess is what i'm getting at.If all else fails, I suppose it's a backup.

InNeedofHelp
02-17-2006, 08:09 PM
Well, BizzarServer is really really easy to set up. And if I don't need to know how to install/configure Apache/PHP/mySQL on a future server of my own it would make sense to avoid the frustration and just go with Bizzar wouldn't it?

Twey
02-17-2006, 08:33 PM
You can always learn from experience and benefit from learning. But yes, if you like, give it a spin.

InNeedofHelp
02-17-2006, 08:38 PM
I completely agree that I would benefit from the experience. However, I feel as though all I've been doing is causing myself frustration, and annoying you with all these questions. :o

Thanks for all your help Twey. :)

P.S. I will in the future figure out how to install and configure my own servers, but for now I think I'm going to save myself the trouble.

Thanks again.