# Apache2 Server not working... HELP PLEASE!!! :) <SOLVED!>

## soldstatic

I had a cool server set up on winxp but I used a package install that was really easy. All i want to do is set up so I can browse to a folder on my desktop computer from another computer, just like a website thing.

No clue why i'm getting this and I've been trying variations on just about everything. Put in a namevirt5ualhost value didnt help changed the *:80 to localhost:80 and the ip addy of my desktop according to dhcp, etc etc etc

Can anyone give me some direction on this??

```

StaticDesktop apache2 # apache2 -k start

[Tue Jun 06 18:08:01 2006] [warn] NameVirtualHost *:80 has no VirtualHosts

StaticDesktop apache2 # apache2 -k stop

[Tue Jun 06 18:08:03 2006] [warn] NameVirtualHost *:80 has no VirtualHosts

StaticDesktop apache2 # apache2 -k stop

[Tue Jun 06 18:08:04 2006] [warn] NameVirtualHost *:80 has no VirtualHosts

httpd (no pid file) not running
```

Thanks in advance guys!!!!!Last edited by soldstatic on Wed Jun 07, 2006 11:10 pm; edited 1 time in total

----------

## Philantrop

You can either comment out the NameVirtualHost directive because for such a simple setup you won't need virtual hosts or you can define a catch-all virtual host like this:

```
# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for requests without a known

# server name.

#

#<VirtualHost *:80>

#    ServerAdmin webmaster@dummy-host.example.com

#    DocumentRoot /www/docs/dummy-host.example.com

#    ServerName dummy-host.example.com

#    ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log

#    CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common

#</VirtualHost>
```

The "<VirtualHost *:80>" line makes sure that any hostname will match.

----------

## spawnferkel

And I must setup the /etc/conf.d/apache2 file,

in the line APACHE2_OPTS = "" 

you must add "- D DEFAULT_VHOST"

----------

## Philantrop

 *spawnferkel wrote:*   

> And I must setup the /etc/conf.d/apache2 file,
> 
> in the line APACHE2_OPTS = "" 
> 
> you must add "- D DEFAULT_VHOST"

 

That's news to me. I didn't need to set that but whatever works for you or him. :-)

