# apache and localhost set up problems

## dominik_ba

hi

i did an emerge world some days ago and since then I cannot accede to my localhost server (public_html and cgi-bin files) in my home directory.

when i try to restart apache I have this error:

"""

* Stopping apache2 ...

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

 * Starting apache2 ...

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

"""

Since I emerged the new version of apache things are different, for example my /etc/apache2/httpd.conf file looks differently. I don't know how to enable cgi-bin in my home folder.

----------

## elgato319

apache seems to start fine.

could you post some error messages from var/log/apache2/error_log after you connected to localhost via browser?

----------

## dominik_ba

here are error messages from var/log/apache2/error_log:

[Fri Jan 11 16:18:32 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

[Fri Jan 11 16:18:33 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

[Fri Jan 11 16:24:33 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

[Fri Jan 11 16:24:37 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

[Fri Jan 11 16:24:40 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

[Fri Jan 11 16:24:49 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

[Fri Jan 11 16:24:52 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

suggestion

the problem is that i want to run my cgi-bin files in the home directory.

----------

## dominik_ba

i think that i have to ask apache to look for localhost in

/home/dbartkowski/public_html/cgi-bin    etc......

and not in /var/www/localhost/htdocs/~dbartkowski

I just don't know how to set it up.

----------

## upengan78

what is there in /etc/hosts ?

----------

## dominik_ba

in /etc/host I have this:

# /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 dbartkowski

::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.)

#

thanks

----------

## upengan78

 *Quote:*   

> ::1 localhost 

 

Why is above required ?  :Confused: 

Can you comment that line and check if your problem persist or not ?

----------

## dominik_ba

I did it and the problem persists

----------

## upengan78

 *dominik_ba wrote:*   

> I did it and the problem persists

 

Okay did you write above after trying to restart apache again and seeing the same error ?

----------

## dominik_ba

yes

here is the var_log message from /var/log/apache2/var_log, the last line is when I try to view my sites in the browser, the other ones is when i restart apache on the command line

[Fri Jan 11 21:25:36 2008] [notice] Apache/2.2.6 (Unix) configured -- resuming normal operations

[Fri Jan 11 21:25:40 2008] [notice] caught SIGTERM, shutting down

[Fri Jan 11 21:25:42 2008] [notice] Apache/2.2.6 (Unix) configured -- resuming normal operations

[Fri Jan 11 21:26:40 2008] [notice] caught SIGTERM, shutting down

[Fri Jan 11 21:26:42 2008] [notice] Apache/2.2.6 (Unix) configured -- resuming normal operations

[Fri Jan 11 21:26:48 2008] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/~dbartkowski

and that's what returns the terminal when i restart apache2:

 * Stopping apache2 ...

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

 * Starting apache2 ...

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

----------

## upengan78

```
can you post contents of file /etc/apache2

vhosts.d/00_default_vhost.conf

```

 *Quote:*   

> Also I would like you to restart network service on machine and try apache restart again

 

 *Quote:*   

> and if this does not work then please restart machine 
> 
> and check if that helps

 

----------

## dominik_ba

I reboot my computer, still the same 

here is the file /etc/apache2/vhosts.d/00_default_vhost.conf

# Virtual Hosts

#

# If you want to maintain multiple domains/hostnames on your

# machine you can setup VirtualHost containers for them. Most configurations

# use only name-based virtual hosts so the server doesn't need to worry about

# IP addresses. This is indicated by the asterisks in the directives below.

#

# Please see the documentation at

# <URL:http://httpd.apache.org/docs/2.2/vhosts/>

# for further details before you try to setup virtual hosts.

#

# You may use the command line option '-S' to verify your virtual host

# configuration.

<IfDefine DEFAULT_VHOST>

# see bug #178966 why this is in here

# Listen: Allows you to bind Apache to specific IP addresses and/or

# ports, instead of the default. See also the <VirtualHost>

# directive.

#

# Change this to Listen on specific IP addresses as shown below to

# prevent Apache from glomming onto all bound IP addresses.

#

#Listen 12.34.56.78:80

Listen 80

# Use name-based virtual hosting.

NameVirtualHost *:80

# When virtual hosts are enabled, the main host defined in the default

# httpd.conf configuration will go away. We redefine it here so that it is

# still available.

#

# If you disable this vhost by removing -D DEFAULT_VHOST from

# /etc/conf.d/apache2, the first defined virtual host elsewhere will be

# the default.

<VirtualHost *:80>

        ServerName localhost

        Include /etc/apache2/vhosts.d/default_vhost.include

        <IfModule mpm_peruser_module>

                ServerEnvironment apache apache

        </IfModule>

</VirtualHost>

</IfDefine>

# vim: ts=4 filetype=apache

I found the wrong path "/var/www/localhost/cgi-bin" in: 

/etc/apache2/vhosts.d/00_default_ssl_vhost.conf 

and in

nano /etc/apache2/vhosts.d/default_vhost.include

----------

## upengan78

Can't figure out what is wrong

what is the value of 

APACHE2_OPTS

in /etc/conf.d/apache2

----------

## upengan78

Also check this file for public_html which you wanted to set initially

modules.d/00_mod_userdir.conf in /etc/apache2

----------

## dominik_ba

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST"

do you think I can modify 

00_default_ssl_vhost.conf , 00_default_vhost.conf,  default_vhost.include 

or those files are being generated...

----------

## upengan78

 *Quote:*   

> 
> 
> do you think I can modify 
> 
> 00_default_ssl_vhost.conf , 00_default_vhost.conf,  default_vhost.include 
> ...

 

Yes you can but do not modify them, check the file I mentioned in earlier post...

----------

## dominik_ba

everything seems to be ok here. 

/etc/apache2/modules.d/00_mod_userdir.conf 

# Settings for user home directories

<IfDefine USERDIR>

<IfModule userdir_module>

# UserDir: The name of the directory that is appended onto a user's home

# directory if a ~user request is received.  Note that you must also set

# the default access control for these directories, as in the example below.

UserDir public_html

# Control access to UserDir directories.  The following is an example

# for a site where these directories are restricted to read-only.

<Directory /home/*/public_html>

        AllowOverride FileInfo AuthConfig Limit Indexes

        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

        <Limit GET POST OPTIONS>

                Order allow,deny

                Allow from all

        </Limit>

        <LimitExcept GET POST OPTIONS>

                Order deny,allow

                Deny from all

        </LimitExcept>

</Directory>

# Suexec isn't really required to run cgi-scripts, but it's a really good

# idea if you have multiple users serving websites...

<IfDefine SUEXEC>

<IfModule suexec_module>

<Directory /home/*/public_html/cgi-bin>

        Options ExecCGI

        SetHandler cgi-script

</Directory>

</IfModule>

</IfDefine>

</IfModule>

</IfDefine>

# vim: ts=4 filetype=apache

----------

## dominik_ba

for a better documentation, if i emerge apache, the message is as follow;

>>> Original instance of package unmerged safely.

 * The default webroot has not been installed into

 * /var/www/localhost because the directory already exists

 * and we do not want to overwrite any files you have put there.

 * 

 * If you would like to install the latest webroot, please run

 * emerge --config =apache-2.2.6-r7

 * 

>>> www-servers/apache-2.2.6-r7 merged.

>>> No packages selected for removal by clean

>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * Messages for package www-servers/apache-2.2.6-r7:

 * 

 * Selected default MPM: prefork

 * 

 * Please note that you need SysV IPC support in your kernel.

 * Make sure CONFIG_SYSVIPC=y is set.

 * 

 * The default webroot has not been installed into

 * /var/www/localhost because the directory already exists

 * and we do not want to overwrite any files you have put there.

 * 

 * If you would like to install the latest webroot, please run

 * emerge --config =apache-2.2.6-r7

 * 

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

 * IMPORTANT: 1 config files in '/etc' need updating.

 * See the CONFIGURATION FILES section of the emerge

 * man page to learn how to update config files.

----------

## dominik_ba

if i follow the instructions 

emerge --config =apache-2.2.6-r7 

returns this error message

emerge --config =apache-2.2.6-r7 

Configuring pkg...

 * Installing default webroot to /var/www/localhost

mkdir: cannot create directory `/var': File exists

mkdir: cannot create directory `/var/www': File exists

mkdir: cannot create directory `/var/www/localhost': File exists

----------

## upengan78

I don't understand, what is the issue, sorry

Try downgrading apache,

example:

emerge -av "=net-www/apache-2.x.x"

Thanks

----------

## dominik_ba

downgrading didn't work out till now.

----------

## elgato319

well..

to get userdirs working you need to add "-D USERDIR" to:

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST" 

 *Quote:*   

> #  USERDIR      Enables /~username mapping to /home/username/public_html

 

than restart apache

----------

## dominik_ba

thanks a lot

now it works, the only thing is that i don't know how to enable cgi scripts, on the previous version of apache it was easier.

----------

## elgato319

did you enable suexec?

add "-D SUEXEC" to APACHE2_OPTS.

after that cgi-scripts should be working in /home/*/public_html/cgi-bin

----------

## dominik_ba

it works, 

i emerged apache with suexec in the USE flags. after that APACHE2_OPTS looks like that:

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SUEXEC"

i finally add -D USERDIR

it's like that 

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SUEXEC -D USERDIR"

and it works

----------

## dominik_ba

thanks a lot for those who helped me

----------

