473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2664
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: New to PHP | last post by:
I am able to install Apache in my XP home edition. I did put a very simple index.html /apache/htdocs/index.html and when I type in http://localhost/index.html, I get this error : Not Found. ...
4
by: Patrick Masson | last post by:
Hello, Our configuration : Apache 2.0.53 PHP 5.0.4 PC Windows 2000 MATLAB 6.1 We work on a consulting project in France which involves MATLAB Web server,
8
by: lawrence k | last post by:
I've installed Apache 1.3.36 on my Redhat EL 3 machine. Now I'm trying to install PHP 5.1.4. I can not get the ./configure command to work. I keep getting this error: configure: error: Invalid...
2
by: joe | last post by:
Hi, I am new to both Apache and PHP. I have installed Apache 2.0.59 and PHP 5.1.6 on WinXP Home. I can run test.php page from default DocumentRoot "C:/Program Files/Apache...
6
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
3
by: bluedogsd | last post by:
I have a new server RHE4 and I am having an issue I have never had before and it's kind of urgent. Running Apache 2.0 I need the web server to have writable access and getting denied - I'm pretty...
0
by: phil469 | last post by:
I'm having an issue when trying to read a file in a user's homedir from a cgi script. I have a virtual host section in my httpd.conf file which I'll include. The cgi script is a very basic script...
7
by: Joe | last post by:
I added some ajax to my asp.net web site and will Ajax just doesn't seem to work. Does Any one PLEASE have any ideas on why Ajax doesn't work on Apache 2.2.6 w/asp.net 2.0
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.