Apache Web-Serving with Mac OS X: Part 3
by Kevin Hemenway01/04/2002
Editor's note: In the first part of this series, Kevin showed you how to easily start serving Web pages from your Mac OS X computer. In the second article, he explored the world of CGI access. Today, he moves forward with a look at PHP.
Turning on PHP4
We're on the last legs of our trip down Feature Lane, Impressiville. This will be the easiest section of our journey, mainly because we'll be going through the paces based on what we already know. Much like CGI, PHP is very popular and well supported, and very often installed on Web hosts by default. Much like SSI, the code is included and interpreted into the actual HTML of your Web pages.
Just like our other sections on CGI and SSI, turning on PHP involves searching for the feature name ("php") within our Apache configuration file. The first entries we come up against are:
# LoadModule php4_module libexec/httpd/libphp4.so
# AddModule mod_php4.c
These lines are just like those we encountered when we were messing around with CGIs -- they enable or disable the loading of PHP on a restart of our Apache Web server. Since they're commented with that little "#" character, we've got to remove the "#" to enable them. Do that now.
Moving on to our next search result, we see:
# For example, the PHP 3.x module will typically use:
#
# AddType application/x-httpd-php3 .php3
# AddType application/x-httpd-php3-source .phps
#
# And for PHP 4.x, use:
#
# AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
|
|
We saw these same sorts of lines when we were enabling
SSI. In essence, they're saying that any file with the .php extension should
be processed by the PHP module we just enabled. As we'll see soon enough, Mac OS X (versions 10.1 and above) comes pre-installed with PHP 4, so go ahead and uncomment the two "for
PHP 4.x" lines. Save the Apache configuration file, and stop and start the
Web server using the "Sharing" preference panel.
We're going to return to our Apache error log for a second to illustrate a simple, yet helpful bit of information. Each time you start Apache, it will spit out a single line telling you that everything has started successfully. Often times, it will look like so:
[notice] Apache/1.3.20 (Darwin) configured
-- resuming normal operations
When you add a third party module or feature
(like PHP, mod_perl, mod_ssl, etc.), Apache will graciously make mention of it in its startup line.
If you just restarted the Apache Web server now, take a look at the error
log by typing:
tail /var/log/httpd/error_log
You should see Apache wax poetic with:
[notice] Apache/1.3.20 (Darwin) PHP/4.0.6
configured -- resuming normal operations
Apache tells us
that PHP is enabled, but how do we really know for sure? Rather easily,
actually. Take that index.shtml file that we were testing SSIs with, and
rename it to index.php. Now, replace the contents with the
following:
<html><body>
<h1>Gleefully Served By Mac OS X</h1>
<? phpinfo()?>
</body></html>
Finally, go to
http://127.0.0.1/index.php and you should see a long page full of PHP
diagnostic information. If so, rub your hands with a gleam in your eye,
because PHP has now been added to your arsenal. Want to add a simple Web-based email program for your traveling coworkers? Check out PHPost. Note: Most PHP
applications require a sophisticated database backend, like MySQL or
Postgres -- PHPost is one of the few that doesn't. While installing and
configuring these database systems is relatively easy on Mac OS X, it would be
outside the scope of this primer. Want to see an article on this? Let us know by commenting below.
Choosing Who Sees What
|
| |
It's five in the morning. You've gone through three six packs of soda, two tins of Penguin Reds, and an untold number of delicious snacky treats. You've got a CGI poll script ready to quiz the employees on the menu for the next company picnic, an SSI image gallery that happily sends the marketing department into a drool-dripping feature panic, and a PHP app with which your developers can track and monitor their sloppy code.
Now what?
After all you've done, something rather minor. We've just got to throw a little access control on our spunky new intranet -- we wouldn't want the outside world seeing the insanely great job we've done (we'd rather wait and show them the really cool stuff we're gonna do on our personal time, right? Wink, wink, nudge, nudge).
While Apache can certainly handle authenticated access control, we're only going to touch on the location-based side of it. To do so, we're going to return to a snippet of configuration file that we've messed around with before, back when we were enabling SSIs:
<Directory "/Library/WebServer/Documents">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I mentioned we'd eventually touch on the remaining lines, and now is said
time (although, we're still going to rudely skip AllowOverride). Quite
simply, the "Order allow, deny" and "Allow from all" lines are the magic
that will stop outside visitors from perusing our intranet. Right now, as
these lines stand, our intranet is wide open to the public.
This is what we're going to end up with:
<Directory "/Library/WebServer/Documents">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Deny from all
Allow from gatesmcfaddenco.org
</Directory>
See what we've done here? The first thing we did is flip our "Order" directive. This tells Apache to process all "Deny" rules first, and then all the remaining "Allow" rules. Likewise, our first "Deny" is "from all," meaning no one can come knocking. If we denied everyone, of course, no one would be able to see our Macstrosity (rather phenomic, eh?), so we add an "Allow" rule for our GatesMcFaddenCo domain. We can also allow and deny by IP, like "Allow from 209.204.146". This will allow access to anyone from within the GatesMcFaddenCo network, but no one from without.
Conclusion
Before you know it, it's seven in the morning and time to show off your efforts. You're confident, feigning a yawn of boredom, not sleepiness. As the morning sun glints off the silver of your glorious G4 tower, you smile privately -- as has been typical since time began, doing something amazing on the Mac has been incredibly simple. Your boss is impressed, your coworkers are disbelieving, and you're signing a purchase order for the newest mystery item from MacWorld. Oh, life is good.
Don't think we've exhausted everything Apache and Mac OS X has to offer, though. You still
haven't touched mod_ssl, which allows secure server capabilities, nor have
you fiddled with mod_perl, which can speed up your CGI scripts immensely.
You haven't touched the authentication capabilities of Apache's access
control, or even tweaked Apache's configuration with .htaccess files. And
sadly, if someone types in a bad URL for your intranet, you still get an
ugly and generic 404 page.
Only 7:30? Plenty of time to bust those out before lunch. Good luck!
Kevin Hemenway is the coauthor of Mac OS X Hacks, author of Spidering Hacks, and the alter ego of the pervasively strange Morbus Iff, creator of disobey.com, which bills itself as "content for the discontented."
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 152 of 152.
-
so easy - but . . .
2005-02-22 12:55:54 videomike [Reply | View]
Like so many others, I've benefitted greatly from this tutorial. Thank you. My problem is so easy I can't find the answer . . .
I want to activate PHP 4. I'm using "sudo pico" in lieu of the assumed BBEdit. (good reason, long story) Once I'm into the Apache config file, and I delete the '#' to un-comment something, how do I save it? I've tried ^X for 'exit' and several other options, plus I've just closed the terminal. When I re-enter, the item is still commented out.
-
mac,php and variables
2004-09-01 04:52:53 flashsmurf [Reply | View]
I've installed Mac OS 10.3.3 succesfully and enabled the apache server and php thanx to your tutorial. There's one problem. In html as well in flash variables are transmitted to the php file, but php can't find them or doesn't recognize them as variables. Variables made within the php script works.What is going wrong?
Thanks in advance, Koen.
-
PHP HTML parsing problem
2003-06-19 16:57:31 enderws [Reply | View]
I've got PHP up and running on my local webserver, but I'm having a problem. Whenever I surf to a .php web page served by my box, it prompts me to save the file rather than parsing it for HTML and displaying the webpage. What's wrong? I already added
AddType Application/x-httpd-php .php .html
to my httpd.conf and restarted the webserver. Why would Apache be sending the .php file as a file to be saved rather than HTML? Is it sending the wrong headers? Any help would be appreciated! -
PHP HTML parsing problem
2003-08-16 16:36:04 anonymous2 [Reply | View]
I had the same problem. My problem was that it wasn't saving the file with the php extension. It added rtf to the end. Read this article
http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_macintosh.html
And follow the directions for the TextEdit and after doing the changes make sure you open a new file.
-
My vote for an article!
2003-05-30 16:29:37 anonymous2 [Reply | View]
"Note: Most PHP applications require a sophisticated database backend, like MySQL or Postgres -- PHPost is one of the few that doesn't. While installing and configuring these database systems is relatively easy on Mac OS X, it would be outside the scope of this primer. Want to see an article on this? Let us know by commenting below."
This is exactly what I'd like to see -- as I'm interested in running a program called WebCalendar which requires php and such database.
Thanks!
blair.at.greenbelt.org
-
php AND ssi?
2003-03-26 06:01:55 anonymous2 [Reply | View]
My SSI's work well if I have a .shtml or a .html page but once I try to add .php to:
Addhandler server-parsed .shtml .html .php
when I go to the page it tries and D-load it like a file. How do I have SSI on .php pages?
Thanks much,
Jason -
php AND ssi?
2003-03-26 06:19:31 Kevin Hemenway [Reply | View]
If you're trying to get SSI and PHP working together through one .php file, that's impossible in Apache 1.3. You can either have PHP in .php files, or SSI in .php files - you can't mix and match them.
Ignoring the above, it sounds like .php (which may or may not have been associated with mod_php) is being handled by the SSI part of Apache, and since no MIME-type has been defined for .php, your browser doesn't know what to do with it. You'll want to add .php to:
AddType text/html .shtml
But, remember, you can't use PHP and SSI in the same file. It's one or the other. Apache 2.0 purportedly will allow you to do this by setting up filters, but I've yet to experiment with it. -
php AND ssi?
2003-04-02 03:37:25 anonymous2 [Reply | View]
I'm Just starting out with PHP, but it strikes me as logical to use the PHP function include() when wanting to include files.
EG.
<?php include("include_this_file.html"); ?>
(of course the icluded file could also be .php)
Another option is that it appears that you can include .php files into .shtml files, and the PHP gets Parsed correctly.
EG.
<!--#include file="info.php"-->
I've tried it with a sample and works fine, though am unsure of Pro's/Con's within a larger web application.
Hope this helps.
-
PHP Nodice. Failed Opening?
2003-01-30 20:16:46 bucky4d4s [Reply | View]
The log sez PHP is running, but when I try to open index.php, I get:
Warning: Failed opening '/Library/WebServer/Documents/index.php' for inclusion (include_path='.:/usr/lib/php') in Unknown on line 0
Whassup?
(on OSX 10.2.3)
-
Apache-PHP
2002-11-23 07:03:35 anonymous2 [Reply | View]
I've added the 2 lines AddType that were missing and I tried again but that does still nothing when I put PHP in my HTML
With tail /var/log/httpd/error_log, I see
[notice]Apache ... resuming normal operations
[notice]Accept mutex: flock (Default: flock)
Has anybody an idea?
-
Pbs with PHP on OS X.2
2002-11-23 06:08:51 anonymous2 [Reply | View]
Can anybody tell me exactly what there is to be done with the Apache config file and after modifying it, because I have put the two missing lines (AddTypa application...), and tried with phpinfo as indicated by the article, but it still doesn't work
Thanks in advance.
-
phpInfo() showing my password
2002-11-14 20:15:13 anonymous2 [Reply | View]
I am new to PHP and learning a ton from this site! I love it.
I am wondering why I can see my password in the phpinfo() page. It's listed as the _SERVER["PHP_AUTH_PW"] variable under PHP Variables near the bottom.
I posted the same phpinfo() file on a server I have used in the past and it doesn't show up there.
Thanks -
phpInfo() showing my password
2003-06-05 01:25:19 anonymous2 [Reply | View]
That scared me too! But I figured out that it only shows up if your site is secured with Authentication and you have already logged in (which may be happening automatically via transparent KeyChain access or other Password Manager type stuff). I tried relaunching my browser and didn't log in to the secured section of my site (the top level of the site is public, but my personal ~user pages are protected), and then ran a file that had phpinfo() in it and the PHP_AUTH_USER and PHP_AUTH_PW variables don't show up in the listing. The PHP module apparenlty has access to your authentication info (I guess that's a good thing?), and that phpinfo page is just showing off _everything_ it knows about. But still it seems like it shouldn't be displaying that by in a general info page - that should be some kind of special command or option, not the default.
-
MySQL or Postgres Please
2002-11-04 11:51:25 anonymous2 [Reply | View]
I would appreciate such information
-
Automatic PHP tasks
2002-10-28 13:44:25 anonymous2 [Reply | View]
I'm thrilled about my newly acquired PHP & MySQL knowledge. Thank you O'Reilly and OSX!
I currently include PHP in HTML Web pages, but I'm wondering if there's a way to create PHP tasks that run automatically at intervals (every hour or day), or at startup (run constantly in the background)? Any help or articles about this in relation to OSX would be greatly appreciated.
Thanks. -
Automatic PHP tasks
2002-10-28 16:50:45 anonymous2 [Reply | View]
I found a simple solution. Add a scheduled task to your /etc/crontab file and use the curl command to excute any PHP script on your site. Example:
0 0 * * * * curl http://www.yoursite.com/yourscript.php
... then execute this in the terminal:
crontab crontab
For more info about crontab, see "Learning the Mac OS X Terminal: Part 1" <http://www.macdevcenter.com/pub/a/mac/2001/12/14/terminal_one.html>
-
i'm missing some lines in my httpd.conf
2002-10-27 21:45:27 anonymous2 [Reply | View]
These lines aren't here:
# For example, the PHP 3.x module will typically use:
#
# AddType application/x-httpd-php3 .php3
# AddType application/x-httpd-php3-source .phps
#
# And for PHP 4.x, use:
#
# AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
I assume since they are missing, that is why the index.php shows the html coding instead of what it's supposed to.
I'm running OSX 10.2.1 -
SOLUTION for OSX 10.2.x users (the missing lines)
2002-12-10 16:07:08 tronje [Reply | View]
I'm running 10.2.2
Just take a look at the lines below then you can easily find the position where you can add the missing lines.
...
<IfModule mod_negotiation.c>
LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
</IfModule>
# And for php4.x, use:
#
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
AddType application/x-tar .tgz
...
btw, if you want your browser to detect index.PHP just as it does index.html add the missing parts as shown below.
...
#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
DirectoryIndex index.html index.php index.shtml
</IfModule>
...
-
php paths
2002-10-23 07:46:38 anonymous2 [Reply | View]
When I use http://127.0.0.1/index.php everything works fine.
When I use file://localhost/Library/WebServer/Documents/index.php I get the "Gleefully..." part, but not the php info.
Is there a way to make file://localhost/Library/WebServer/Documents/index.php work???
Reason: I am developing web pages using Adobe GoLive and when I preview my files GoLive opens the files in Explorer using the file://localhost... path, and so far the php parts have been excluded.
Thanks for the series and any help you may be able to offer.
Craig -
php paths
2003-08-02 21:20:09 anonymous2 [Reply | View]
i'm having this exact same problem. when i'm online and go to http://localhost/somefolder/index.php, the files in Documents folder work fine.
if i unplug the ethernet cable and go to http://localhost i get nothing - that makes sense to me. BUT it i go to file://localhost/somefolder/index.php i get nothing - the files in the .php files in the Sites folder do not work.
any guidance would be great!!
thanks,
scott
ringworm@boardermail.com
-
*To anyone running Jaguar*
2002-10-09 13:03:42 anonymous2 [Reply | View]
I see some new messages on here regarding problems with Jaguar. Philocon gave a simple fix, and it worked for me when I tried it. In case you missed it, here it is:
When running through the article, you'll notice that the 3rd and 4th line that are commented on in httpd.conf do not exist. What you must do is add this line (I added it at the end with a comment):
AddType application/x-httpd-php .php
Your PHP test page should now work, and no longer shows up as simple text in your browser. -
*To anyone running Jaguar*
2002-10-10 16:06:49 sckz [Reply | View]
Please read the post below yours from me. Following the article works great, also for Jaguar. And my test.php looks beautiful.
But there every forum stops. Why do the scripts I use work on my ISP but not on my own server? Is it a server problem or permissions... what?
Can anyone help. The info page is starting to bore me :)
Thanks,
Sckz -
*To anyone running Jaguar*
2003-01-30 00:05:51 anonymous2 [Reply | View]
I got the same problem: all permissions at 777 throughout the file hierarchy & running as superuser - working scripts on my ISP running the same apache server refuse absolutely to work on Jaguar: only simple test.cgi etc will run.
-
PHP doesn't work but IS installed
2002-09-30 05:27:17 sckz [Reply | View]
First: this is a great site!
I followed the instructions for installing the PHP module. If I try http://127.0.0.1/index.php (like in the article) I see the long configuration file.
Now I tried a simple PHP script that saves a text you type. This script works on the server of my ISP so I think the script is ok. But it doesn't work on my Mac.
I use OS X 10.2.1. After installing - following the article - and trying my script, the error log tells me:
[Mon Sep 30 13:51:33 2002] [notice] Apache/1.3.26 (Darwin) PHP/4.2.3 configured -- resuming normal operations
[Mon Sep 30 13:51:33 2002] [notice] Accept mutex: flock (Default: flock)
[Mon Sep 30 13:59:09 2002] [error] [client 127.0.0.1] Invalid method in request
Is this a file permission problem? I have no idea what to do. Please let me know!
-
PHP is running, but scrambles HTML and shows up in Source-Code???
2002-09-26 09:56:37 anonymous2 [Reply | View]
I'm using Jaguar and installed PHP4.2 (according to this tutorial: http://www.entropy.ch/software/macosx/php/).
Everything seemed to be fine, php is working and obviously processing the PHP-Pages, but after the first PHP-Line, HTML becomes scrambled (i.e. it says means, it strips all '=' and '"' and so on). Plus: the PHP-Code is shown in the source code of the page...
What am I doing wrong?
I changed the httpd.conf like indicated in every tutorial and I also have the php.ini-file in the right place. Have to mention, that I installed Apache/PHP on Windoof-Systems already and that worked pretty fine...
Thanks for any help
Regards
Urs -
PHP is running, but scrambles HTML and shows up in Source-Code???
2002-10-01 17:53:39 philocon [Reply | View]
Hi
You write: "I changed the httpd.conf file like indicated in every tutorial." I cannot understand this. You cannot work through the article and make every change shown there because there are a few lines missing in Jaguar. Have you added them? Or is there another problem?
Please let me know
philocon
-
Re: PHP and Apache on Jacuar (OSX 10.2)
2002-09-22 13:25:16 anonymous2 [Reply | View]
Thank You!!!
The AddType solved my problem - once I remembered to do a Shift-Refresh.
-
Tomcat + Apache
2002-09-22 10:13:13 anonymous2 [Reply | View]
Please tell more about canfiguring Apache to use with Tomcat..
-
Apache + php + jaguar = no go?
2002-09-18 06:24:34 anonymous2 [Reply | View]
I did all that this article suggests to get php
working but I just get an error message with every php-file I try. It looks like this on the page:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] 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.
And in the Apache logs it looks like this:
[Wed Sep 18 15:13:57 2002] [error] (8)Exec format error: exec of /Library/WebServer/CGI-Executables/test.php failed
[Wed Sep 18 15:13:57 2002] [error] [client 1.1.1.1] Premature end of script headers: /Library/WebServer/CGI-Executables/test.php
Please help. I want to install SquirrelMail which is php-based. Already got sendmail and imap running.
/John
-
PHPost Permissions fix
2002-09-13 12:28:50 rymes60 [Reply | View]
Another post recommended changing the permissions on the PHPost directories to 777. This allows everyone to read, write, and execute all of the files. I may be wrong, but that is a security concern.
Either way, the Readme file for PHPost recommends the following:
If you are running PHP in safe mode, the directory will have to be chgroup'd to the same group that your web server runs as (usually 'nobody'). You will also want to change the permissions to "drwxrwx---" (that's 770).
changing the group to nobody didn't seem to work for me, so I changed the owner to www (AFAIK the same owner as Apache.). Then I changed the Permissions to 770 (only owner and group can read, write.) and everything works fine. Great little program.
Tom
-
PHP and Apache on Jacuar (OSX 10.2)
2002-09-12 07:55:48 anonymous2 [Reply | View]
Couldn't find this anywhere in my httpd.conf file:
# For example, the PHP 3.x module will typically use:
#
# AddType application/x-httpd-php3 .php3
# AddType application/x-httpd-php3-source .phps
#
# And for PHP 4.x, use:
#
# AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
So just typed in (without single quotes!)
'AddType application/x-httpd-php .php'
after
'AddType application/x-tar .tgz'
uncommented the loadModule and AddModule stuff , restarted Apache and everything worked fine.
-
HELP!!! Installed PHP now can't start Apache!
2002-09-11 09:09:08 sat150 [Reply | View]
I installed the php module from entropy.ch, and I might have typed something incorrectly at the terminal.
Since the installation I cannot start Apache. When I type 'apachectl graceful' I get the following error:
/usr/sbin/apachectl graceful: httpd not running, trying to start
Syntax error on line 816 of /etc/httpd/httpd.conf:
Invalid command '.phps', perhaps mis-spelled or defined by a module not
included in the server configuration
I opened the file, and line 816 just says 'phps', and it is uncommented (no hash).
Any help would be much appreciated.
-
RE: Where is my error???
2002-09-02 15:42:28 insomnis [Reply | View]
I had the same problem as Arellano. Fortunately the problem was a head-slapper. Select your index.php file, do a "show info" on it go to "Name & Extension" and uncheck "Hide extension". Renaming the file in the Finder had given the file the name index.php.shtml. Delete the last ".shtml" part, and the PHP should show up fine.
[sw]
-
Where is my error???
2002-08-12 14:23:00 arellano [Reply | View]
Ok, this article was great, unfortunately it doesnt work for me yet. Ok, here is the problem. I edited the httpd file and when i check the error_log (like the article suggests) I see:
[Mon Aug 12 01:51:20 2002] [notice] Apache/1.3.22 (Darwin) PHP/4.0.6 configured -- resuming normal operations
[Mon Aug 12 01:51:20 2002] [notice] Accept mutex: flock (Default: flock)
I have also saved a file test.php in my sites folder with the same code the article suggested.
Now when I go to view test.php at http://127.0.0.1/~username/test.php
I only see "Gleefully Served by Mac OSx" and no printout of php diagnostics.
what could i have done wrong? it says that php4 is enabled... i can see the page, but the php doesnt seem to be working.
please help>
:)
-
Where is my error???
2002-08-12 14:18:35 arellano [Reply | View]
Ok, this article was great, unfortunately it doesnt work for me yet. Ok, here is the problem. I edited the httpd file and when i check the error_log (like the article suggests) I see:
[Mon Aug 12 01:51:20 2002] [notice] Apache/1.3.22 (Darwin) PHP/4.0.6 configured -- resuming normal operations
[Mon Aug 12 01:51:20 2002] [notice] Accept mutex: flock (Default: flock)
I have also saved a file test.php in my sites folder with the same code the article suggested.
Now when I go to view test.php at http://127.0.0.1/~username/test.php
I only see "Gleefully Served by Mac OSx" and no printout of php diagnostics.
what could i have done wrong? it says that php4 is enabled... i can see the page, but the php doesnt seem to be working.
please help>
:)
-
Paste in LoadModule/AddModuleLines
2002-08-04 16:43:56 bobmoore [Reply | View]
Paste LoadModule/AddModule lines into the httpd.conf file if you can't find the lines. (I finally got it to work by doing so.)
-
edit PHP default settings
2002-07-19 20:57:23 cyndical [Reply | View]
First, this is a great series of articles. I can't believe that in the course of one day I've gone from 0 to getting a <?php phpinfo() ?> to work on my Mac!
Anyway, I want to change the 2M file size limit to, say 10, for starters. I can't get the script I have to upload a small gif file, so there's probably some other bit that has to be enabled/path names set.
I can't figure out how to find and edit the right file(s). I can find them in Terminal, but not outside of it.
Pointers? Suggestions? Please!
Thx
-
Permission problems
2002-07-05 06:19:35 morteniv [Reply | View]
Thank you for trying to help me out with the webserver in OS X 10.1. When I connect to my server trough a browser I get the index.html file fine (the whole site is at root level in the /library/webserver/documents). But when I hit one of my links to another index.html file I do not have permission to see file. This is the message:
You don't have permission to access /Blaasti/index.html on this server. I have changed the httpd.conf file to deny all and allow localhost (my IP).
What am I doing wrong?
Best regards,
morten -
Permission problems
2002-12-06 16:25:17 anonymous2 [Reply | View]
u might want to click on the folder containing the files, press apple-I to view its permissions, and there allow read permission to everyone...then click
on apply to all containing folders and file...
permission is probably just set for the index file as of now ..and not for all the containing files and folders
shak
-
I don't have an index.php file
2002-05-11 13:17:50 mknauf [Reply | View]
I even searched the whole drive for "index.php" no joy... should I worry / how can I tell it's really working?
-
problem with Volumes
2002-05-07 01:38:35 wilseven [Reply | View]
Hi -
your articles are really great. Are they all in a book somewhere yet? a webserving for OS X book on the way?
Anyway - I wanted to maybe move my document root to another volume, but I have this problem with OS X where it's saying there are a bunch of volumes at /Volumes, even though they've been disconnected. This unfortunately includes even my local volume, which currently reads "Mercury 1" because one of the junk volumes has the name "Mercury". So it seems like it's not refreshing the volume info correctly, which would be a problem when I assign doc root on a volume and os x decides to mount it with a new name...
Any help? I looked around for a LONG time before posting...
Michael
mt@motiontek.com
-
Missing LoadModule/AddModule Lines
2002-04-09 15:52:10 d_simmons [Reply | View]
Apple just issued a security upgrade which includes PHP v4.1.2. As with other posters, I didn't have the Load/Add Module lines in my httpd.conf file. After pasting them at the end of the other lines, I restarted Apache, and PHP started with it. whee.
This article has been extremely useful. I'm a University student doing a senior project which requires Apache/PHP/MySQL and is to be served from a RedHat machine to Windows clients. I'll be doing most of the development and testing on my Grape iMac running OS X, and I'm going to use it as an internet server so my project teammates can ftp to it and test from their homes.
The author might want to update part 3 of this article, to let folks know that some installs are missing those two lines, and that they need to insert them themselves. It might save someone from having to forage through these posts.
Thanks again for the much needed info.
Now, off to a team meeting, to get another dig in on my WinTel compadres. Bweh heh heh.
-
Missing LoadModule/AddModule Lines
2002-04-16 17:14:10 Kevin Hemenway [Reply | View]
>Now, off to a team meeting, to get another dig
>in on my WinTel compadres. Bweh heh heh.
Exactly! :)
-
Help!!! Error in the httpd file
2002-04-07 23:37:29 plastic1 [Reply | View]
I keep getting this error: Syntax error on line 37 of /private/etc/httpd/httpd_macosxserver.conf:
Invalid command 'LoadModule', perhaps mis-spelled or defined by a module not included in the server configuration
Any Ideas on how solve this... I think I've corrupted the config files of apache trying to upgrade to apache 2.*. I have a mac os x server but when I tryed to install php4lib it broke all... I need your help, and also a good way to make work php, apache and mysql on my mac! -
Help!!! Error in the httpd file
2002-04-16 17:09:01 Kevin Hemenway [Reply | View]
There have been reports of PHP having problems compiling with 2.0 on OS X - I'm not going to be getting into 2.0 discussions until Apple releases something official on their end (which hopefully will be with a 10.2 release, but if they don't, it won't surprise me).
Generically speaking, a LoadModule error means either a) you're missing a matching AddModule line or b) the module in question is broken. If you had problems building PHP, then there's a good chance that the module on line 37 is the PHP module. Commenting it (by placing a # in front of that line) should give you (at the very least) a different error message.
As for MySQL, there are instructions on how to install it on OS X in part five of this series.
-
PostgreSQL
2002-03-30 10:57:47 Michael Brewer [Reply | View]
I would like to see an article on setting up Postgres on OS X.
-
Should this work on osX 10.1.3 ?
2002-03-27 03:19:55 sba [Reply | View]
Sorry this should be sitting at the bottom of the 4 th article!
I suppose it all fits in whith the Trilogy thing !
Ie not what is should be!
sba!
-
Should this work on osX 10.1.3 ?
2002-03-26 16:56:33 sba [Reply | View]
Hi I've been trying to set up .htaccess on a standard osX 10.1.3 machine I've gone thru the article and I think I've got all the right files in the right places but it still lets me in to any site / Subsite I build!
I did a search on .htaccess on apples site and came accross this and was wondering does it have any relavence?
http://www.apple.com/support/security/security_updates.html
Thanks in advance
Steve
-
Allow from....
2002-03-22 03:38:26 redleader [Reply | View]
Hi,
I want to set allow from to a batch of IP numbers, namely:
any 90.0.0.*
any 127.0.0.*
I read the apache manual and tried;
Allow from 90.0 but it did not work and also it did not mention multiple IP range allows. -
Allow from....
2002-03-22 09:02:04 Kevin Hemenway [Reply | View]
Allow from 90.0 should have definitely worked for you - when you were denied, did you check your error_log file to see the matching IP that it was denying? If you're previewing locally, it may have seen you as 127.0 instead.
As for multiple ranges, just replicate the "Allow from" line - you can have as many as you want:
Allow from 90.0.0
Allow from 127.0.0
-
tutorial on MySQL please
2002-03-20 20:57:38 clappazon [Reply | View]
You said to comment if you wanted a continuing tutorial on database implementation. Please give us a MySQL setup for the Mac tutorial. This whole series has been exceedingly informative and has broken the wall of ignorance I had built around configuration files and investigating the powers of Mac OS X. I would love to get MySQL up and running.
Thanks! -
tutorial on MySQL please
2002-03-22 08:58:29 Kevin Hemenway [Reply | View]
Your wish is my command, see part 5 of this series.
-
index.php empty
2002-03-19 19:16:08 driftkop [Reply | View]
Hi,
I found the problem. To test the file, I dragged the index.php file to my browser icon, and thus the server looked for:
file://localhost/Users/koen/Sites/index.php
instead of for:
http://127.0.0.1/~koen/index.php
For the latter, it worked fine.
Thanks for your fast response, and for this great series!
- Koen.
-
index.php empty
2002-03-19 10:52:37 driftkop [Reply | View]
Hi,
Although I can see that php is enabled in the httpd.error log, I get an empty screen when I load the index.php file. I have my files in /Users/koen/Sites/ and use my own koen.conf file, so maybe in this case I need to add some more lines in my configuration file?
thanks,
- Koen.
-
index.php empty
2002-03-19 14:15:23 Kevin Hemenway [Reply | View]
Nope - PHP, by default, is on for every user, regardless of their configuration. Are you sure you uncommented the "AddType" lines? These lines tell the PHP module that .php files should be interpreted - if they're not there, then the browser would just send the results straight to the window, with no processing.
Check that the AddType's are uncommented, and check that the phpinfo line is correctly in that file. Then, load it in your browser, and if there's still nothing there, do a "view source" and see if there's anything in the HTML.
-
no access through 127.0.0.1
2002-03-15 08:06:42 axel_vogelsang [Reply | View]
hello,
First of all thanks for that great series. I have a little problem though. Everything is running and I can access all my Files in my user folder and on the root level through the browser. But as soon as I exchange the "Allow from all" in the httpd.conf with my ip-adress, the access is denied. Please help. Thanks
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride None
Order deny,allow
Deny from all
Allow from 217.37...
</Directory>
-
no access through 127.0.0.1
2002-03-15 12:22:10 Kevin Hemenway [Reply | View]
Couple of notes:
When you add the "Allow" from line, are you using your full IP address, or the example shown above (this is a stupid question, but I just have to make sure)? If you're using the 217.37 with three periods after it, it will fail.
The entry above will *only* work on your root directory (not your user directories0. So, when you access your root directory and get denied, check your error_log - there's a good chance that you're actually browsing as 127.0.0.1, and not the 217 address. The error_log will report what IP is being denied.
-
phpost pop connection fails
2002-03-01 19:42:31 dicklacara [Reply | View]
phpost installs OK, but login fails in the following code segment in phpost.php.
$sockel has no value after the fsockopen
$errno is 61
$errstr is Connection refused
Code Segment
---------------------
// Open connection
$socket = fsockopen( $h, $p, $errno, $errstr, 15 );
if( ! $socket )
{
$errstr = "Connection refused (" . $prefs["pop"] . ")";
return false;
}
-
PHP.INI
2002-02-27 12:35:21 kuacweb [Reply | View]
OK, this is driving us crazy - in order to tell PHP where to route mail created with the mail() tag, you have to specify a SMTP server. Everything I've seen says this can be done in PHP.INI, which is the PHP configuration file. We can't find this file anywhere on our OsX box. It's a standard install. Anyone know where this is supposed to exist under OsX or what it might be called? Thanks! -
PHP.INI
2003-06-29 08:00:18 anole [Reply | View]
Well, shoot. Got PHP.INI to be read, and the mail variables set correctly. But now my sent mails from the php-based pMachine... instead of erroring like they did before, they just disappear into the ether. -
PHP.INI
2002-03-02 06:14:16 kkohler [Reply | View]
In the FAQ part of this website http://www.entropy.ch/software/macosx/php/ is written, that you have to create the php.ini in order to get mail() worked. For more information go to the website. Greetings Klaus -
PHP.INI - correct path
2002-04-26 18:34:51 lyle [Reply | View]
Unfortunetly for me the Entropy site specifies a path (/usr/local/lib/php.ini) that did not work for my system (OSX.1.4) - the path that finaly worked is /usr/lib/php.ini
Take a look at the output of a <?php phpinfo() ?> - item six (Configuration File) specifies where your instilation is looking for the php.ini file. -
PHP.INI
2002-03-04 08:46:45 kuacweb [Reply | View]
Thanks! We tried it and it works, however, has anyone noticed a slow response on mail forms? Everything else seems very fast, PHP or not - but the mail forms can take up to 15-20 seconds even for a very simple form.
-
rebol meets apache on MacOS X
2002-02-26 12:38:26 usaps [Reply | View]
Well, first hello...
Kevin Hemenway... Very cool articles! I'm really learning a lot; but I've got a little problem I cannot make OS X Apache run my Rebol scripts... i really cannot!
I need help...
THANKS in advance.
jero
-
Appreciation
2002-02-24 17:58:43 mgoins11 [Reply | View]
Thank You for offering this series. It has been very educational to this newbie. I'll anxiously wait to see where ti goes next.
-
Installing the imap extension for php
2002-02-23 04:11:18 kkohler [Reply | View]
First of all congratulations for this great tutorial. I really learned a lot. The only thing I'm still working on ist how to install the IMAP extension for php on Mac OS X. Can anybody help me?
Thanks Klaus Kohler -
Installing the imap extension for php
2002-02-25 08:26:54 Kevin Hemenway [Reply | View]
Klaus,
The next planned in the series (part 5) will be about installing MySQL and PostgreSQL databases. As part of that, we'll be taking a quick look at recompiling PHP. I'll see if I can make mention of the IMAP extension. Just be on the lookup for the fifth article (which should be out in a few weeks).
-
Outside users can't connect
2002-02-03 00:22:04 audiophyle [Reply | View]
I am new to web serving, so please excuse me if I miss something seemingly obvious.
I have several computers connected to a Linksys Etherfast Wireless Access Point + Cable/DSL Router with 4 port switch, including a Powerbook using Airport, a PowerMac G4, and two Windows PCs. This is connected to a Cisco DSL Router, which receives a dynamically assigned IP address. I started the Apache server just fine, and I can access the web pages fine since I'm on the LAN, but outside users cannot access this website. I realize that this probably has something to do with the dynamic IP address, and the firewall created by my Linksys device, but how do I get around this? What do I need to do in order to have a web server that everyone can see? -
Outside users can't connect - me too
2002-02-03 03:26:06 pattyb777 [Reply | View]
Thanks for posting this. I too have a PC and a Mac networked with a router (SMC) and airport base station. My Mac's IP address is dynamic and my router has a firewall. I can't see what's on my apache web server on my other computer. There must be a way around this!
Patty -
Outside users can't connect - me too
2002-02-06 07:42:16 swanilda [Reply | View]
Same problem here. I went to the URL for the IP detection. http://www.checkipdyndns,org, got the actual IP address I am using as opposed to the router's, but I still can't get past the firewall. Perhaps there are settings regarding this? -
Outside users can't connect - me too
2002-03-03 00:49:45 piddle_spank [Reply | View]
i am on Cable with router PCs and Macs ect. i still have not figured this out yet but heres what i have done so far.
in the router software i have put fixed mapping on my IP so that always get the same IP.
opened ports 80 + 999 on my firewall. then changed the httpd_conf.pm file so that it trys port 999 instead of 80.
made my computer a 'DMZ' which means its no longer protected by the routers firewall.
but still no luck :(
-
Web Server won't start - please help
2002-02-02 14:32:51 pattyb777 [Reply | View]
I've been doing this series and loving it, but I think I made mistake in my httpd.conf file. The last time I stopped and started the web server, it tried to start but never actually started. It just keeps saying it is starting.
The section in question is as follows:
============
DocumentRoot "/Library/WebServer/Documents"
#
# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# permissions.
#
<Directory "/">
Options Indexes FollowSymLinks MultiViesw
AllowOverride None
Order allow,deny
Allow from all
</Directory>
==========
When empowering SSI, I edited this section by mistake. Can someone please check their file to see what it should say?
The other changes I made were to add these lines at the end of the other lines like them:
LoadModule php4_module libexec/httpd/libphp4.so
AddModule mod_php4.c
and uncomment these lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
All help will be appreciated!
-
Why two httpd.conf files?
2002-02-01 12:14:56 galt606 [Reply | View]
I was reading the documentation for OS X Server and came across /private/etc/httpd/httpd.conf. Which one is for what? Why are there two? Does it make a difference? WHAT IS GOING ON HERE!?! -
Why two httpd.conf files?
2002-02-01 14:37:21 Kevin Hemenway [Reply | View]
It does not make a difference. /private/etc and /etc point to the same place - it's like an alias (in Linux, it's called a "symlink").
-
PHPost works - but does not display correctly
2002-01-30 14:29:07 cpaulu [Reply | View]
I downloaded PHPost and got it to work, but it does not correctly display the text (e.g., "username") that it pulls from the language file "phpost_English.inc"
Instead, everything ends up with just a "T": "T" instead of "username", "T" instead of "password", "login" etc.
I tried changing the language, and it didn't work either.
Anyone know what this is about?
-
PHPost works - but does not display correctly
2002-01-31 14:43:49 Kevin Hemenway [Reply | View]
I don't, unfortunately. I mainly chose PHPost as an example in the article, because it didn't use any sort of database, which would have made it a bad example. Your best bet, unless someone else answers here, is to contact the author directly.
-
Missing LoadModule php4
2002-01-30 09:17:51 stepgo [Reply | View]
I've have the same problem as a previous post. I don't have the lines LoadModule php4_module an AddModule etc...
Can I add these lines to the config code?
If so could you tell me in what order they must be ?
Thanx
PS I've just found this site and it's great
-
OK we can add these....
2002-01-30 09:23:27 stepgo [Reply | View]
But on what line exactly ? -
OK we can add these....
2002-01-30 13:56:31 Kevin Hemenway [Reply | View]
Two different places, actually.
Add the "LoadModule" line as the last of the "LoadModule" lines in your httpd.conf (you should see a good 20 of 'em in a row).
The AddModule line follows the same mentality. Look for a bunch of AddModule lines, and add the "AddModule" php line to the end of them.
-
Apache to Classic
2002-01-28 10:51:59 fallenaristocrat [Reply | View]
Can I run Classic and IE in Classic (not in OSX) and connect to the Apache server.
I tried and got kernal panic - I actually had to restart OSX for the first time
REASONS - I want to develop in shockwave
(Director) and theres no plug-in for OSX yet.
regards -
Apache to Classic
2002-01-28 11:16:00 Kevin Hemenway [Reply | View]
I coulda swore Macromedia just came out with Shockwave for OS X - be sure to check VersionTracker.com on that one.
As for the Classic to OS X, yes, you can, but you may have to use your actual IP address when trying to view the pages.
Since Classic is an emulator, it might get its own "localhost" and "127.0.0.1" -- different than the "localhost" and "127.0.0.1" used by OS X. In that case, if you were in Classic IE and tried either of those, it'd look for a Classic server, and not the one you have running under OS X.
-
please do an article on mysql on osx
2002-01-26 13:43:25 dan@visual-contact.com [Reply | View]
I'd really like to see an article on configuring mysql on os x with php. I have had no problem getting php up and running, but mysql is giving me all kinds of problems. I can't get them to play well together.
/dan
-
Apache Web-Serving-Mac OS X: Part: ALL
2002-01-26 13:12:35 hylas [Reply | View]
Thank you for quality subject, manner and solid ground floor reporting - instruction.
Refreshing.
Hylas
-
Another vote to continue
2002-01-23 15:12:26 djwudi [Reply | View]
Hey Morbus -
Just another vote to continue. Thanks for what we've got so far...looking forward to more.
Now I just need to go get a couple books on php/sql and see if I can get the monstrosity cooking in my brain to come to fruition...lol :)




I am running Mac OS X 10.4 with Apache 1.3 and PHP 5.
I do not see what could be wrong with my httpd.conf. If any of you want, I could put a copy on my web server's index.html.en and put a link here.
Thanks.