469,282 Members | 1,624 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Apache Server, PHP, home page

I have a couple easy questions possibly.

1) Is there a default.php page? The webserver seems to
support default.htm, default.html, index.htm and index.html.
It's an Apache server, I'd like to know if a default.php
exists, or how to set it.

2) I'm getting some some strange results...

My doctype.php file contains:

<?php
$sDoc='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html>\r\n<head>\r\n';
?>

My html file contains:

<?php
require('static/doctype.php');
echo($sDoc);
?>

The file is named default.htm. The HTLM presents.

<?php
require('static/doctype.php');
echo($sDoc);
?>
<!--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
-->

So it appears either I need to tell PHP to process html, htm
files or I need to find a way to set the apache server to use
a default.php or whatever. Is that correct?

Pagenames with a ".php" extension do work. Thanks much.

--
Jim Carlock
Post replies to the newsgroup, thanks.
Nov 22 '05 #1
14 2224
And one more Apache related question.

IIS servers use a global.asa file in the root of the web
for a variety of things including setting up odbc, and
misc other settings.

There's also a way to turn on an anonymous default file,
a file that gets presented when someone browses to
a folder with no default document. How do I achieve
this with an Apache server?

--
Jim Carlock
Post replies to the newsgroup, thanks.
Nov 22 '05 #2
Jim Carlock (an*******@127.0.0.1) wrote:
: I have a couple easy questions possibly.

BTW: there is at leats one apache group that would be your best bet for
apache setup questions.

: 1) Is there a default.php page? The webserver seems to
: support default.htm, default.html, index.htm and index.html.
: It's an Apache server, I'd like to know if a default.php
: exists, or how to set it.

Look in http.conf (for me that's /etc/httpd/conf/httpd.conf).

I think "DirectoryIndex" is probably what you want to investigate.
: 2) I'm getting some some strange results...

: My doctype.php file contains:

: <?php
: $sDoc='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html>\r\n<head>\r\n';
: ?>

: My html file contains:

: <?php
: require('static/doctype.php');
: echo($sDoc);
: ?>

: The file is named default.htm. The HTLM presents.

: <?php
: require('static/doctype.php');
: echo($sDoc);
: ?>
: <!--
: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
: <html>
: -->

: So it appears either I need to tell PHP to process html, htm
: files or I need to find a way to set the apache server to use
: a default.php or whatever. Is that correct?

huh?

If you setup the php module in apache then (normally) the extension .php
will be recognized by apache as indicating a file containing php.

: Pagenames with a ".php" extension do work. Thanks much.

There you go, just like I said but I hadn't read this far. Apache is
recognizing .php as php, and .html as html, correctly, just like you want
(though you don't realize that yet).

I am pretty sure the "DirectoryIndex" in your http.conf file is what you
are looking for.

Nov 22 '05 #3
Jim Carlock wrote:
I have a couple easy questions possibly.

1) Is there a default.php page? The webserver seems to support
default.htm, default.html, index.htm and index.html. It's an Apache
server, I'd like to know if a default.php exists, or how to set it.
Same way you set default.htm, default.html, index.htm and index.html! ;-)

BTW: Aside from perhaps Win 9X, filenames can have more than 3 character
extensions so personally I'd nix the .htm's. Also default.html is an
IIS'ism and IMHO has no place in Apache!

Seriously though, assuming PHP is configured simply add it to the list
of DirectoryIndex in your httpd.conf file and restart Apache.
2) I'm getting some some strange results...

My doctype.php file contains:

<?php
$sDoc='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html>\r\n<head>\r\n';
?>

My html file contains:

<?php
require('static/doctype.php');
echo($sDoc);
?>

The file is named default.htm. The HTLM presents.

<?php
require('static/doctype.php');
echo($sDoc);
?>
<!--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
-->

So it appears either I need to tell PHP to process html, htm files or
I need to find a way to set the apache server to use a default.php or
whatever. Is that correct?
HTML files are for static content. PHP files (indicated by a suffix of
..php) can contain PHP code. You don't want to be making Apache parse all
your .html files looking for PHP! You want Apache to only consider .php
files as having PHP.
Pagenames with a ".php" extension do work. Thanks much.


