# [Solved]Http 404 error when trying to visit virtual host

## jordanwb

So i got webmin installed thanks to avendesora. In Webmin I added a virtual host and set its Document Root to /var/www/site-1/htdocs which exists and chmodded the htodcs folder to 0777. I also set the Virtual Host to listen on port 81. I restarted Apache, point FF to 192.168.1.131:81 and I get the 404 error.Last edited by jordanwb on Tue Aug 19, 2008 7:35 pm; edited 1 time in total

----------

## SeaTiger

Check for log files in /var/log/apache2 first. There should be some access.log and error.log, which properly will give some clues on what went wrong.

----------

## bunder

Moved from Portage & Programming to Networking & Security.

----------

## jordanwb

 *junksiu wrote:*   

> Check for log files in /var/log/apache2 first. There should be some access.log and error.log, which properly will give some clues on what went wrong.

 

Nothing regarding Virtual Hosts. Only the fact that the client couldn't find favicon.ico and that apache started successfully.

----------

## rvr777

Probably apache is showing you the default vhost instead of the one you want. Try to define the domain name you created in Webmin in your /etc/hosts like:

```
127.0.0.1 localhost

192.168.1.131 yourdomain.com
```

And point your browser to http://yourdomain.com:81/ to see if it works.

----------

## jordanwb

 *rvr777 wrote:*   

> Probably apache is showing you the default vhost instead of the one you want. Try to define the domain name you created in Webmin in your /etc/hosts like:
> 
> ```
> 127.0.0.1 localhost
> 
> ...

 

I don't have any domains. I'm accessing the virtual hosts by IP:Port only. If I goto http://192.168.1.131/ I get the "It Works!" page. But If I goto http://192.168.1.131:81 I get the 404 error.

----------

## SeaTiger

Your virtualhost properly is not configure correctly. Post the apache virtualhost config file.

----------

## jordanwb

Which one is that? In the /etc/apache2 folder there is:

Courtesy of "dir -R /etc/apache2":

```
.:

httpd.conf  magic  modules.d  ssl  vhosts.d

./modules.d:

00_default_settings.conf  00_mod_log_config.conf  10_mod_mem_cache.conf

00_error_documents.conf   00_mod_mime.conf     40_mod_ssl.conf

00_languages.conf     00_mod_status.conf     45_mod_dav.conf

00_mod_autoindex.conf     00_mod_userdir.conf     46_mod_ldap.conf

00_mod_info.conf     00_mpm.conf        70_mod_php5.conf

./ssl:

server.crt  server.key

./vhosts.d:

00_default_ssl_vhost.conf  00_default_vhost.conf  default_vhost.include

```

----------

## rvr777

The files under the vhosts.d dir.

----------

## SeaTiger

Post all the following since they may conflict each other:

```
./vhosts.d:

00_default_ssl_vhost.conf  00_default_vhost.conf  default_vhost.include
```

----------

## jordanwb

Well considering that the makers of phpBB decided that file upload wasn't necessary that's going to be hard. Here we go, let's upload it to my dad's website:

http://grime-away.com/archive.tar

BTW Webmin put the second virtual host in /etc/apache2/httpd.conf

----------

## rvr777

 *jordanwb wrote:*   

> BTW Webmin put the second virtual host in /etc/apache2/httpd.conf

 

Then, can you post your httpd.conf?

----------

## jordanwb

```
ServerRoot "/usr/lib/apache2"

LoadModule actions_module modules/mod_actions.so

LoadModule alias_module modules/mod_alias.so

LoadModule auth_basic_module modules/mod_auth_basic.so

LoadModule authn_alias_module modules/mod_authn_alias.so

LoadModule authn_anon_module modules/mod_authn_anon.so

LoadModule authn_dbm_module modules/mod_authn_dbm.so

LoadModule authn_default_module modules/mod_authn_default.so

LoadModule authn_file_module modules/mod_authn_file.so

<IfDefine AUTHNZ_LDAP>

LoadModule authnz_ldap_module modules/mod_authnz_ldap.so

</IfDefine>

LoadModule authz_dbm_module modules/mod_authz_dbm.so

LoadModule authz_default_module modules/mod_authz_default.so

LoadModule authz_groupfile_module modules/mod_authz_groupfile.so

LoadModule authz_host_module modules/mod_authz_host.so

LoadModule authz_owner_module modules/mod_authz_owner.so

