# Apache 2.0.49 Issue(s)

## Spaz17

I recently formatted my web server (I'm still trying to figure out why), and when I reinstalled Gentoo, I emerged Apache 2.0.49. I had been running 2.0.48 on a similar Gentoo installation earlier.

I'm having two errors with Apache now:

1.) I can only restart the service once.

```

spaz@pyschopompus spaz $ su

Password:

root@pyschopompus spaz # /etc/init.d/apache2 restart

 * Stopping apache2...                                                    [ ok ] * Starting apache2...                                                    [ ok ]root@pyschopompus spaz # /etc/init.d/apache2 restart

 * Stopping apache2...                                                    [ ok ] * Starting apache2...

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs                                                       [ !! ] 

root@pyschopompus spaz #

```

My vhosts section looks something like this:

```

NameVirtualHost *:80

                                                                                

<VirtualHost *:80>

DocumentRoot /var/www/html/spazticenterprises.com

ServerName spazticenterprises.com

ServerAlias www.spazticenterprises.com

</VirtualHost>

```

...which may or may not have someting to do with that.

After I restart it twice and it fails to load, I have to restart the system entirely. Apache loads at boot.

2.) I'm having permissions errors.

```

Forbidden

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

Apache/2.0.49 (Gentoo/Linux) Server at spazticenterprises.com Port 80

```

That's the output I get when I'm trying to access it from a web browser. I haven't changed the config files too much, and the indexes option is disabled by default. I do have my directory indexes set up correctly, though. The permissions of the directory with the documents are set 0775, which is pretty liberal, but I'm testing it right now.

----------

## kcarlson

 *Quote:*   

