Creating Virtual Hosts in Ubuntu 13.10 Desktop Edition

Discussion in 'Server Operation' started by N3RVE, Jan 26, 2014.

  1. N3RVE

    N3RVE New Member

    Hello There,

    I'm new to server management in Ubuntu. I have a VPS at Linode powered by Ubuntu 13.10 Server edition. I run Ubuntu 13.10 Desktop edition on my laptop and I have a LAMP stack setup with a web directory that works out of an assigned folder in my home folder.

    I'm trying to achieve this setup:

    A new Virtual host setup with an IP address different from the localhost or 127.0.0.1, I tried using 128.0.5.1. So under /etc/apache2/sites-available, I created 128.0.5.1.conf and this is the content of the file:

    Code:
    <VirtualHost *:80>
    	# The ServerName directive sets the request scheme, hostname and port that
    	# the server uses to identify itself. This is used when creating
    	# redirection URLs. In the context of virtual hosts, the ServerName
    	# specifies what hostname must appear in the request's Host: header to
    	# match this virtual host. For the default virtual host (this file) this
    	# value is not decisive as it is used as a last resort host regardless.
    	# However, you must set it for any further virtual host explicitly.
    	
    	ServerName 128.0.5.1
    
    	ServerAdmin webmaster@localhost
    	DocumentRoot /home/n3rve/www2
    
    	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    	# error, crit, alert, emerg.
    	# It is also possible to configure the loglevel for particular
    	# modules, e.g.
    	#LogLevel info ssl:warn
    
    	ErrorLog ${APACHE_LOG_DIR}/error.log
    	CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    	# For most configuration files from conf-available/, which are
    	# enabled or disabled at a global level, it is possible to
    	# include a line for only one particular virtual host. For example the
    	# following line enables the CGI configuration for this host only
    	# after it has been globally disabled with "a2disconf".
    	#Include conf-available/serve-cgi-bin.conf
    
    <Directory "/home/n3rve/www2">
       Order allow,deny
       Allow from all
       AllowOverride FileInfo
       # New directive needed in Apache 2.4.3: 
       Require all granted
    </Directory>
    </VirtualHost>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    I edited the /etc/hosts file as follows:

    Code:
    127.0.0.1	localhost
    127.0.1.1	B-613
    128.0.5.1	localhost
    128.0.5.1	B-613
    128.0.5.1	127.0.0.1
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    
    127.0.0.1 productsearch.ubuntu.com
    Then in a terminal window, I ran a2ensite 128.0.5.1.conf and it asked me to run service apache2 reload which I did. Now when I try to run a2ensite 128.0.5.1, it says Site 128.0.5.1 already enabled.

    When I try to visit http://128.0.5.1, it doesn't work. Looking at the above setup, what have I or haven't I done, and how can I get it working?
    I appreciate any help.
     

Share This Page