LoadModule authz_user_module modules/mod_authz_user.so

LoadModule autoindex_module modules/mod_autoindex.so

<IfDefine CACHE>

LoadModule cache_module modules/mod_cache.so

</IfDefine>

LoadModule cgid_module modules/mod_cgid.so

<IfDefine DAV>

LoadModule dav_module modules/mod_dav.so

</IfDefine>

<IfDefine DAV>

LoadModule dav_fs_module modules/mod_dav_fs.so

</IfDefine>

<IfDefine DAV>

LoadModule dav_lock_module modules/mod_dav_lock.so

</IfDefine>

LoadModule deflate_module modules/mod_deflate.so

LoadModule dir_module modules/mod_dir.so

<IfDefine CACHE>

LoadModule disk_cache_module modules/mod_disk_cache.so

</IfDefine>

LoadModule env_module modules/mod_env.so

LoadModule expires_module modules/mod_expires.so

LoadModule ext_filter_module modules/mod_ext_filter.so

<IfDefine CACHE>

LoadModule file_cache_module modules/mod_file_cache.so

</IfDefine>

LoadModule filter_module modules/mod_filter.so

LoadModule headers_module modules/mod_headers.so

LoadModule include_module modules/mod_include.so

<IfDefine INFO>

LoadModule info_module modules/mod_info.so

</IfDefine>

<IfDefine LDAP>

LoadModule ldap_module modules/mod_ldap.so

</IfDefine>

LoadModule log_config_module modules/mod_log_config.so

LoadModule logio_module modules/mod_logio.so

<IfDefine CACHE>

LoadModule mem_cache_module modules/mod_mem_cache.so

</IfDefine>

LoadModule mime_module modules/mod_mime.so

LoadModule mime_magic_module modules/mod_mime_magic.so

LoadModule negotiation_module modules/mod_negotiation.so

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule setenvif_module modules/mod_setenvif.so

LoadModule speling_module modules/mod_speling.so

<IfDefine SSL>

LoadModule ssl_module modules/mod_ssl.so

</IfDefine>

<IfDefine STATUS>

LoadModule status_module modules/mod_status.so

</IfDefine>

LoadModule unique_id_module modules/mod_unique_id.so

<IfDefine USERDIR>

LoadModule userdir_module modules/mod_userdir.so

</IfDefine>

LoadModule usertrack_module modules/mod_usertrack.so

LoadModule vhost_alias_module modules/mod_vhost_alias.so

User apache

Group apache