Ah, so then PHP is not set up with your Apache server then. IOW if you
browse to http://<host>/<somefile>.php and you have some real executable
PHP in there (let's say just an echo "Hi mom!") you are not just seeing
"Hi mom!". That's a different issue that brings up more questions like
where are you running Apache? What version? Have you installed PHP? Have
you configured Apache to know about PHP? etc.
Nov 22 '05 #4
Andrew DeFaria wrote:
Pagenames with a ".php" extension do work. Thanks much.

Correction! My mind inserted a "not" between "do" and "work" above.
Ignore the following paragraph... Sorry.
Ah, so then PHP is not set up with your Apache server then. IOW if you
browse to http://<host>/<somefile>.php and you have some real
executable PHP in there (let's say just an echo "Hi mom!") you are not
just seeing "Hi mom!". That's a different issue that brings up more
questions like where are you running Apache? What version? Have you
installed PHP? Have you configured Apache to know about PHP? etc.


Nov 22 '05 #5
Jim Carlock wrote:
And one more Apache related question.

IIS servers use a global.asa file in the root of the web
for a variety of things including setting up odbc, and
misc other settings.

There's also a way to turn on an anonymous default file,
a file that gets presented when someone browses to
a folder with no default document. How do I achieve
this with an Apache server?

--
Jim Carlock
Post replies to the newsgroup, thanks.


Check the Apache doc.

There is no "default" page in Apache, other than what you specify in the
httpd.conf file. Often this is index.html, default.htm or similar - but
it's whatever you specify.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 22 '05 #6
"Andrew DeFaria" <An****@DeFaria.com> wrote:
Same way you set default.htm, default.html, index.htm
and index.html! ;-) BTW: Aside from perhaps Win 9X, filenames can
have more than 3 character extensions so personally
I'd nix the .htm's. Also default.html is an IIS'ism and
IMHO has no place in Apache!
Thanks, Andrew.

Yeah, yeah, yeah. <g> I like 8.3 filenames a heck of a
lot better than 48000 character filenames. You caught
onto my Microsoft DOS roots.

The first question I asked... I answer...

"The default.php page name ends up as index.php."

The second message asked for a "default 404 page". I
couldn't quite get a fix on what it was called. Looked it
up though from a site I visited five years ago.
Seriously though, assuming PHP is configured simply
add it to the list of DirectoryIndex in your httpd.conf
file and restart Apache.
:-) Okay that'll give me something to search for. I don't
see the file, "httpd.conf", so is there a .PHP way to read
it? I don't own the server, it's a subscriber issue. I'll start
looking over the apache website in the meantime. Thanks
for the hint.
HTML files are for static content. PHP files (indicated
by a suffix of .php) can contain PHP code. You don't
want to be making Apache parse all your .html files
looking for PHP!
Why not? Don't answer it. <g> I almost see where you
could go with it.
You want Apache to only consider .php files as having
PHP.
And I don't want html to try rendering .php code either.
So I'll stick with the the accepted response that few, if any
one, performs such things.
Ah, so then PHP is not set up with your Apache server
then. IOW if you browse to http://<host>/<somefile>.php
and you have some real executable PHP in there (let's say
just an echo "Hi mom!") you are not just seeing "Hi mom!".
That's a different issue that brings up more questions
like where are you running Apache?
PHP was set up with the server... but I'm not coming from
a PHP background nor a Unix background. I'm coming
from DOS 8.3 / Windows9x / NT. It's a hosted solution.
My Unix experience is almost null. My PHP experience
compares miserably to experience with IIS 5, but
compares favorably to my Unix experience. I ended up
reinstalling Windows 98 on the computer that I toyed with
Unix on in the past. <g>
What version? Have you installed PHP? Have
you configured Apache to know about PHP? etc.


The Apache/PHP versions...

Server: Apache/1.3.31 (Unix)
PHP/4.3.11
mod_ssl/2.8.18 OpenSSL/0.9.6b

Thanks much.

--
Jim Carlock
Post replies to the newsgroup, thanks.
Nov 22 '05 #7
"Jerry Stuckle" <js*******@attglobal.net> posted:
There is no "default" page in Apache, other than what
you specify in the httpd.conf file. Often this is index.html,
default.htm or similar - but it's whatever you specify.


Thanks Jerry.

Another question to anyone that has an answer...

<?php
require ("doctype.htm");
$sDoc=$sDocType.'<html>\r\n<head>\r\n';
$sDoc.='<title>Test.php</title>\r\n';
$sDoc.='</head>\r\n';
$sDoc.='<body>\r\n';
$sDoc.='<p align="center">hello world</p>\r\n';
$sDoc.='</body>\r\n';
$sDoc.='</html>\r\n';
echo ($sDoc);
?>

How do I add a newline using PHP? Also, CAN the
httpd.conf file be accessed via PHP? Or if there's a
client-based (web/subweb-based) file rather than the
system-wide based file, what's the name and can I
get to via PHP?

--
Jim Carlock
Post replies to the newsgroup, thanks.
Nov 22 '05 #8
Jim Carlock wrote:
"Jerry Stuckle" <js*******@attglobal.net> posted:
There is no "default" page in Apache, other than what
you specify in the httpd.conf file. Often this is index.html,
default.htm or similar - but it's whatever you specify.

