473,839 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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='<!DOCTYP E html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">\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.dt d">
<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 2795
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='<!DOCTYP E html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">\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.dt d">
: <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='<!DOCTYP E html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">\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.dt d">
<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>.ph p 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>.ph p 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*******@attgl obal.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>.ph p
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*******@attg lobal.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<he ad>\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*******@attg lobal.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<he ad>\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*******@attgl obal.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>.ph p
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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2050
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. Please tell me where should I put the index.html? Thanks. PS. I did not change httpd.conf and here is part of it
4
3729
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
6313
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 Apache directory - unable to find httpd.h under /usr/local/apache/include So then I run this command: find / -name httpd.h
2
1291
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 Group/Apache2/htdocs" but I have a subdirectory "C:/Program Files/Apache Group/Apache2/htdocs/sub1" from which I cannot run my test.php page. Can someone give me an idea as what is wrong here and how I can fix it
6
7987
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 "include not found", rather much of the page is blank where the included menus, etc would be, and the CSS is not attached. thanks so much!!! My httpd.conf looks like this:
3
3117
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 sure my users/groups/permissions/etc are all good. Apache is running as user apache group ftpusers. server root for default server is at the top /export/home chowned to apache and grped to ftpusers recursively. Even so with permissions...
0
6863
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 written in Perl just for testing. I believe I need to find the correct <Directory> entry or some other Directive in Apache to make this work, but I've had no luck for a week now. I've tried many different things, but w/ no luck. I even tried adding...
7
2103
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
7607
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 work. Please review my work and let me know if you see that one little thing that is throwing me for a loop. HTTPD.CONF # # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the...
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10597
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.