Forum Moderators: phranque

Message Too Old, No Replies

Mac OS 10.3 Panther and Apache

         

bbrueck

3:23 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



I am trying to set up the Apache server included in Mac OS Panther to test PHP sites locally. I had completed the how-to at: [macromedia.com...] which I didn't completely understand. The line "Add the following lines (add these lines above: AddType application/x-tar .tgz):" confuses me completely.

Now I cannot start web sharing at all. Is there a way to set the server back to it's default?

There was also a thread posted here on a similar issue at: [webmasterworld.com...] that suggested using the PHP Package at entrpy.ch which I tried but it gave me errors and will not install. I think once I get back to square one I can use this download to walk me through it. Aaaaaaaahhhh.

I am a designer with mediocre knowledge of html, flash and css. I am desperately trying to learn server tech. but please don't get too tech in your descriptions. I use Dreamweaver MX but do mostly hand coding with it.

Thanks in advance!

sonjay

4:36 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



To get back to your original httpd.conf file, do the following in Terminal. Hit the return key after each line. The first line uses cd (change directory) to take you into the /etc/httpd directory. The second line uses list with a couple of options to list all the files in that directory.

cd /etc/httpd

ls -la

Okay, stop typing in the Terminal here. When you typed ls -la, did you get a list of files? Is there one in the list called "httpd.conf.default? That's a copy of the original, untouched default httpd.conf file as it came to you from Apple.

Next, let's rename the httpd.conf file that you've "messed up." There's probably no real need for this, but I find that it's good to get into the habit of preserving httpd.conf before changing or overwriting it. So type the below line in Terminal. This uses the mv (move) command to rename the file:

sudo mv httpd.conf httpd.conf.messedup

You can use a different extension instead of "messedup" if you want. ;) Because you're using sudo to edit a system file, you'll be asked for your admin password -- just type that in at the prompt.

Now do this next step, also in terminal. This command will copy (cp) httpd.conf.default to a new file called httpd.conf. We want to copy this one (cp) rather than move/rename (mv), so that we leave that original httpd.conf.default in its original untouched state, in case you ever need it again. In Terminal, type:

sudo cp httpd.conf.default httpd.conf

Now type in Terminal the next line. This runs a test on your httpd.conf file to see if it has any problems.

apachectl configtest

If you get "Syntax OK" as the result, then your Apache is good to go. You can restart Apache from the Terminal by typing:

sudo apachectl graceful

You should get "httpd gracefully restarted" as the result.

Now you're back at square one and ready to tackle php. ;)

bbrueck

5:06 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



THANK YOU Sonjay! That worked. That Terminal is dangerous territory for me to tread.

Would you recommend using the PHP 5.0.4.pkg if it will install now? From the comments I've seen it looks like that's a simple install and use.

:)

sonjay

6:02 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



Great, I'm glad to hear it!

I used the package from entropy when I set up php on my machine, but it's the 4.3.11 version. The entropy installers have a very good reputation (that Mark Liyanage is a saint!), so I would think the 5.05 package should install fine.

If you use that, please do post back how it goes -- I'd like to upgrade my php, and I'd be interested in hearing how the install goes for you.

bbrueck

8:53 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



The install went smooth as can be and I can view and test php pages locally. However, that's about all I know. I am ready to tackle the learning php now.

I have a tutorial that I am working on <snip> but I am already lost. I want to create a template site where I can load content from other html pages just as this tutorial demonstrates but I am lost at "We’ll set the variable in the query string (everything that comes after the "?") of the url: template.php?page=babeuf." part. Do you know any how-to sites I could go to? Does the query string go in the menu.php file? It seems something is missing from this tutorial.

I guess I just assumed you were my personal tech support—sorry. If you think this is up your alley and want to help out it'd be much appreciated. If not, thanks for the help already and I understand...

Let me know if you have q's on the php 5.0.4 package...

[edited by: jdMorgan at 11:10 pm (utc) on Jan. 3, 2006]
[edit reason] No URL drops, please. See Terms of Service. [/edit]

sonjay

9:29 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



Thanks, it's good to hear that the php 5.05 install is as easy as the earlier ones. Unless you can tell me how to do an upgrade, as opposed to a fresh install, I don't think I have any questions. ;)

In that tutorial, the reference to "setting the variable in the query string" refers to the actual URL of the page in question, e.g., http://www.example.com/template.php?page=babeuf

In that URL, the "page=babeuf" part is the query string. On your local machine, you would call the page in your browser with [localhost.com...] This sets the page variable to babeuf.

However....... (you knew this was coming, right?)

That looks like a nice tutorial, but you need to take note of the date that particular article was published: August 2002. There's a key feature of php that's changed since publication of that tutorial, and that is register_globals.

I don't recall exactly what version, but php began shipping with register_globals turned off in version 4.something. In your 5.05 install, I'm sure register_globals is off. But when that tutorial was written, register_globals would have been on in virtually all php installations.

So what does that mean to you? When that article was published, you could put a variable in the query string (template.php?page=something) and in your php you could simply refer to the variable $page.

But now, with register_globals off, you have to access that variable by the SUPERGLOBAL array, which in this case would be $_GET['page']. Variables in the query string are GET variables. If you have a form that's POSTed, its variables are POST variables and would be accessed with $_POST['variablename']. A cookie that you set needs to be accessed with $_COOKIE['variablename'].

With register_globals off, all of those variables would be accessed simply by $variablename, and a malicious user could put query strings in the URL that would overwrite your cookie values, and stuff like that. For example, if someone figures out that you set a cookie named "admin" with the value "yes" for your site's admin area, they could just go to your site with?admin=yes in the URL, and bingo, they're the administrator! Imagine a webmasterworld where bbrueck could take over sonjay's user identity just by putting?username=sonjay in the URL! So the php folks thought that having register_globals on was too risky, and turned it off by default. It's possible to turn it back on in your php.ini or an .htaccess, but you'll learn much better coding habits by leaving it off and using the appropriate SUPERGLOBAL array variables.

And all of that means that the nice tutorial you found won't work with the more current versions of php!

I would recommend that you look for more recent tutorials that don't depend on register_globals being turned on. (I'll sticky you a couple of URLs with tutorials that I like.) I also recommend that you spend oodles of quality time at php.net, where you'll find the full php manual, with all of the functions explained. The user notes on each function's page are treasure troves
of great information!

bbrueck

12:45 pm on Jan 4, 2006 (gmt 0)

10+ Year Member



Oh boy. Lesson learned on that—ALWAYS CHECK THE DATE on a thread. Thanks for all of you help and your sticky mail, I can see that I have many days ahead in books and on forums.

I didn't see an upgrade to the PHP package, but then again I didn't really look. :) Maybe it installs over previous versions? I also saw that PHP 6 is on its way soon. It all moves so rapidly!

Thanks again!