Thanks Jerry.

Another question to anyone that has an answer...

<?php
require ("doctype.htm");
$sDoc=$sDocType.'<html>\r\n<head>\r\n';
$sDoc.='<title>Test.php</title>\r\n';
$sDoc.='</head>\r\n';
$sDoc.='<body>\r\n';
$sDoc.='<p align="center">hello world</p>\r\n';
$sDoc.='</body>\r\n';
$sDoc.='</html>\r\n';
echo ($sDoc);
?>

How do I add a newline using PHP? Also, CAN the
httpd.conf file be accessed via PHP? Or if there's a
client-based (web/subweb-based) file rather than the
system-wide based file, what's the name and can I
get to via PHP?

--
Jim Carlock
Post replies to the newsgroup, thanks.


httpd.conf is a system-wide configuration file. If you are on a shared
host, you don't have access to this file.

Otherwise, it is a text file so it could be read by PHP, but you're much
better off using a text editor and changing it manually (back it up
first!). Parsing it is a lot of work!

For local configuration changes, you can use .htaccess. See the Apache
doc at www.apache.org for how to use it. It's all in there.

As for the newline - you add it with \n. But HTML parsing will ignore
newline characters (you can still see them if you view the source).
Here you need to use an HTML <br>. See the HTML doc at www.w3.org.

And at least TRY to find the answer before asking questions!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 22 '05 #9
Jim Carlock wrote:
BTW: Aside from perhaps Win 9X, filenames can
have more than 3 character extensions so personally
I'd nix the .htm's. Also default.html is an IIS'ism and
IMHO has no place in Apache!
Thanks, Andrew.

Yeah, yeah, yeah. <g> I like 8.3 filenames a heck of a
lot better than 48000 character filenames. You caught
onto my Microsoft DOS roots.


idont.txt unders~1.txt why.txt you.txt would.txt prefer.txt eight.txt
dot.txt three.txt filena~1.txt! ;-)
The first question I asked... I answer...

"The default.php page name ends up as index.php."

The second message asked for a "default 404 page". I
couldn't quite get a fix on what it was called. Looked it
up though from a site I visited five years ago.
You're looking for error documents...
Seriously though, assuming PHP is configured simply
add it to the list of DirectoryIndex in your httpd.conf
file and restart Apache.


:-) Okay that'll give me something to search for. I don't
see the file, "httpd.conf", so is there a .PHP way to read
it?


Why would you use PHP to read a file? Is everything a web page for you?
Do you use PHP as your editor?!?
I don't own the server, it's a subscriber issue.
Then you need to talk to the server administrator and ask him to make
that change.
I'll start
looking over the apache website in the meantime. Thanks
for the hint.
HTML files are for static content. PHP files (indicated
by a suffix of .php) can contain PHP code. You don't
want to be making Apache parse all your .html files
looking for PHP!
Why not? Don't answer it. <g> I almost see where you
could go with it.
You want Apache to only consider .php files as having
PHP.


And I don't want html to try rendering .php code either.


What is "html" in this context? PHP is a programming language. HTML is a
markup language that instructs a program how to render the text and
images. How could html render PHP code?!?
So I'll stick with the the accepted response that few, if any
one, performs such things.
Ah, so then PHP is not set up with your Apache server
then. IOW if you browse to http://<host>/<somefile>.php
and you have some real executable PHP in there (let's say
just an echo "Hi mom!") you are not just seeing "Hi mom!".
That's a different issue that brings up more questions
like where are you running Apache?
PHP was set up with the server... but I'm not coming from
a PHP background nor a Unix background. I'm coming
from DOS 8.3 / Windows9x / NT.


My condolences! ;-)
It's a hosted solution.
My Unix experience is almost null. My PHP experience
compares miserably to experience with IIS 5, but
compares favorably to my Unix experience. I ended up
reinstalling Windows 98 on the computer
Gotta love these people using 7 (coming on 8) year old OSes and trying
to grasp the latest technologies...
that I toyed with
Unix on in the past. <g>
What version? Have you installed PHP? Have
you configured Apache to know about PHP? etc.


The Apache/PHP versions...

Server: Apache/1.3.31 (Unix)
PHP/4.3.11
mod_ssl/2.8.18 OpenSSL/0.9.6b

Thanks much.


So are you saying that if you place a file named index.php in a
directory and browse there the PHP is not executed? If so then it's a
server configuration issue and you must speak to the server admin to
have that fixed.
--
What is a free gift? Aren't all gifts free?

Nov 22 '05 #10
"Jerry Stuckle" <js*******@attglobal.net> posted:
As for the newline - you add it with \n. But HTML
parsing will ignore newline characters (you can still
see them if you view the source). Here you need to
use an HTML <br>.