> (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
> 
> no listening sockets available, shutting down

 

Something is listening on port 80.  Find out what it is.  After stopping apache, try as root:

```
ps -ef | grep apache

netstat -pan | grep apache

netstat -pan | grep :80

```

 *Quote:*   

> Unable to open logs                                                       [ !! ] 

 

This is disconcerting.  Check the ServerRoot & ErrorLog parameters in your /etc/apache2/conf/apache2.conf file.  The directory ServerRoot/ErrorLog must exist.

----------

## The_Loserkid

I'm currently having the same problem as Spazs second problem

i'm trying to make apache show an index of / when i go to my server

but instead i get the 

```
Forbidden

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

--------------------------------------------------------------------------------

Apache/2.0.49 (Gentoo/Linux) Server at The_Loserkid Port 8080
```

error, i've been trying for hours now to make it work

read practically the entire manual from apache etc

i've been trying hundreds (litterally) of combinations and it still wont frigging work, i'm near to giving up and kick the entire thing in the arse

this is what i've finally come up with, and i'm positive this HAS to work but for some reason it doesnt  :Mad:  

```
<Directory />

  Options Indexes

  AllowOverride None

 <IfModule mod_access.c>

  Order allow,deny

  Allow from all

 </IfModule>

</Directory>
```

this should work isn't it????

please help both of us

----------

## bone

Your problem is that for it to process the "Order" and "Allow" parts of your <Directory> section below, it has to have the module mod_access loaded. I would check to confirm that this is loading correctly and or not erroring out.

 *The_Loserkid wrote:*   

> I'm currently having the same problem as Spazs second problem
> 
> ```
> 
> <Directory />
> ...

 Last edited by bone on Tue Apr 06, 2004 11:17 pm; edited 1 time in total

----------

## The_Loserkid

 *bone wrote:*   

> Your problem is that for it to process the "Order" and "Allow" parts of your <Directory> section below, it has to have the module mod_access loaded. I would check to confirm that this is loading correctly and or not erroring out.

 

i guess it's not cos when i place a .jpg in my htdocs folder and i type the entire url in my internet explorer i can access the file

----------

## bone

What errors are in your access_log and error_log when attempting to view the DocumentRoot or VirtualHost directory?

 *The_Loserkid wrote:*   

>  *bone wrote:*   Your problem is that for it to process the "Order" and "Allow" parts of your <Directory> section below, it has to have the module mod_access loaded. I would check to confirm that this is loading correctly and or not erroring out. 
> 
> i guess it's not cos when i place a .jpg in my htdocs folder and i type the entire url in my internet explorer i can access the file

 

----------

## The_Loserkid

 *bone wrote:*   

> What errors are in your access_log and error_log when attempting to view the DocumentRoot or VirtualHost directory?

 

how do i check ?

----------

## bone

If the URL that you are trying to access is your main DocumentRoot, then check your logs directory, if its a VirtualHost then you might have an alternative log file/directory specifed for that VirtualHost in which case you would have to check there.

----------

## The_Loserkid

 *bone wrote:*   

> If the URL that you are trying to access is your main DocumentRoot, then check your logs directory, if its a VirtualHost then you might have an alternative log file/directory specifed for that VirtualHost in which case you would have to check there.

 

here's what the logs says when i tried to acces /

```
[Wed Apr 07 11:21:21 2004] [error] [client 192.168.0.2] Directory index forbidden by rule: /var/www/localhost/htdocs/
```

client 192.168.0.2 is my computer

----------

## UberLord

 *The_Loserkid wrote:*   

>  
> 
> ```
> <Directory />
> 
> ...

 

Try using <Directory /var/www/localhost/htdocs>

Or, simply find that section in /etc/conf/commonapache2.conf and add Indexes to the Options

----------

## The_Loserkid

the <Directory ....> thing i pasted was from my commonapache2.conf file

----------

## kcarlson

I found that I was better off leaving most options unchanged in commonapache2.conf and apache2.conf -> and then creating a virtual host for any sites on my domain.

The Important bits are:

```
/etc/apache2/conf/apache2.conf

###

### Virtual Hosts 

###

# We include different templates for Virtual Hosting. Have a look in the 

# vhosts directory and modify to suit your needs.

Include conf/vhosts/vhosts.conf

#Include conf/vhosts/dynamic-vhosts.conf

#Include conf/vhosts/virtual-homepages.conf
```

```
/etc/apache2/conf/vhosts/vhosts.conf

...

include conf/vhosts/your_site_name.conf

```

```
/etc/apache2/conf/vhosts/your_site_name.conf

<VirtualHost *:80>

        ServerName your_site_name

        ServerAlias www.your_site_name

        ServerAdmin webmaster@localhost

        # Directories 

        DocumentRoot "/share/web/"

        <Directory />

                Options -All -Multiviews +Followsymlinks +Includes +Indexes

                Allow from all

        </Directory>

</VirtualHost>

```

- If you can access a single file directly from a URL ( http://my_site.com/my_jpeg.jpg ) successfully, then you are accessing the web site as intended.  

- The "Directory index forbidden by rule" error is apache saying that you do not have a default web page in that location, and that apache is not configured to provide essentially a 'dir' or 'ls' listing of your htdocs directory.  The +Indexes option above is what allows that, if that is actually what you intend.

-Make sure there is no .htaccess file in your htdocs directory that forbids this as well.  

- You likely should just make a default web document in your htdocs directory.  Default documents are parsed in the order found by the apache directive DirectoryIndex, found in the commonapache2.conf file.

(  DirectoryIndex index.html index.html.var index.php index.php3 index.shtml index.cgi index.pl index.htm Default.htm default.htm

)

Hope some of this helped.

----------

## infecticide

I've done as shown above and tried the VirtualHosts.  

Still no luck.

I have all my hosted files on a FAT32 partition that I dual boot WinXP from and it seems to me that this could be a problem with the permissions set in fstab or something?

I tried the chmod 777 /mnt/windows/htdocs

But it still gives me 403.

access_log

```

127.0.0.1 - - [20/Apr/2004:03:52:16 -0600] "GET / HTTP/1.1" 403 406 "-" "Mozilla/5.0 (compatible; Konqueror/3.2; Linux 2.4.25-gentoo) (KHTML, like Gecko)"

```

error_log

```

[Tue Apr 20 03:52:05 2004] [notice] Apache/2.0.49 (Gentoo/Linux) configured -- resuming normal operations

[Tue Apr 20 03:52:16 2004] [error] [client 127.0.0.1] (13)Permission denied: access to / denied

```

Any pointers?  Thanks in advance.

----------

## infecticide

Igot curious about those fstab permissions and took a look around.  Found a fstab tag gid=users, uid=0000, these did the trick.  Apache and mySQL now have no problem accessing the files.

----------

## kcarlson

 *infecticide wrote:*   

> I have all my hosted files on a FAT32 partition that I dual boot WinXP from and it seems to me that this could be a problem with the permissions set in fstab or something?
> 
> I tried the chmod 777 /mnt/windows/htdocs
> 
> But it still gives me 403.
> ...

 

Possibly a few pointers.  Once you mount a partition, the permissions can change based on who mounts it, etc.  I do not know if WinXP will try to muck with the files either.

1.  First best advice: FAT32 sucks.  Use NTFS for WinXP.  Make a new partition for Linux and use ext3 or reiserfs.

2.  Change your fstab to a line similar to:

/dev/hdxx     /mnt/windows       vfat        rw,user,uid=___,gid=_____

- hdxx is of course your drive and partition.  Ex.  /dev/hdc3

- fill in the blanks for the uid and gid of your apache user and group.  On my box apache runs as user:apache, group: apache.  To find the uid/gid do this:

 cat /etc/passwd | grep apache

apache:x:81:81:apache:/home/httpd:/bin/false

 cat /etc/group | grep apache

apache::81:apache,jsmith

so I would use uid=81, and coincidentally gid=81.  

This should help set permissions to be accessible to your web server.  I don't know if this will solve your problem, but I've never attempted to deal with linux filesystem priviledges on a FAT32 partition either.

later.

----------

## syscrash

I am also experiencing the same issue (#1).

```
sigma apache2 # /etc/init.d/apache2 restart

 * Starting apache2...                                                    [ ok ]

sigma apache2 # netstat -pan | grep :80 

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      11618/apache2       

tcp      427      0 192.168.0.6:80          192.168.0.4:33566       CLOSE_WAIT  -                   

sigma apache2 # /etc/init.d/apache2 stop

 * Stopping apache2...                                                    [ ok ]

sigma apache2 # netstat -pan | grep :80 

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      11618/apache2       

tcp      427      0 192.168.0.6:80          192.168.0.4:33566       CLOSE_WAIT  -                   

sigma apache2 # killall apache2

sigma apache2 # netstat -pan | grep :80 

sigma apache2 # netstat -pan | grep :80 

sigma apache2 # netstat -pan | grep apache2

sigma apache2 # /etc/init.d/apache2 start  

 * Starting apache2...                                                    [ ok ]

sigma apache2 # netstat -pan | grep apache2

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      11724/apache2       

sigma apache2 # 

```

It seems to load the first time around though, but it is a bit of a hassle for me to reboot the server.

Any ideas? Is it an apache bug?

----------

## compucoder

I had some issues like this with apache 2 and it ended resolving the problem by adding apache to the users group and also making sure the docroot and virtual host root was owned by 'root'.

Might want to give this a try.

----------

## Spaz17

I'm back.

I was away for a while. Thanks for stealing me thread  :Wink: 

I resolved my first issue, but I don't remember how, since it was such a long time ago.

However, I'm still having issues trying to actually serve my files. I can only do so out of the default /var/www/localhost/htdocs directory. When I change the DocumentRoot in my apache2.conf file, I get that forbidden error. The permission of the folder I change it to are the same as that of htdocs.

Ideas?

----------

## kcarlson

 *Spaz17 wrote:*   

> 
> 
> However, I'm still having issues trying to actually serve my files. I can only do so out of the default /var/www/localhost/htdocs directory. When I change the DocumentRoot in my apache2.conf file, I get that forbidden error. The permission of the folder I change it to are the same as that of htdocs.
> 
> Ideas?

 

Can you post the relevant lines from the access/error logs found in /var/log/apache2/ ?

----------

## Chris W

Spaz17, you are most likely getting the 403 errors because Apache does not have permission to access the contents of the OS directory /var/www/html/spazticenterprises.com (The / in the 403 error refers to the document root not the real root).  Unless you have specifically allowed it, the default entries in commonapache.conf disallow it.  The disallowing entry looks like: 

```
<Directory />

  Options -All -Multiviews

  AllowOverride None

  <IfModule mod_access.c>

    Order deny,allow

    Deny from all

  </IfModule>

</Directory>
```

 where the <Directory> directive applies to the operating system root directory and all subordinates.  You need to allow access to /var/www/html/spazticenterprises.com in same fashion that access is allowed to the /var/www/localhost/htdocs tree.  For example: 

```
<Directory /var/www/html/spazticenterprises.com>

    Options -Indexes FollowSymLinks MultiViews

    AllowOverride All

    <IfModule mod_access.c>

      Order allow,deny

      Allow from all

    </IfModule>

</Directory>
```

Hope this helps.

----------

## Spaz17

Wow, I swear I posted a response to this a long time ago.

Well, thanks Chris W, that's what it was. It's weird that I've never had to do that before, though.

But my first error seems to still be appearing, though.

After stopping Apache:

```

pyschopompus root # ps -ef | grep apache

root     29240     1  0 21:52 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

apache   29360 29240  0 21:54 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

apache   29361 29240  0 21:54 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

apache   29362 29240  0 21:54 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

apache   29363 29240  0 21:54 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

apache   29364 29240  0 21:54 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

apache   29365 29240  0 21:54 ?        00:00:00 /usr/sbin/apache2 -k start -D SSL -D PHP4

root     29402 29141  0 21:57 pts/2    00:00:00 grep apache

pyschopompus root # netstat -pan | grep apache

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      29240/apache2

tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      29240/apache2

unix  2      [ ACC ]     STREAM     LISTENING     22130  29360/apache2       /var/run/cgisock

pyschopompus root # netstat -pan | grep :80

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      29240/apache2

pyschopompus root #

```

Eh?

----------

## Chris W

Does Apache _really_ stop if you use:

```
# apache2ctl -k stop
```

Is your /etc/init.d/apache2 up to date?  Have you been running etc-update and merging changes?  

```
ptolemy root # md5sum /etc/init.d/apache2

ec04063f55e79fc73de02c4f4647b135  /etc/init.d/apache2

```

Perhaps there is a permission problem with the PID file:

```
ptolemy root # ls -l /var/run/apache2.pid

-rw-r--r--    1 root     root            6 Apr 27 13:35 /var/run/apache2.pid
```

----------

## infecticide

Just incase anyone is wondering how I solved my issue of serving Apache2 from FAT32.    I had to add gid=users, umask=0000 to fstab.

----------

## Larcen

Help!

..now that thats taken care of.

I was running on FreeBSD for months, and then decided to migrate to Gentoo. Very good move.. BUT I can't seem to get VirtualHosts working under Gentoo. FreeBSD was simple, installed apache2 and set it up, boom, done. Worked fine.  But Gentoo.. I dunno whats goin on. in using the vhosts include, or putting my virtualhosts right in apache2.conf I either get.. Permissioned denied trying to access / on this server also there was an error in the error document handling etc etc.. OR I just keep getting the default htdocs directory for all addresses. www.* test.* whatever.domain.com Any suggestions?

----------

