Results 1 to 2 of 2

Thread: OS 13.1 - Apache 2.4.6 - VHOSTS config questions

  1. #1
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,037

    Default OS 13.1 - Apache 2.4.6 - VHOSTS config questions

    hello.
    I plan to create a web server which is installed for the moment on local network.
    I am using apache 2.4.6 on opensuse 13.1
    I want to use name based virtual hosts.

    There is no dns server

    After reading a lot, i have found that the definition and the use for
    NameVirtualHost
    VirtualHost
    ServerName
    ServerAlias
    ServerPath
    are not very clear for me.

    Here is my config.

    On the web server (192.168.130.100)
    ===================================

    /etc/resolv.conf file is configured as :
    ++++++++++++++++++++++++++++++++++

    Code:
    search lan
    nameserver 192.168.1360.230
    /etc/hosts file is configured as :
    ++++++++++++++++++++++++++++++++++

    Code:
    192.168.130.100    LINUX-TEST-123.my-dom.nwk    LINUX-TEST-123
    #
    # LOCAL
    127.0.0.1            localhost.localdomain        localhost
    # ------------ PROJECT 1
    127.0.0.1            project_1.my-dom.nwk        project_1
    # ------------ PROJECT 1
    127.0.0.1            project_2.my-dom.nwk        project_2
    #
    /etc/sysconfig contains :
    +++++++++++++++++++++++++

    Code:
    APACHE_CONF_INCLUDE_FILES="/etc/apache2/httpd.local.conf"
    /etc/apache2/httpd.local.conf contains :
    ++++++++++++++++++++++++++++++++++++++++

    Code:
    <Directory /srv/www/htdocs>
        Options +FollowSymLinks
    </Directory>
    
    IncludeOptional /etc/apache2/my_virtual_hosts/*.conf
    /etc/listen.conf
    ++++++++++++++++

    Code:
    Listen 80
    
    
    <IfDefine SSL>
        <IfDefine !NOSSL>
        <IfModule mod_ssl.c>
    
            Listen 443
    
        </IfModule>
        </IfDefine>
    </IfDefine>
    
    
    # Use name-based virtual hosting
    NameVirtualHost *:80
    /etc/apache2/my_virtual_hosts/project_1.conf contains :
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Code:
    <VirtualHost *:80>
        ServerAdmin root@LINUX-TEST-123.hathor-nwk
        ServerName  ?????????????????
        ServerAlias ?????????????????
    
        # symbolic links
        DocumentRoot /srv/www/htdocs/PROJECT_1
    
        # if not specified, the global error log is used
        ErrorLog  /var/log/apache2/PROJECT_1-error_log
        CustomLog /var/log/apache2/PROJECT_1-access_log  combined
    
        # don't loose time with IP address lookups
        HostnameLookups Off
    
        # needed for named virtual hosts
        UseCanonicalName Off
    
        # configures the footer on server-generated documents
        ServerSignature On
    
        #
        <IfModule mod_userdir.c>
        UserDir public_html
        Include /etc/apache2/mod_userdir.conf
        </IfModule>
    
        #
        # This should be changed to whatever you set DocumentRoot to.
        #
        <Directory "/srv/www/htdocs/PROJECT_1">
    
            Options Indexes FollowSymLinks
    
    #        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
            Order allow,deny
            Allow from all
    
        </Directory>
    
    </VirtualHost>
    Physically, data are kept on /data1_pub/400_SERVEUR_WEB/PROJECT_1/001_keep_final_ok/public_html/

    a link is created in /srv/www/htdocs/WEB_1

    /etc/apache2/my_virtual_hosts/project_2.conf contains :
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Code:
    <VirtualHost *:80>
        ServerAdmin root@LINUX-TEST-123.hathor-nwk
        ServerName  ?????????????????
        ServerAlias ?????????????????
    
        # symbolic links
        DocumentRoot ?????????????????
    
        # if not specified, the global error log is used
        ErrorLog  /var/log/apache2/PROJECT_2-error_log
        CustomLog /var/log/apache2/PROJECT_2-access_log  combined
    
        # don't loose time with IP address lookups
        HostnameLookups Off
    
        # needed for named virtual hosts
        UseCanonicalName Off
    
        # configures the footer on server-generated documents
        ServerSignature On
    
        #
        <IfModule mod_userdir.c>
            UserDir public_html
            Include /etc/apache2/mod_userdir.conf
        </IfModule>
    
        #
        # This should be changed to whatever you set DocumentRoot to.
        #
        <Directory "/srv/www/htdocs/PROJECT_2">
    
            Options Indexes FollowSymLinks
    
    #        AllowOverride None
    
        #
        # Controls who can get stuff from this server.
        #
            Order allow,deny
            Allow from all
    
        </Directory>
    
    </VirtualHost>
    Physically, data are kept on /data1_pub/400_SERVEUR_WEB/PROJECT_2/001_keep_final_ok/public_html/

    a link is created in /srv/www/htdocs/WEB_2

    /etc/apache2/default-vhost.conf contains :
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Code:
    EMPTY
    /etc/apache2/default-server.conf contains :
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Code:
    (Left unmodified)
    
    #
    # Configure the DocumentRoot
    #
    <Directory "/srv/www/htdocs">
        Options None
    #    AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
    #
    Alias /icons/ "/usr/share/apache2/icons/"
    
    <Directory "/usr/share/apache2/icons">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
    #
    ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
    
    <Directory "/srv/www/cgi-bin">
        AllowOverride None
        Options +ExecCGI -Includes
        Order allow,deny
        Allow from all
    </Directory>
    
    #
    <IfModule mod_userdir.c>
        UserDir public_html
        Include /etc/apache2/mod_userdir.conf
    </IfModule>
    
    #
    IncludeOptional /etc/apache2/conf.d/*.conf
    
    # The manual... if it is installed ('?' means it won't complain)
    IncludeOptional /etc/apache2/conf.d/apache2-manual?conf
    On a client linux box
    ===================================

    /etc/resolv.conf file is configured as :
    ++++++++++++++++++++++++++++++++++

    Code:
    search lan
    nameserver 192.168.1360.230
    /etc/hosts file is configured as :
    ++++++++++++++++++++++++++++++++++

    Code:
    # LOCAL
    127.0.0.1            localhost.localdomain        localhost
    # MY NETWORK
    192.168.130.100    LINUX-TEST-123.my-dom.nwk    LINUX-TEST-123

    I have a few questions.

    I want users getting access by these address from the local network

    http://my-dom.nwk/web_1 or web_1
    and
    http://my-dom.nwk/web_2 or web_2

    From internet when I will setup my domain through OpenDNS
    http://my-dom.nwk/web_1
    and
    http://my-dom.nwk/web_2

    What should I put in the /etc/hosts on a client soandshoulde be resolved

    What should I put in /etc/apache2/my_virtual_hosts/project_1.conf and /etc/apache2/my_virtual_hosts/project_2.conf for
    ServerName ?????????????????
    ServerAlias ?????????????????
    DocumentRoot ?????????????????
    <Directory "/srv/www/htdocs/??????????">

    Where to configure a default VHOSTS so I show a web page error if a bad web server project is specified. ( there are VHOSTS configured in /etc/apache2/my_virtual_hosts )

    What name should be written in upper case or lower case letters accordingly
    with physical location on disks or definitions in files ?
    Any help is welcome.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.0 -- ASUS g750JZ Optimus KDE leap 15.1 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  2. #2
    Join Date
    Mar 2014
    Location
    US
    Posts
    115

    Default Re: OS 13.1 - Apache 2.4.6 - VHOSTS config questions

    Yowza, lot of questions. Let me first say I've only dabbled in apache, so I'll do the best I can to point you in the right direction. First, easy stuff. /etc/resolv.conf ...don't care. Second, /etc/hosts ...don't care, but fyi it should contain your local network, so mine looks like this

    Code:
    127.0.0.1          localhost
    192.168.10.1     router.local.loc   router
    192.168.10.2     acer.local.loc      acer
    192.168.10.3     Lenovo.local.loc  lenovo
    next, /etc/sysconfig- leave it alone, /etc/apache2/httpd.local.conf- leave alone, /etc/listen.conf- leave alone, basically anything Apache installed is ok as is. Your changes start with the ../my_virtual_hosts/ directory. This is where you start your virtual hosts and you'll have a file for each of your hosts, so for instance, you'll have one named WEB1 and another for WEB2. For now, they will be almost be identical except for the following:
    "ServerName" is the FQDN of the site, so for WEB1 it will be www.web1.com
    "ServerAlias" is just, well an alias, so: web1
    "DocumentRoot", this tells apache were to find the info for this website. So lets say you want them all in one spot to make life easy. say under /srv/www/, then your WEB1 will have a DocumentRoot of /srv/www/WEB1, WEB2 will have a DocumentRoot of /srv/www/WEB2 and so on.

    Basically that's it, just create the directories WEB1 and WEB2 under /srv/www. If you want, just create two simple index.html files with the content of one being "You've reached WEB1" and the other saying "You've reached WEB2" and put them in their respective directories.

    Final step, change group and owner of WEB1, WEB2 and all files and sub-directories to owner: wwwrun, group: www. You will probably also want to change all permissions to a minimum of 744 or better 644.

    Hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •