# [SOLVED] apache 2 wont process webpages

## imcominup

i emerged apache, and during the build process i got no errors. everything seems to be where it needs to be. but when i go to http://localhost in my browser, it just prints the HTML for the index.html page. it won't show the content like a real webpage. what could be the problem here exactly? i've never seen this issue before. this is what i see:

```
kumi@throne ~ $ /etc/init.d/apache2 status

 * status:  started
```

http://localhost

```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Test Page for Apache Installation</title>

</head>

<!-- Background white, links blue (unvisited), navy (visited), red

(active) -->

<body bgcolor="#FFFFFF" text="#000000" link="#0000FF"

vlink="#000080" alink="#FF0000">

<p>If you can see this, it means that the installation of the <a

href="http://www.apache.org/foundation/preFAQ.html">Apache web

server</a> software on this system was successful. You may now add

content to this directory and replace this page.</p>

<hr width="50%" size="8" />

<h2 align="center">Seeing this instead of the website you

expected?</h2>

<p>This page is here because the site administrator has changed the

configuration of this web server. Please <strong>contact the person

responsible for maintaining this server with questions.</strong>

The Apache Software Foundation, which wrote the web server software

this site administrator is using, has nothing to do with

maintaining this site and cannot help resolve configuration

issues.</p>

<hr width="50%" size="8" />

<p>The Apache <a href="manual/">documentation</a> has been included

with this distribution.</p>

<p>You are free to use the image below on an Apache-powered web

server. Thanks for using Apache!</p>

<div align="center"><img src="apache_pb.gif" alt="" /></div>

</body>

</html>
```

what is the problem here? has anybody experienced this issue before?Last edited by imcominup on Wed Aug 29, 2007 4:51 am; edited 1 time in total

----------

## kiksen

Apache is supposed to send out html just like it does. It's your browser that should render it. I wouldn't know why that doesn't happen - have you tried with another browser?

/kiksen

----------

## imcominup

 *kiksen wrote:*   

> Apache is supposed to send out html just like it does. It's your browser that should render it. I wouldn't know why that doesn't happen - have you tried with another browser?
> 
> /kiksen

 

it's gotta be apache. my browser processes every other web document. even when i put  file:///home/kumi/development/atlas/index.html in the browser it processes the page perfectly, with all the images and everything. it's gotta be apache. http://localhost/ doesn't work. it cant be a browser issue for that reason, right? i'm running firefox by the way.   should i try emerging another one?

----------

## kiksen

If I save what you have posted as apache's output in, say, test.html and load it in firefox it renders it nicely. I'd still say apache is doing what it's supposed to do... if you do the same what result do you get?

/kiksen

----------

## imcominup

 *kiksen wrote:*   

> If I save what you have posted as apache's output in, say, test.html and load it in firefox it renders it nicely. I'd still say apache is doing what it's supposed to do... if you do the same what result do you get?
> 
> /kiksen

 

the same result as you my man. firefox parses the html perfectly.. but if i put the file in my htdocs directory, it just prints the syntax onto the screen. nothing else. do you know what to do from here?

----------

## kiksen

I don't know what the reason is. If you type http://localhost/index.html what do you get? I'm emerging apache now to see if I get anything similar. I'll be back  :Smile: 

/kiksen

----------

## kiksen

apache2 merged (2.2.4-r12, I'm on ~x86)

I had to emerge --config "=apache-2.2.4-r12" to get the webroot, but the html renders fine. It's simpler than yours - it says "It works!".

You aren't running a proxy server are you? If so, disable it for localhost. Else... I'm out of ideas  :Sad: 

/kiksen

----------

## imcominup

 *kiksen wrote:*   

> I don't know what the reason is. If you type http://localhost/index.html what do you get? I'm emerging apache now to see if I get anything similar. I'll be back 
> 
> /kiksen

 

i get a print-out of index.html syntax. it does not 'work' =\.   i'm not running a proxy server. i think if i knew how to set one up i'd be more familiar with linux enough to fix this issue that i'm having. my buddy built this gentoo box for me when i was JUST getting into linux. i told him i wanted a hard distro to learn. gentoo is what he gave me.

what do you mean when you say you had to emerge --config ="apache-..........." to get the webroot? what is the webroot? what is the purpose of the --config option? how did you know you had to use it?

another issue i'm having setting up this LAMP server is i've tried to emerge php but it shat the bed at the very last build. now when i try to emerge it over again:

```

kumi@throne ~ $ sudo emerge php

Calculating dependencies

emerge: there are no ebuilds to satisfy "=www-servers/apache-2*".

(dependency required by "dev-lang/php-5.2.4_pre200708051230-r2" [ebuild])

```

what is wrong with my portage tree? i've already sync'd it and ran emerge-webrsync. still no luck!

----------

## kiksen

A webroot is just the start of the tree for a site; where apache looks for what comes after http://localhost/. In my case /var/www/localhost/htdocs.

I know about the --config stuff because the emerege of apache2 told me about it.

Only use emerge-webrsync if your'e behind a firewall and can't run emerge --sync... there's no need to run both.

Dunno about the apache-2 package - it doesn't exist (it did waaaaayyyy back if I remember it right). You may have gotten an old tree with emerge-webrsync? (this is purely speculation...). Upgrade your tree with emerge --sync and try again.

/kiksen

----------

## imcominup

thank you very very much for the information so far. you've been very helpful in shedding light on a lot of features regarding gentoo and the portage system. my http://localhost/ is also located in /var/www/localhost/htdocs. i'm syncing again and then i'll try to emerge apache again. i'll keep you posted. thanks again for all your help so far.

----------

## imcominup

end of apache emerge build...

```
 * GNU info directory index is up-to-date.

 * IMPORTANT: 2 config files in /etc need updating.

 * Type emerge --help config to learn how to update config files.

```

could this be part of the problem? what do i do from here? i don't want to mess this up...

----------

## kiksen

It's important to keep your configuration files up-to-date. You can use etc-update or dispatch-conf to do so. I prefer dispatch-conf, but it's your choice  :Smile: 

You'll be presented with the differences and have the choice to accept the new version, keep the one you have or merge. Pay attention to what you do - a lot of them are easily upgraded (e.g. init scripts if you don't mess with them yourself), and some, like /etc/fstab you'll want to guard with your life  :Wink: 

/kiksen

----------

## imcominup

```
kumi@throne ~ $ sudo etc-update

Password:

Scanning Configuration files...

The following is the list of files which need updating, each

configuration file is followed by a list of possible replacement files.

1) /etc/mime.types (1)

Please select a file to edit by entering the corresponding number.

              (don't use -3, -5, -7 or -9 if you're unsure what to do)

              (-1 to exit) (-3 to auto merge all remaining files)

                           (-5 to auto-merge AND not use 'mv -i')

                           (-7 to discard all updates)

                           (-9 to discard all updates AND not use 'rm -i'): -3

Replacing /etc/mime.types with /etc/._cfg0000_mime.types

mv: overwrite `/etc/mime.types'? y

Exiting: Nothing left to do; exiting. :)

kumi@throne ~ $ sudo /etc/init.d/apache2 restart

 * Service apache2 stopping

 * Stopping apache2 ...

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName                                                     [ ok ]

 * Service apache2 stopped

 * Service apache2 starting

 * Starting apache2 ...

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName                                                     [ ok ]

 * Service apache2 started

```

unfortunately that did not help. my http://localhost/ doesn't process webpages correctly still. i have no idea what to do. i even have the o'reilly apache handbook and it doesn't have anything in there about this kind of troubleshooting. no one i've talked to has ever seen this happen. i am totally out of ideas... why should this be so difficult?

----------

## imcominup

great news!!! for some reason i decided to use http://127.0.0.1/ and it worked! isn't that crazy! why would one work and not the other? where do you configure apache for both to work?

php on the other hand still does not work. i'm going to re-emerge it now. thank you so much for all the help so far!!!

----------

## kiksen

Your /etc/hosts file is not correct. It should have a line looking something like:

127.0.0.1   mybox.mydomain mybox localhost

Of course, you'll have different names  :Smile: 

/kiksen

----------

## imcominup

thanks for the head's up. i didn't even know that file existed. this is what mine looks like:

```

# /etc/hosts: Local Host Database

#

# This file describes a number of aliases-to-address mappings for the for 

# local hosts that share this file.

#

# In the presence of the domain name service or NIS, this file may not be 

# consulted at all; see /etc/host.conf for the resolution order.

#

# IPv4 and IPv6 localhost aliases

127.0.0.1       localhost

::1     localhost

#

# Imaginary network.

#10.0.0.2               myname

#10.0.0.3               myfriend

#

# According to RFC 1918, you can use the following IP networks for private 

# nets which will never be connected to the Internet:

#

#       10.0.0.0        -   10.255.255.255

#       172.16.0.0      -   172.31.255.255

#       192.168.0.0     -   192.168.255.255

#

# In case you want to be able to connect directly to the Internet (i.e. not 

# behind a NAT, ADSL router, etc...), you need real official assigned 

# numbers.  Do not try to invent your own network numbers but instead get one 

# from your network provider (if any) or from your regional registry (ARIN, 

# APNIC, LACNIC, RIPE NCC, or AfriNIC.)

```

it looks like it's all there, right?

----------

## kiksen

Almost  :Smile: 

Your machine has a name, it's configured in /etc/conf.d/hostname

That name should appear first in your /etc/hosts line e.g. 127.0.0.1 my-box localhost

If you have a domain name or are on a network with a domain name, say, mydomain then: 

127.0.0.1 my-box.mydomain my-box localhost

/kiksen

----------

## coolone

if i open my local website, like, if i open 

http://localhost/wordpress/wp-login.php, the webpage cannot be displayed correct, but the weird thing is 

if i open it like this : http://127.0.0.1/wordpress/wp-login.php, then the web page displays perfect

meanwhile, i tired http://127.0.0.1/test.php and http://localhost/test.php

this two both can display well.

could someone explain this question?

thanks in adv

----------

## desultory

Merged the above post.

Have you checked the server specified content types, both when accessing the server by name and when accessing it by address?

----------

