Results 1 to 3 of 3

Thread: LAMP with localhost subdomains

  1. #1
    Join Date
    Jul 2011
    Beans
    2

    Question LAMP with localhost subdomains

    Hi, I was trying to create localhost server with subdomains, but it doesn't seem to work.

    I was following this guide. I did all the required steps, but it doesn't work after 2 subdomains, a.localhost worked, but after adding b.localhost it stopped from working, it just redirects to a.localhost

    What could be the problem?

    Here are some config files that I have edited, by the guidance of the previously mentioned link.

    Code:
    root@Grimoire:~# cat /etc/hosts
    127.0.0.1 a.localhost
    127.0.0.1 b.localhost
    127.0.1.1 Grimoire
    root@Grimoire:~# cat /etc/apache2/sites-available/a 
    <VirtualHost *>
    	DocumentRoot /var/www/a/
    	ServerName a.localhost
    
    	<Directory /var/www/a/>
    		Options Indexes FollowSymLinks MultiViews
    		#AllowOverride None
    		AllowOverride All
    		Order allow,deny
    		allow from all
    	</Directory>
    	ErrorLog /var/log/apache2/a-error.log
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel warn
    
    	CustomLog /var/log/apache2/a-access.log combined
    </VirtualHost>
    root@Grimoire:~# cat /etc/apache2/sites-available/b
    <VirtualHost *>
    	DocumentRoot /var/www/b/
    	ServerName b.localhost
    
    	<Directory /var/www/b/>
    		Options Indexes FollowSymLinks MultiViews
    		#AllowOverride None
    		AllowOverride All
    		Order allow,deny
    		allow from all
    	</Directory>
    	ErrorLog /var/log/apache2/b-error.log
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel warn
    
    	CustomLog /var/log/apache2/b-access.log combined
    </VirtualHost>
    Hope these might be able to help.

  2. #2
    Join Date
    May 2007
    Location
    NY's first capital
    Beans
    2,648
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: LAMP with localhost subdomains

    I'm not sure why it is not mentioned in the tutorial, buy apache needs to "know" you want to use the NameVirtualHost directive.

    Try adding the following to
    /etc/apache2/httpd.conf

    Code:
    NameVirtualHost *
    I have seen your symptom many many times. Seems some folks never got it to work. I have yet to find in any documentation where this directive should actually reside. I have seen posts recommending placing the above line in ports.conf. So you could try each location if one or the other does not work.

    Be sure to restart apache after the change.
    Nothing is ever easy, but if it is difficult you must be doing it wrong.

  3. #3
    Join Date
    Jul 2011
    Beans
    2

    Re: LAMP with localhost subdomains

    Great! Now it works as it should work. Should try to get someone update the page with up-to-date info.

    Update: Added the info that volkswagner gave into the community help page. Hope it helps other people too.
    Last edited by gurnarok; July 22nd, 2011 at 11:38 AM.

Tags for this Thread

Bookmarks

Posting Permissions

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