(Btw, I'm usually not into correcting people but this bothers me too much... :) )

 *Quote:*   

> wer sich mit wenig zufrieden gibt, hat alles was er braucht

 

----------

## soldstatic

oh see i thought i had set that up but i guess i forgot to uncomment it. lol duuhr.

now I can't seem to get the right documentRoot ... any idea where that should point??

----------

## soldstatic

well I switched the DocumentRoot to /var/www/

started up w/o any errors, but now how do I navigate to it?? if I type in localhost in my browser, it doesnt do anything. if I type in my local IP, doesnt do anything. each time it spits out error "connection refused" or something. I have a feeling egentoo blocks that type of connection by default??

----------

## soldstatic

ok and upon closer inspection, even after i do apache2 -k start, there's no process for it in the process tree.

----------

## Philantrop

Please post the output of this command:

```
cat /etc/apache2/httpd.conf | grep -v "^#" | grep -v "^;" | grep -v "^$" 
```

Furthermore, delete /var/log/apache2/error_log and /var/log/apache2/access_log, try to start Apache by using 

```
/etc/init.d/apache2 start
```

(do not try to start it any other way. Init scripts are being used for a reason.) and if that fails, too, post both of the above logs.

----------

## soldstatic

ah i'm so new to linux, i'll do the cat and everything when I get home tonight, ~5p CST, but what is the difference between running it by typing

~ apache2

~ apache2 start

~ apache2 -k start

/etc/init.d/apache2 start

??????

----------

## soldstatic

 *spawnferkel wrote:*   

> And I must setup the /etc/conf.d/apache2 file,
> 
> in the line APACHE2_OPTS = "" 
> 
> you must add "- D DEFAULT_VHOST"

 

By the way, that was already in there by default, but I also installed it by emerging a script I like (ampache) [I assumed it would install apache and php and everything as dependencies so I wouldnt have to emerge other junk either]

----------

## spawnferkel

hmm, maybe is that the reason for my problem. 

can it be true that I have emerged my apache2 and php 

on an wrong way? if you have enough time please

write down your way to emerged an complete lamp.

in the tread i have opend: https://forums.gentoo.org/viewtopic-t-469186.html

good luck to solve your probl.

----------

## soldstatic

looks like the latest error in the log was

(2)No such file or directory: apache2: could not open error log file /usr/lib/apache2/@rel_logfiledir@/localhost-error_log.

Unable to open logs

so let me see if i can fix that, then i'll copy the logs if that still doesnt work

----------

## soldstatic

Alright got that fixed, thanks, dumb as it sounds i didnt think to look at the logs. 

so apache is up, only now i get a 403 forbidden:

```
Forbidden

You don't have permission to access / on this server.

Apache Server at 192.168.2.5 Port 80
```

where does that get set up??

error log:

```

Wed Jun 07 17:56:55 2006] [error] [client 192.168.2.5] Directory index forbidden by rule: /var/www/

[Wed Jun 07 17:57:10 2006] [error] [client 192.168.2.5] File does not exist: /var/www/andy

[Wed Jun 07 17:57:33 2006] [error] [client 192.168.2.5] (13)Permission denied: access to /~andy denied

[Wed Jun 07 17:57:33 2006] [error] [client 192.168.2.5] File does not exist: /var/www/favicon.ico

[Wed Jun 07 17:57:45 2006] [error] [client 192.168.2.5] Directory index forbidden by rule: /var/www/

[Wed Jun 07 17:57:45 2006] [error] [client 192.168.2.5] File does not exist: /var/www/favicon.ico

```

So apprently the files aren't in the right directory... although I'm positive the files for ampache are in /var/www/localhost/ampache etc... oh duh let me change the server directory to /var/www/localhost and see if that works.

----------

## soldstatic

Well, changed that so it looks like it should be going to the correct dir....

instead i get 404 not found or 403 forbidden.

so in the logs i get:

in access_log:

```

192.168.2.5 - - [07/Jun/2006:18:09:01 +0000] "GET / HTTP/1.1" 403 263

192.168.2.5 - - [07/Jun/2006:18:09:01 +0000] "GET /favicon.ico HTTP/1.1" 404 270

192.168.2.5 - - [07/Jun/2006:18:09:06 +0000] "GET /index.html HTTP/1.1" 404 269

192.168.2.5 - - [07/Jun/2006:18:09:06 +0000] "GET /favicon.ico HTTP/1.1" 404 270

192.168.2.5 - - [07/Jun/2006:18:09:12 +0000] "GET /ampache/ HTTP/1.1" 404 267

192.168.2.5 - - [07/Jun/2006:18:09:12 +0000] "GET /favicon.ico HTTP/1.1" 404 270

192.168.2.5 - - [07/Jun/2006:18:09:17 +0000] "GET /ampache/index.php HTTP/1.1" 404 276

192.168.2.5 - - [07/Jun/2006:18:09:17 +0000] "GET /favicon.ico HTTP/1.1" 404 270

```

in error_log:

```

192.168.2.5 - - [07/Jun/2006:18:09:01 +0000] "GET / HTTP/1.1" 403 263

192.168.2.5 - - [07/Jun/2006:18:09:01 +0000] "GET /favicon.ico HTTP/1.1" 404 270

192.168.2.5 - - [07/Jun/2006:18:09:06 +0000] "GET /index.html HTTP/1.1" 404 269

192.168.2.5 - - [07/Jun/2006:18:09:06 +0000] "GET /favicon.ico HTTP/1.1" 404 270

192.168.2.5 - - [07/Jun/2006:18:09:12 +0000] "GET /ampache/ HTTP/1.1" 404 267

192.168.2.5 - - [07/Jun/2006:18:09:12 +0000] "GET /favicon.ico HTTP/1.1" 404 270

192.168.2.5 - - [07/Jun/2006:18:09:17 +0000] "GET /ampache/index.php HTTP/1.1" 404 276

192.168.2.5 - - [07/Jun/2006:18:09:17 +0000] "GET /favicon.ico HTTP/1.1" 404 270

```

soooo yea. and I know the files are physically in the /var/www/localhost/whatever. There

----------

## soldstatic

shoot i figured it out. i missed the fact that there was another folder in there.... /htdocs. shoot. :-/

got it workin now!

----------

## xeonburn

if I want to add a virtual host, say mail.mydomain.com, do I need to edit conf.d/apache or do I just create the .conf file in /etc/apache/vhosts.d/... or maybe there's another file alogether that must be edited?

----------

## soldstatic

my guess = the vhost file... but i dont really have any clue...

----------

## Philantrop

soldstatic, you may be clueless but your guess was correct. ;-)

xeonburn, in /etc/apache2/vhosts.d/ you'll find a "00_default_vhost.conf". Copy that to something like 10_mail.mydomain.com.conf and edit the latter. If you need more support on this after trying yourself first, I'd suggest to open a new thread because this one is flagged as solved and at least I'm soon going to stop watching it. :-)

----------

## soldstatic

lol: see, i didnt think about the new file. i figured youd just edit the existing one, but obviously the new one would be better.

hey speaking of vhosts, i've got my server responding to the ip, 192... but why cant i get it to respond to localhost???

and why can't i see the apache over the LAN? does gentoo have a firewall thing in place initially? The firewall I have is blocking outside ips from connecting to my server, but how do i get my laptop (also a 192... ip) to reach the servers' 192... ip??

----------

