Page 1 of 1

Total newb question about running pHp scrips

Posted: Sat Aug 21, 2010 10:28 pm
by agarose
I don't have a CS background, and although comfortable with computers, am brand new to web programming (and most of programming in general) so please excuse my early newbness.

My question is regarding how you go about "running" all those files that have ".php" endings, such as "test.php".

I think I'm doing it right (my scripts work) but I've seen this question asked so many times on other beginner forums and answered incompletely that I've been having doubts.

My method (local Apache server)
- Installed LAMP on Ubuntu linux, got it to work (whew).
- Save my .php files in /var/www (you have no idea how long this took me to figure out on my own - my book made no mention of it)
- Run the script by opening Firefox, and typing "http://localhost/FILENAME.php"

I'm asking because my first time doing it, I tried to directly open the .php files in Mozilla. It works for html files, but with the php, it asks to download the file instead.

I've seen this exact problem of download instead of parse asked at least 10 times when googling the problem, yet nobody seems to mention the http://localhost.filename as the correct method of running the script, so I'm making sure I'm doing it right.

Thanks for the help

PS - It's ironic, but after "playing" (very minimally) with Python, html, PERL ( abit) and now php , I've found that hardest aspect of all of them the installation and configuration. The programming aspect has been far, far easier to understand.

Re: Total newb question about running pHp scrips

Posted: Wed Aug 25, 2010 6:04 pm
by McInfo
There are other ways to use PHP, but the process you described is probably the most common.

As for installing all the software you need (HTTP server, database server, PHP, extensions, etc.), it may be easiest to install a bundle like XAMPP. However, the required packages may be just as easy to install and maybe even easier to maintain with Ubuntu's Synaptic Package Manager.

It may take a lot of reading to become comfortable with the PHP Manual and discover how useful it really is, but it's worth it.

Editors like NetBeans and Eclipse PDT are quite helpful too with features like syntax highlighting and code completion.