And at least TRY to find the answer before asking
questions!


Okay. :-)

The doctype.php file:
<?php
$sDocType='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n';
?>
The index.php file:
<?php
require ("doctype.php");
$sDoc=$sDocType.'<html>\r\n<head>\r\n';
$sDoc.='<title>Test.php</title>\r\n';
$sDoc.='</head>\r\n';
$sDoc.='<body>\r\n';
$sDoc.='<p align="center">hello world</p>\r\n';
$sDoc.='</body>\r\n';
$sDoc.='</html>\r\n';
echo ($sDoc);
?>

The html results:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html>\r\n<head>\r\n<title>T est.php</title>\r\n</head>\r\n<body>\r\n<p
align="center">hello world</p>\r\n</body>\r\n</html>\r\n

The html did not ignore the newline characters. The PHP
script ignored \n and \r. The newsreader broke up the
lines in this post because I can't set it greater than 128
characters. <shrug>

Parsing through

"custom 404" site:apache.org

returns some hits.

Another customized search...

"custom 404" group:alt.apache.configuration

at http://groups.google.com/ returns some links.

Nothing definitive yet... I'll keep looking. :-)

--
Jim Carlock
Post replies to the newsgroup, thanks.
Nov 22 '05 #11
Jim Carlock wrote:
Okay. :-)

The doctype.php file:
<?php
$sDocType='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n';
?>

The index.php file:
<?php
require ("doctype.php");
$sDoc=$sDocType.'<html>\r\n<head>\r\n';
$sDoc.='<title>Test.php</title>\r\n';
$sDoc.='</head>\r\n';
$sDoc.='<body>\r\n';
$sDoc.='<p align="center">hello world</p>\r\n';
$sDoc.='</body>\r\n';
$sDoc.='</html>\r\n';
echo ($sDoc);
?>


Why not simply:

<?php
require ("doctype.php");
echo $sDocType;
?>
<html>
<head>
<title>Test.php</title>
</head>
<body>
<p align="center">hello world</p>
</body>
</html>

I mean isn't the beauty of PHP the fact that it can be interspersed
amongst the html?
--
Dumb Question Department: Been swimming. Smart Answer: No, I was out
walking my pet fish!

Nov 22 '05 #12
On Wed, 16 Nov 2005 04:29:26 GMT, "Jim Carlock" <an*******@127.0.0.1>
wrote:

The html did not ignore the newline characters. The PHP
script ignored \n and \r.


PHP doesn't parse backslashed characters in single-quoted strings. If
you use double-quotes on your strings, it will work as expected.

Nov 22 '05 #13
Jim Carlock wrote:
"Jerry Stuckle" <js*******@attglobal.net> posted:

As for the newline - you add it with \n. But HTML
parsing will ignore newline characters (you can still
see them if you view the source). Here you need to
use an HTML <br>.

And at least TRY to find the answer before asking
questions!

Okay. :-)

The doctype.php file:
<?php
$sDocType='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n';
?>
The index.php file:
<?php
require ("doctype.php");
$sDoc=$sDocType.'<html>\r\n<head>\r\n';
$sDoc.='<title>Test.php</title>\r\n';
$sDoc.='</head>\r\n';
$sDoc.='<body>\r\n';
$sDoc.='<p align="center">hello world</p>\r\n';
$sDoc.='</body>\r\n';
$sDoc.='</html>\r\n';
echo ($sDoc);
?>

The html results:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n<html>\r\n<head>\r\n<title>T est.php</title>\r\n</head>\r\n<body>\r\n<p
align="center">hello world</p>\r\n</body>\r\n</html>\r\n

The html did not ignore the newline characters. The PHP
script ignored \n and \r. The newsreader broke up the
lines in this post because I can't set it greater than 128
characters. <shrug>

Parsing through

"custom 404" site:apache.org

returns some hits.

Another customized search...

"custom 404" group:alt.apache.configuration

at http://groups.google.com/ returns some links.

Nothing definitive yet... I'll keep looking. :-)

--
Jim Carlock
Post replies to the newsgroup, thanks.

Ah, one thing I missed.

It needs to be "\n", not '\n'. Special characters are valid only within
double quotes; in single quotes they are just the individual chars '\'
and 'n'.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 22 '05 #14
"Jerry Stuckle" <js*******@attglobal.net> wrote:
It needs to be "\n", not '\n'. Special characters are valid
only within double quotes; in single quotes they are just
the individual chars '\' and 'n'.


You are absolutely correct. Thanks, much. :-)

--
Jim Carlock
Post replies to the newsgroup, thanks.
Nov 22 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by New to PHP | last post: by
4 posts views Thread by Patrick Masson | last post: by
2 posts views Thread by joe | last post: by
7 posts views Thread by Joe | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.