Virtual hosts
|
|
We’re doing web site design, and just got a brand-new iMac. I downloaded the MAMP stack, and it’s working just fine. I’d like to configure so that I can set up web sites for local testing before uploading, and put the files someplace like /user/Sites instead of the default page in the apache2 folder. I’ve gone through lots of docs, edited the conf/httpd.conf file, /etc/hosts, and so forth. No good, I can still get default page but can’t get the new site to come up. And I’ve found more files, /etc/apache2, and /private/etc, and so on… do they get edited? Do I need to set the browser to some strange address? Thanks for any help. |
|
|
Hi PhilC, If you want to set up your website with Mamp Stack, you only need to put source files into apache/htdocs and type http://localhost:port/index.html (or another html/php file). I hope it’s help you. Cheers, |
|
|
Hi again PhilC, Sorry, I think that i didn’t understand correctly your question. Are you running your mac apache web server? In MacOS there are an Apache2 installed by default, and it’s DocumentRoot is in “Sites” folder into your user home. BitNami Mamp Stack installs a new Apache2 in your system, by default it’s runs in 8080 port, and it have his DocumentRoot in apache/htdocs. Can you try to access to http://localhost:8080 ?. You can change BitNami Apache DocumentRoot to another directory in your system editing apache2/conf/httpd.conf: For example:
and
Now you must to restart apache (BitNami) with ”./ctlscript.sh restart”. I hope it’s help you. Cheers, |
|
|
Manu: Thanks for the prompt reply. I was under the impression that MacOS didn’t ship with a default apache server, otherwise I wouldn’t have downloaded the MAMP stack. I have found the apache files with the OS, but it appeared just to be a simple HTML page which any browser can process. Anyway, I did get localhost:8080 up and running, it shows the default Bitnami page. I understand about directing DocumentRoot to some other folder. What I was hoping to do was set up several sites on the hard drive and just go to anyone at any time, just by changing the URL in the browser. Is that not correct? I ran across some information on the net which suggests that I can. If I can only access one at a time, changing httpd.conf, I can live with that. |
|
|
I do a couple different things that might give you what you want. First, I actually have 3 or 4 MAMP stacks installed at a time, each containing different versions of the pages I’m working on. To switch between them, I just shut down the old one and start the new one. For virtual hosts, I’ve taken to modifying the apache2/conf/httpd.conf file. (Actually, I use a separate file and add it as an include at the end of the httpd.conf file, but that’s probably overkill for you.) There’s an example VirtualHost directive already in httpd.conf. You can set multiple virtual hosts on different ports (e.g., 8080, 8081), as long as you make sure to modify the “Listen” line. If you want to set up actual name-based virtual hosts, you can do that, but you’ll need to add entries to your /etc/hosts file. For example, mine has a line that looks like “127.0.0.1 tjlocal”. That allows me to enter http://tjlocal:8080/ into my browser and get the tjlocal virtual host (which is local mirror of http://truejeans.com/ ). I’m happy to provide more details, but this should give you an idea of a couple approaches that have worked for me. I actually use a combination of all three for various purposes. Thom |
|
|
Thanks for the answer Thom :) |
