English
Ask Your Question
0

Multiple Hosts on httpd-Apache in Fedora 18 not working

asked 2013-05-19 21:39:13 +0000

brotherBonzai gravatar image

updated 2014-09-28 15:58:19 +0000

mether gravatar image

I have moved web development from Ubuntu to Fedora and am having troubles getting set up on my local environment. My set up only needs to be viewed from my laptop only. On Ubuntu my set up worked with the hosts file looking like so:

127.0.0.1  localhost
127.0.0.2  site-1
127.0.0.3  site2
...

/etc/hosts on my Fedora 18 looks like this:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 

I tried adding "site-1 site-2" to the end of each line, also tried adding localhost.site-1 localhost.site-2 as I've seen mentioned.

I also tried adding them to their own line.

hostname looks like so: localhost.localdomain

Here is the httpd file. For conciseness I removed most of documentation but left some of the commands I tried but failed with. My additions are at the bottom.

ServerRoot "/etc/httpd"

#Listen 12.34.56.78:80
Listen 80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

#ServerName www.example.com:80
#NameVirtualHost *:80
#NameVirtualHost 127.0.0.1
#NameVirtualHost 127.0.0.2
#NameVirtualHost 127.0.0.3
#ServerName localhost
#ServerName site-1
#ServerName site-2

<directory/>
    AllowOverride none
    Require all denied
</directory>

#DocumentRoot "/var/www/html*"

# Relax access to content within /var/www.
#
#<directory "="" var="" www"="">
#    AllowOverride None
    # Allow open access:
#    Require all granted
#</directory>

# Further relax access to the default document root:
#<directory "="" var="" www="" html"="">

#    Options Indexes FollowSymLinks

#    AllowOverride None

#    Require all granted
#</directory>

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<ifmodule dir_module="">
    DirectoryIndex index.html
</ifmodule>

#<files ".ht*"="">
#    Require all denied
#</files>

#ErrorLog "logs/error_log"

LogLevel warn

<ifmodule log_config_module="">

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <ifmodule logio_module="">
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </ifmodule>

    #CustomLog "logs/access_log" common

    CustomLog "logs/access_log" combined
</ifmodule>

<ifmodule alias_module="">

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</ifmodule>

<directory "="" var="" www="" cgi-bin"="">
    AllowOverride None
    Options None
    Require all granted
</directory>

<ifmodule mime_module="">

    TypesConfig /etc/mime.types

    #AddType application/x-gzip .tgz

    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #AddHandler type-map var

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</ifmodule>

AddDefaultCharset UTF-8

MIMEMagicFile conf/magic

#EnableMMAP off
EnableSendfile on

# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
# Place any notes or comments you have here
# It will make any customization easier to understand in the weeks to come
# User Defined Multiple Hosting

<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin webmaster@localhost
  ServerName  localhost
  ServerAlias localhost

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html
  DocumentRoot /var/www/html/localhost/view/site

  # Custom log file locations
  LogLevel warn
  ErrorLog ...
(more)
edit retag flag offensive close merge delete

Comments

check your SELinux log, '/var/www/html/logs/..' is not the default place for apache log files

Rabin ( 2013-05-19 22:19:11 +0000 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-05-21 02:21:34 +0000

updated 2013-05-21 02:27:24 +0000

The status log is pretty direct: You've specified root directories and logs for your vhost that don't exist.

The fooling around with IP addresses does nothing for you. Stop doing that. <VirtualHost *:80> means that the vhost will answer to any IP it listens on, as long as it has the right name. so, use

127.0.0.1 localhost site-1 site-2

To make things easier on yourself, create one conf file for each vhost, ie /etc/httpd/conf.d/site-1.conf

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

Follow
1 follower

Stats

Asked: 2013-05-19 21:39:13 +0000

Seen: 3,732 times

Last updated: May 21 '13