Hello Drupal folk,
This one is aimed at those who have a mac and use a virtual host to make their drupal sites.
I have followed the steps in this tutorial: http://www.entityarts.net/blog/steve_krueger/07-19-2007/virtualhosts_mam...
And tried to do some research but it all pretty much follows the same set up.
I have also set MAMP to use port 80 (8889 for MySQL) so I don't have to type the port number as well.
What I want
My localhost root I want to be is: /User/imac/foo
I would like my site "root" (say www.domain.dev) to be: /User/imac/foo/site
follow the steps in the tutorial
My httpd.conf file
/Applications/MAMP/conf/apache/httpd.conf
Have added at the bottom of the file
<VirtualHost 127.0.0.1>
DocumentRoot /Users/imac/foo
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot /Users/imac/foo/site
ServerName www.domain.dev
</VirtualHost>
My hosts file
(/private/etc/hosts)
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 www.mydomain.dev
And it seems as if the addresses are reversed when I visit http://localhost/ it shows the hello word file (from the site folder). When I visit www.domain.dev I am shown the file structure from the foo folder.
Any suggests on what I may be missing?
Thanks in advance.
Comments
See these posts of mine to
See these posts of mine to maybe help with MAMP virtual hosts:
http://drupal.org/node/353266#comment-1178828
http://drupal.org/node/354895#comment-1185035
Let me know if that does the trick. Try out the Hosts widget I mention, as it has been the easiest way for me (never fails to flush DNS for me, etc, so it always works the moment I save a new entry). If you do manually edit /etc/hosts, at least the source I learned from a long time ago said you had to edit it using sudo (not just nano /etc/hosts).
I'm not sure if it's due to having migrated through several versions of MAMP, but my httpd.conf does not have the VirtualHost 127.0.0.1 that's mentioned in the link you posted.
-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides
Thanks for the quick reply
I have added that hosts widget as I am not great with terminal.
I also deleted the virtualHost 127.0.0.1
Am I misunderstanding how the final result should work.
Say I want to have
www.domain.dev1
www.domain.dev2
I will add to the httpd.conf file
And add them to the hosts file using the Hosts Widget.
Does this mean I can then access localhost, www.domain.dev1 and www.domain.dev2 in the browser and it will show the individual index.php files for each respective location?
As with the current set up if I try localhost, www.domain.dev2
They are showing the dev1 site (Users/imace/foo/site/1)
Am I right in thinking that it shouldn't be doing this, or do you have to comment out info when you wish to change sites?
The only thing I'm seeing
The only thing I'm seeing right off that's hinting to me of a possible issue is the www ... try to set it up without using www, so that you enter http://site1.dev in your browser to pull it up. It's a local site and there's really no purpose for adding the www, even if the online version will have it.
Also make sure that you've properly setup your path to htdocs in MAMP's settings. In the "Apache" tab of MAMP, set the document root to exactly: /Users/imace/foo (where foo is htdocs). Inside that put folders for the actual sites. In my case I separate these one extra level as well with several initial folders for better organization, and sites inside this group of parent folders (e.g. one folder for my own sites, one for client sites, and one for cms testing/random stuff). So one example of a path for me (as entered in my VirtualHost) would be /Users/MyAccount/htdocs/cms/drupal6-test. The path for document root set in MAMP is /Users/MyAccount/htdocs. The drupal6-test folder is the folder containing Drupal (e.g I extracted the tar.gz and renamed the resulting folder to that name).
-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides
Your understanding is
Your understanding is correct. It must be some small detail.
Do you have a
NameVirtualHost *line before the vhosts?Do you restart Apache every time you make a change?
Cheers for the replies
The NameVirtualHost * was commented out. but I removed the #.
Restarted my entire computer... but still the same issue.
Also removed the www from the addresses.
I will look into VirtualHostX, but also wouldn't mind figuring out how I'm missing this... may try reinstall MAMP...
Look at your domain names
Apache always defaults to the first entry in the vhosts file if it can't find a match. You have "ServerName www.domain.dev" (NOT www.mydomain.dev) in the vhosts file and "www.mydomain.dev" in the hosts file. Those domain names don't match, so apache defaults to the first entry (as I understand it) and you get the directory structure of /foo - working as designed, I think.
I've had a whisky to many to sort your other problem but see if this sorts one of them :-)
Colin
I did send another reply... but
Thanks for the reply..
For some reason it is now working... I'm not sure what made it start to play ball.
Good spot, but in my follow up reply where I had two different domains, it was still having the same issue. And i didn't have a domain - mydomain discrepancy.
Final Code
I tried to test by deleting the httpd.conf file and replacing it with the back up, then adding all the details again. But still had the same issues.
I then started swapping around the code, so putting c2 before c1:
This started working, then when I swapped it back it would cause the issue again... was sort of going in circles for a while then it started working. So I added another one and an extra code for localhost so I can still have that option.
Sorry to anyone else looking for a solution to this problem... but I'm not quite sure...
NB: To follow up I can use www in the addresses but have decided to leave it out
Take the easy route...
Check out VirtualHostX. Spend c $9 and save yourself the hassle. I use MAMP Pro to do the same thing but this is a much more affordable option.
VirtualX, as you mentioned,
VirtualHostX, as you mentioned, is now $37.18.
In my opinion, use a decent code editor to edit the file as needed. This way, you will also get a better understanding of how the file is structured. TextWrangler is a decent free editor for basic editing.
Possible solution
I know it seems a bit late, but after getting stuck in the same rut, I noticed one thing in the code examples that seemed different. In the first listing of the httpd.config file Sheedz shows us this.
By the time his configuration is working he shows us this.
The difference is in the Virtual Host used for the localhost. Initially it was this
<VirtualHost 127.0.0.1>. Once it is set to<VirtualHost *>the whole thing seemed to work for me.I hope this helps out someone else :)
This works
I too struggled with this very same issue for two days before I stumbled upon this post. Most tutorial forget to tell you to do two things:
This seems to have solved my issue.
Thanks to all who contributed to posting this solution!
confirm that it works after
confirm that it works after changing the lines in MAMP's default httpd-vhosts.conf
from:
NameVirtualHost *:80
to:
NameVirtualHost *
D8 setup
Hi Folks,
If anyone is facing issues regarding setup the multi site in D8. Please follow the below steps.
Here I am going to create a new sub site in D8 named - domain1.com.
1. Just navigate to the Drupal 8 root dir.
2. Goto sites folder.
3. Create a new file sites.php or you can copy example.sites.php and rename it.
4. Put below code in sites.php.
5. Now inside the sites folder create a folder named - domain1
6. Inside domain1 folder , you should have 3 folders.
A. modules
B. files
C. settings.php
7. if you already have db then link db from settings.php, if not then copy default.settings.php and paste it followed by rename to settings.php in domain1 folder and place the below code at the bottom of the file.
8. Now if you are using mac or linux then fire below command.
Add the following line at the end of the file.
9. Now the last step will be to map your hosts and drupal.
Please note you need to enable vhosts file include from httpd.conf file.
Uncomment below in httpd.conf file to include vhosts.
to