You are here
Hey Guys,
We are using turnkey linux magento with turnkey HUB backup ( awesome and low pricing so highly recommended :).
Now we want to setup Vhosts on our server, i will give as much info as i can and think of right now.I am breaking my head on this now for over a week and just can't get it to work...
I tried everything i can find on the internet, problem is that on our server is used Apache 2.2.22 and most people have either older versions of Apache or newer, so it never fits on what i can read.
Because this version does not seem to work with a Httpd.conf file and there is this file etc/apache2/sites-enabled/000-default wich seems to be empty.
Now if i use webmin and add use ''Create virtual host'' and fill everything with what is needed stated on apache website.
Either only the first website that is on the server will listen to both URL's we have OR i get it to work to only have the second website listen to both urls.
So either one of two websites is available with both urls.
www.website1.be ans www.website2.com
maybe also good to know, we have a dedicated Ip adres for the server, both url's we have point to this ip adress.
Server is behind a router that is connected to the modem wich has the dedicated IP.
I know for sure i am doing something wrong, or forget to do something elsewhere but just can't put my finger on it.
I know you guys will need more info, so will give it to you upon request.
Highly appreciated if someone wants to dig in to this.
Greetings.
The biggest thing to keep in mind re Apache config
By default (Apache upstream & RedHat et al) Apache has a (massive) monolithic config file often called httpd.conf. In Debian (and derivs) that monolithic file is broken down and split into different sections, with each section contained in a different conf file.
So to change or add a port for Apache to listen on; instead of looking for the ports declaration in /etc/httpd/conf/httpd.conf (RedHat et al) you just edit /etc/apache2/ports.conf. Instead of adding a new virtualhost to your monolithic httpd.conf; you add a new site file (containing your vhost info) to /etc/apache2/sites-available. You then enable it with 'a2ensite site-name'. FWIW the a2ensite command simply creates a symlink from /etc/apache2/sites-available/site.conf to /etc/apache2/sites-enabled/site.conf
Note as of Apache2.4 (not the version you are using; the next one that is in Debian Jessie and will be in TKL v14.0) the vhost (sites) file must have a .conf file extension. So even though it's not required for the version you are working with it's probably a good habit to get into now...
Personally I have had limited success with the Webmin module although TBH I didn't try very hard... Once you get your head around the differences between Apache implementations and only read the right info (i.e. as a TKL user read stuff that explicitly relates to Debian/Ubuntu) then it isn't that hard to set up...
So IMO the first step is to do some reading about Apache config in Debian Wheezy (aka Debian 7). That should get you headed in the right direction. Then adjust the existing enabled site (have a peek in /etc/apache2/sites-enabled/ to see what's enabled already). Also I recommend that you create a local backup of any files that you edit so you can easily roll back changes if they don't work. So here's how I'd start:
Then go crazy editing and changing things around until it works how you want. Remember that Apache needs to be restarted before changes are applied (service apache2 restart). Personally I'd be inclined to make a separate site file (in /etc/apache2/sites-available/; enabled with a2emsite) for your new domain (so they are somewhat independent of one another).
I'm sorry that I'm probably light on specifics but hopefully that will get you going in the right direction. Have a little read and a play and please please post back. If you've worked it all out then share your victory and what managed to get it working for you. Or if you still can't get it then hopefully someone (probably me) will try to help you further...
Hey Jeremy, Thank you very
Hey Jeremy,
Thank you very much for your time and help.
Seems that i have been doing things right, i used A2ensite and A2dissite.
I also see the links in the the map ''sites-enabled''.
But most of the time it's just the first installed website in the main root folder that will be seen with both URL's.
Strange thing that i can't get figured out is the 000-default map.
It is blanco, but if i put code in it, from what i found on the internet, the webiste goes down.
So my guess is that i need to put something in there that is crucial for getting things to work ?
Or am i totally wrong.
For sure i will search further, but i am missing something crucial here and i just can't get it figured out.
But if i do, i surely will share it here!!!
In the mean time, if just anybody had this figured out allready, pleasse share :)
Thanks in advance!
Dave.
You need to make virtual hosts listen respond to specific site
So instead of:
You will need something like: and Then www.website1.be should display /var/www/website1/index.php and www.website2.be should display /var/www/website2/index.phpAs I said I would recommend putting them in separate site files. E.g. /etc/apache2/sites-available/website1 & /etc/apache2/sites-available/website2 and then enabling them with a2ensite website1 & a2ensite website2.
If you do this as root (which you probably are), then you may need to change the file permissions. The easiest (although not the most secure) way is to make www-data (the webserver user account) own all the while directory tree:
Also don't forget to restart Apache after any config changes.
overlapse
Tried it, but this is what i get:
Oops, my bad! Looks like I've lead you astray...
So this time I actually looked it up. Have a look here. To make life easier; I have translated that to what you'll need to do for your scenario:
As noted in the docs you could swap out the asterisk for the actual IP address (not the name! Doh!) but it's not required...
Apologies on the confusion and misdirection...
Impossible vhosts
Hey Jeremy,
Also tried that, i think i allready did that.
I can for sure say i tried everything, found on the internet.
For me it is impossible to find out what causes it not to work.
Or the website that i put in the /var/www root folder shows always up, even if i use the second URL.
Or i get the other website under both url's, but seperate is impossible.
Do you know if i have to do something in the /etc/hosts file ?
Thanks for you time !
Hmm that sucks!
I'll have to sit down and have a play and see if I can get it working. Unfortunately ATM I'm flat out trying to get the v14.0 release out the door, so please excuse my lack of further help...
The things that occur to me (OTTOMH) are:
It sucks, not you :)
Jeremy,
First of all , your support is highly appreciated !
So if it works or not, that does not matter !!!
I am happy i have someone who wants to think with me, so any input is highly appreciated.
I share a virtual beer with you ;)
I know apache needs to be restarted with every setting that is used, it is one of the things people keep hammering on when giving support.
Maybe i am the biggest factor of not getting it done, for sure i am not a linux guru !
Despite that i really used all that i could find at many many many threads resulting almost every time with ''yeajjjj it works, or thank you so much this worked for me'' from all kinds of readers of that post.
Only those answers seem not to be the fix for my version of apache / webmin.
The stupid thing is, i can delete every vhost , also of the website that is in the main root folder : /var/www
The damn website keeps working.
Even if there is no VHOST, so somewere there must be a ''default'' setting ???
It seems the main website is this vhost/etc/apache2/sites-enabled/magento
If i empty the conf file ''magento'' the website still works, do i even put one word in it press save and restart apache then the website get's unreachable.
So why is it possible to delete that config file, and still have a working website, is that because there is always a default that says, send every url from the ip adress to the /var/www folder ?
Now, last thing i have done is this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.mywebsite.be
ServerAlias mywebsite.be *.website.be
DocumentRoot /var/www
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.com
DocumentRoot /var/vhosts/magento
</VirtualHost>
After saving and restarting i get this warning:
Failed to start apache :
My understanding is that with no conf it should not work!
By default there should be 2 symlinks; one to /etc/apache2/sites-avaialble/magento and the other to /etc/apache2/sites-avaialble/phpmyadmin If you have any more than that that is possibly your issue... Feel free to post the result of the above command if you want my input...
Also I only just noticed; in your error message:
That is the port that PHPMyAdmin is served on by default. If you have an overlap on that then there it must be defined in multiple places.Please post back the result to this:
Also make sure that Apache has read permissions to your Magento site (/var/vhosts/magento); although I assume that it does (as you say that bit works).Also perhaps it is worth downloading a clean appliance; boot it up in VirtualBox (or similar); edit your hosts file (on the host system) to point ot your VM (with 2 different test server names). Then muck around with that until it works... Then once you have a known good config you can try transferring it back to your current system...
root@magento ~# ls -l
Hmm ok
Also looks like you have mail (probably error info). Read it like this:
and when you want to get rid of it:VICTORY
Hey Jeremy,
As you posted, i build a new server setup with parts that ia had laying around.
Installed exact same software distro.
I could setup the vhost's in a heartbeat, really just in a few minutes i had it working.
I read so much tutorials that the setup was a piece of cake.
So that raised the question, why in the world does that not work for the live server.
So I opened all config files side by side and took over all that was different.
It worked, unfortunately i can't say what was the faulty thing, as there were a lot things different.
But all in a same kind of way.
Like: Listen *:12321
insted of Listen 12321
So in the ports.conf file it looks like this now:
#Listen *:12322
#Listen *:12325
#Listen *:12326
Listen 12322
And also in the vhosts file i had some of these that should not be there ( '' )
Like : DocumentRoot ''/var/www/''
instead of DocumentRoot /var/www/
Also copied the hosts file in /etc as there also was something others configered.
Only i still have this thing to work out:
I do not know why, but now it works.
Thanks for sharing your thoughts with me.
Greetings,
Dave.
Glad you finally got it working! :)
Also FWIW using virtualisation is a very handy way to test stuff. Essentially you can do what you did on you old hardware but it's much easier to work with and worst case to can trash it and start again quite easily... VirtualBox is easy to use, cross platform and free!
Add new comment