Include /etc/apache2/modules.d/*.conf

Include /etc/apache2/vhosts.d/*.conf

ServerName  GentooServer

DocumentRoot /var/www/localhost/htdocs

<VirtualHost *:81>

DocumentRoot "/var/www/site-1/htdocs"

<Directory "/var/www/site-1/htdocs">

allow from all

Options +Indexes

</Directory>

</VirtualHost>

```

I removed all the comments to make it easier.

----------

## rvr777

The DocumentRoot of the vhost in port 81 is set to /var/www/site-1/htdocs. You will have to change the end of your httpd.conf:

```
DocumentRoot /var/www/localhost/htdocs

<VirtualHost *:81>

DocumentRoot "/var/www/site-1/htdocs"

<Directory "/var/www/site-1/htdocs">

allow from all

Options +Indexes

</Directory>

</VirtualHost>
```

To:

```
DocumentRoot /var/www/localhost/htdocs

<VirtualHost *:81>

DocumentRoot "/var/www/localhost/htdocs"

<Directory "/var/www/localhost/htdocs">

allow from all

Options +Indexes

</Directory>

</VirtualHost>
```

So that the two vhosts use the default location (/var/www/localhost/htdocs).

----------

## jordanwb

Actually it should've been

```
DocumentRoot /var/www/site-1/htdocs

<VirtualHost *:81>

DocumentRoot "/var/www/site-1/htdocs"

<Directory "/var/www/site-1/htdocs">

allow from all

Options +Indexes

</Directory>

</VirtualHost>
```

But I still can't connect to http://192.168.1.131:81

This is seriously getting more complicated than it should be.

[Edit #2]

I got it working. I disabled the part in httpd.conf about including those files in vhosts.d and copied the second virtual host (site-1) for the first (localhost) and it works.

```
ServerRoot "/usr/lib/apache2"

LoadModule actions_module modules/mod_actions.so

LoadModule alias_module modules/mod_alias.so

LoadModule auth_basic_module modules/mod_auth_basic.so

LoadModule authn_alias_module modules/mod_authn_alias.so

LoadModule authn_anon_module modules/mod_authn_anon.so

LoadModule authn_dbm_module modules/mod_authn_dbm.so

LoadModule authn_default_module modules/mod_authn_default.so

LoadModule authn_file_module modules/mod_authn_file.so

<IfDefine AUTHNZ_LDAP>

LoadModule authnz_ldap_module modules/mod_authnz_ldap.so

</IfDefine>

LoadModule authz_dbm_module modules/mod_authz_dbm.so

LoadModule authz_default_module modules/mod_authz_default.so

LoadModule authz_groupfile_module modules/mod_authz_groupfile.so

LoadModule authz_host_module modules/mod_authz_host.so

LoadModule authz_owner_module modules/mod_authz_owner.so

LoadModule authz_user_module modules/mod_authz_user.so

LoadModule autoindex_module modules/mod_autoindex.so

<IfDefine CACHE>

LoadModule cache_module modules/mod_cache.so

</IfDefine>

LoadModule cgid_module modules/mod_cgid.so

<IfDefine DAV>

LoadModule dav_module modules/mod_dav.so

</IfDefine>

<IfDefine DAV>

LoadModule dav_fs_module modules/mod_dav_fs.so

</IfDefine>

<IfDefine DAV>

LoadModule dav_lock_module modules/mod_dav_lock.so

</IfDefine>

LoadModule deflate_module modules/mod_deflate.so

LoadModule dir_module modules/mod_dir.so

<IfDefine CACHE>

LoadModule disk_cache_module modules/mod_disk_cache.so

</IfDefine>

LoadModule env_module modules/mod_env.so

LoadModule expires_module modules/mod_expires.so

LoadModule ext_filter_module modules/mod_ext_filter.so

<IfDefine CACHE>

LoadModule file_cache_module modules/mod_file_cache.so

</IfDefine>

LoadModule filter_module modules/mod_filter.so

LoadModule headers_module modules/mod_headers.so

LoadModule include_module modules/mod_include.so

<IfDefine INFO>

LoadModule info_module modules/mod_info.so

</IfDefine>

<IfDefine LDAP>

LoadModule ldap_module modules/mod_ldap.so

</IfDefine>

LoadModule log_config_module modules/mod_log_config.so

LoadModule logio_module modules/mod_logio.so

<IfDefine CACHE>

LoadModule mem_cache_module modules/mod_mem_cache.so

</IfDefine>

LoadModule mime_module modules/mod_mime.so

LoadModule mime_magic_module modules/mod_mime_magic.so

LoadModule negotiation_module modules/mod_negotiation.so

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule setenvif_module modules/mod_setenvif.so

LoadModule speling_module modules/mod_speling.so

<IfDefine SSL>

LoadModule ssl_module modules/mod_ssl.so

</IfDefine>

<IfDefine STATUS>

LoadModule status_module modules/mod_status.so

</IfDefine>

LoadModule unique_id_module modules/mod_unique_id.so

<IfDefine USERDIR>

LoadModule userdir_module modules/mod_userdir.so

</IfDefine>

LoadModule usertrack_module modules/mod_usertrack.so

LoadModule vhost_alias_module modules/mod_vhost_alias.so

User apache

Group apache

Include /etc/apache2/modules.d/*.conf

# Virtual-host support

#

# Gentoo has made using virtual-hosts easy. In /etc/apache2/vhosts.d/ we

# include a default vhost (enabled by adding -D DEFAULT_VHOST to

# APACHE2_OPTS in /etc/conf.d/apache2).

#Include /etc/apache2/vhosts.d/*.conf

# vim: ts=4 filetype=apache

ServerName  GentooServer

#DocumentRoot /var/www/site-1/htdocs

Listen 81

<VirtualHost *:81>

   DocumentRoot "/var/www/site-1/htdocs"

   <Directory "/var/www/site-1/htdocs">

      allow from all

      Options +Indexes

   </Directory>

</VirtualHost>

Listen 80

<VirtualHost *:80>

   DocumentRoot "/var/www/localhost/htdocs"

   <Directory "/var/www/localhost">

      allow from all

      Options +Indexes

   </Directory>

</VirtualHost>

```

----------

