Each line of that example will begin with an octothorpe. The octothorpe character marks the line as a comment, so the example is not executed. Add the following lines below that example:. That's all you need to do! Save and close the file. That will tell the Apache server everything it needs to know in order for it to serve the pages using the domain names site1.
One note is that, in the above example, we have a space in the path. Because of that, we put quotation marks around the document root directory. If the path does not have any spaces in it, do not quote the path.
If the directory used for your sites were, for example MySites instead of My Sites, the document root line would look like this instead:. We're next going to edit another file to work around that. The second file you need to edit is called hosts, with no file extension. It is a Windows system file and it will enable you to enter specific addresses for specific domains instead of using a DNS lookup. The normal location for this file is:. If you don't find it there, do a search in your windows directory for the word hosts in the file name.
The file you want is called hosts, with no file extension. The correct file will begin with the following lines:. Once again, in this file, the octothorpe character is a comment marker. Lines beginning with it are comments. In all likelihood, there will be nothing there, except for comments. If there are any other non-commented entries, leave them alone. Just go to the bottom of the file, below all the comments and any existing entries and add the following two lines:.
You're almost done! The only remaining thing you need to do is to re-start the Apache server. How can I set up virtualhost for multiple domain name on Windows? Improve this question. Peter Mortensen Add a comment. Active Oldest Votes. You need to do several steps in order to make this work. Improve this answer.
MicE MicE 4, 2 2 gold badges 27 27 silver badges 26 26 bronze badges. I've been working with a different port and haven't had any luck getting this to work properly on windows. Do you have any advice on this? Using Port for example. One thing which you probably figured out already is that you need to change the vhosts file, i. But everytime I do this, I forget to tell Apache to listen on that port.
Look for " Listen " in your httpd. Plus if you're still on Apache 2. You saved me by mentioning that elusive check for Include I thought it'd be included by default but it wasn't and the tutorial I was using didn't mention it. Works like a charm now. Finally, we are going to edit the host file in Windows This will allow the system to load correctly the virtual hosts we have just created. In that case, opens a CMD as administrator and enters the following commands:. The last command will launch the notepad and it is necessary to add the following lines to the hosts file:.
What we have done is added the IP address and the names of the websites we have just created. This way the system will be able to load them correctly. If you have followed to the letter the instructions I have given you, then it will already be possible to host more than one website on our Apache server. Remember that if you get any errors, then check if the files were edited correctly. To check if everything is OK, open the web browser and enter localhos t.
Finally, we have seen how to enable Apache virtual host in Windows This configuration will allow loading more than one website in the Apache server. Consequently, it will give us more flexibility to program websites. This is all for the time being, until the next time. Status change detected: stopped [Apache] Error: Apache shutdown unexpectedly.
Save my name, email, and website in this browser for the next time I comment. All rights reserved. Sign in. Forgot your password? Get help. Password recovery. OS Radar. By roger. November 19, Edit the index. Modifying the index.
0コメント