Forum Moderators: phranque

Message Too Old, No Replies

Problem setting up Xampp virtual hosts (Linux)

         

mack

5:02 pm on Apr 24, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I'm having a few issues getting virtual hosts setup correctly running Xampp under Ubuntu Linux.

The location of my website files is...

/Home/Documents/Websites/example
/Home/Documents/Websites/example2

Each of these folders contains a website, I want to be able to access these sites using
www.example.lan and www.example2.lan


I have added the followig to my httpd-vhosts.conf...

<VirtualHost *:80>
ServerName www.example.lan
DocumentRoot /Home/Documents/Websites/example
ServerAdmin webmaster@example.com
ErrorLog /var/log/apache2/www.example.lan-error_log
CustomLog /var/log/apache2/www.example.lan-access_log common
</VirtualHost>


<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example2.com
DocumentRoot /Home/Documents/Websites/example2
ServerName example2.lan
ServerAlias www.example2.lan
ErrorLog logs/www.example2.lan-error_log
CustomLog logs/ww.example2.lan-access_log common
</VirtualHost>


I also added the following to my host file...


127.0.0.1 localhost
127.0.1.1 www.example.lan
127.0.1.1 www.example2.lan


After a restart of apache both domains do go to locahosts, but not their correct content. It simple loads a page I have at default doc root.

Any ideas.

Mack.

mack

6:28 pm on Apr 24, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Solved! :)

I was looking through the main httpd.conf file and by default virtual hosting is disabled unless included within the main configuration file..

# XAMPP
#Include etc/extra/httpd-xampp.conf

uncomment line 2 from above will call your file listing virtual host entries. It would have been handy if they had placed this information as a comment within httpd-vhosts.conf

Mack.

jdMorgan

12:39 am on Apr 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for posting your solution -- You had it fixed before I even saw your first post!

Jim

ozstar

11:49 am on May 2, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,

What is the main config file you are referring to?

Thanks

oz :-)

mack

1:14 pm on May 2, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



The main config file I was referinf to is httpd.conf in the past a standard Apache install would generaly only have thus one global configuration file. Now it appears to be modular with the main configuration file that includes several other files. Each serves its own purpose, but because they are called as includes that all act as building blocks of httpd.conf

It does make it easier to understand as opposed to one very large often fairly complicated file.

Mack.

ozstar

10:52 pm on May 2, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks.

I looked in that file and those lines were uncommented in the MEPIS distro which I am using, so I didn't have that problem.

I stll cannot get to my sites though, localhost says it can't find the address.

I have checked the httpd-vhosts file and it looks okay.

In XP and wamp one has to use make reference to the virtual sites in an XP file in /system32/ called 'hosts', however I am not sure where that file would be in Linux.

Any ideas?


oz :-)

encyclo

11:10 pm on May 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure where that file would be in Linux.


/etc/hosts
:)

One question though - why Xampp? Ubuntu comes with Apache and MySQL ready to install via apt-get, all preconfigured with sane defaults (which is more than can be said for the security nightmare that is Xampp). There are tools for adding virtual hosts and everything, no need to use a third-party solution which is not covered by the usual system security updates.

ozstar

11:23 pm on May 2, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi encyclo,

It was a mine field trying to find an easy to use front end for Linux for a Ms slave of many years. I stumbled on Mepis on YouTube and the help files were excellent.

As a user of wamp I just moved over to Xampp although I though it would be more like wamp than it is.

As I learn more, it may be that I move over to another more secure one like as you say, Ubuntu.

Appreciate the help.

oz :-)

mack

12:09 am on May 3, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Why xampp? Good question...

The system default with Ubuntu involves several folders, in different areas of the file system. With xampp its all in one folder, so rsync is a lot easier. It's also possible use nfs to mount that folder on any other system on the LAN.

Mack.

ozstar

1:16 am on May 3, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



Okay, I have found the file and set it up okay.

The content is a little different than in wamp but with some testing found this works..

127.0.0.1 mywebsite.com mywebsite

oz :-)