[TriLUG] Localhost web server

Brian Henning brian at strutmasters.com
Thu Sep 8 08:35:12 EDT 2005


Hi Matt,
   Presuming you have Apache correctly configured (usually the defaults 
are enough to get you going just for localhost-only operation)...  Say 
in httpd.conf, you have:

DocumentRoot /var/www/htdocs

..and a matching Directory with appropriate options set, such as:

<Directory "/var/www/htdocs">
  Order deny,allow
  Allow from all
</Directory>

...then in your /var/www/htdocs directory, you have, for example, a file 
named "index.php" that contains the following:

<html>
  <body>
<?php
   echo "Goodbye, cruel world!";
?>
  </body>
</html>

Then when you point your browser to http://localhost , you should see:

Goodbye, cruel world!

The general answer to your question, however, is you always ask Apache 
for the file you want.  So if your file is bobsfile.php, you'd ask for 
http://localhost/bobsfile.php

Note that Apache determines the need for mod_php based on extension.  So 
if you have a file with a .html extension with php code in it, you'll 
get the code in your browser instead of the results of its execution. 
So to continue the above example, if you had named the file index.html, 
you'd have seen:

<?php
   echo "Goodbye, cruel world!";
?>

in your browser.

HTH,
~Brian


matt-nc wrote:
> I installed Mandriva 10.1 with every possible package selected.  It 
> appears that Apache and PHP are functioning and correctly integrated 
> because I got a server error message that seemed to indicate that Apache 
> 2.0.50, mod_perl, perl, mod_ssl and PHP/4.3.8 were all running, even 
> though it couldn't find the file I specified.
> 
> My question is, what do I type in the URL window to get Apache to serve 
> up a PHP file?
> 
> My objective is to be able to have Apache and PHP running so that I can 
> work on PHP and MySQL programming while I am at the library and have no 
> access to the internet.
> 
> I added the following line to the Apache httpd2.conf file as my PHP book 
> instructed:
> 
> AddType application/x-httpd-php .php
> 
> Any advice or links to good online tutorials about using Apache for a 
> localhost web server w/ PHP would be appreciated.
> 
> Thanks,
> Matt
> 



More information about the TriLUG mailing list