Forum Moderators: phranque
As and example I get the above title in the url but page says not found.
I am still confused how I set up apache to know where to look for my web sites
Or for dreamweaver to know where the server is?
When I installed dreamweaver I correctly identified localhost as my server.
I feel that I some how need to tell both pieces of software where my websites will be stored on my local machine.
I want a testing server on my PC only.
Help
Jim
If it does, then you have Apache installed correctly. So therefore, all you need to do is make sure that you have your Dreamweaver "Site" setup correctly so that the "Local Files" of the site is pointing to Apache's default "document root" directory. This is the directory on your computer that currently contains the default "You installed Apache correctly" page that you hopefully were able to load above (assuming that [localhost...] worked).
So, assuming you are on Windows XP, and you just did an "average" Apache install, the path to your "document root" folder is probably something like: "C:\Apache-Group\Apache\httpdocs" ...or something vaguely similar. Anyway, regardless, that folder named "httpdocs" is where you want to save and develop the the website files you will open and work on in Dreamweaver. So in Dreamweaver, just configure your Dreamweaver "Site" to use that "httpdocs" folder (the entire path to it) as the directory to store you "Local Files".
The advantage to setting it up this way when you have Apache installed on your local machine is that you don't need to use Dreamweaver's "preview" feature at all (although you still can, especially if you are using some of Dreamweaver's more "fancy" features/behaviors). Instead of using the preview feature, you can just keep your web browser open to the page you are working on (such as [localhost...] if you were working on a file named "index.html" in the root of your site). You can just "save" the file in Dreamweaver and then switch over to your browser and refresh the same page in the browser. Voila! This can save a bit of time (a second or two) because it's usually faster than Dreamweaver's "Preview" command is...because the "Preview" command creates a temp file (named something crazy like "TMP16yihsn5qg.htm") that then loads in the browser, instead of loading the actual file you are working on in the browser. The small advantage to using the "preview" is that you don't have to "save" the file to do a preview, but that usually (for me anyway) doesn't matter as you can always "undo" even after saving. Hope that helps.
Well, technically, you can put the "web root" folders of your websites wherever you want on your hard drive. What I think you will need to do is create "virtual hosts" so that you can actually use Apache to host multiple websites on the same machine (which is your computer). This involves editing Apache's httpd.conf file and also editing your Windows "hosts" file. If you don't know what that is yet, don't worry.
Overall, this whole process is a little complicated, but it is really very easy to do each step. I will explain how I have setup my multiple, local, development websites.
STEP 1
First, you need to create a separate directory for each website you want to have a "local" version of. These folders can technically be anywhere on your hard drive. But What I did (and recommend) is create a directory on my C: drive named "www". Then, within that directory I created a separate directory for each website that I develop. So, let's say I develop a site with the URL of www.example.com. For that website, I created a directory named "www.example.com" inside the "www" directory on my C: drive. So the complete path to this first "web root" directory, for one of the websites is:
C:\www\www.example.com\
Then, create more directories of this nature inside the main "www" directory. When you are finished creating all the directories, you will have a separate directory for each website. Such as:
C:\www\www.example.com\
C:\www\www.example2.com\
C:\www\www.otherexample.com\
I want to point out that the only reason I named the directories the exact same name as the URLs of the websites was for convenience in remembering it. You can name these directories anything you want that makes sense to you. This is just a convention that I use and that makes sense to me. It has worked pretty well for me over the past couple of years, so I do recommend it.
So, anyway, it's hopefully obvious that you will configure your various Dreamweaver "sites" to point to these directories (respectively). Go ahead and do that now. And create a test page named "index.html" in the first one. Put some unique text on this page such as: "Here is the homepage I made for www.example.com." and then save the page.
STEP 2
OK, next, find the directory named "conf" in your main Apache installation directory. Inside the "conf" directory, locate the "httpd.conf" file that jdMorgan mentioned above. Open this file in Windows Notepad. This is a large and intimidating file when you are new to Apache, but don't worry. One "good to know" point about this file is that any line that begins with a pound sign (#) is commented out and essentially does nothing functional.
Find the section of code in the "httpd.conf" file that looks something like (or exactly like) this:
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
Note that all of these lines are commented out and aren't really doing anything but providing one example of one way to create what Apache refers to as "Virtual Hosts". To create a new VisrtualHost you do not need to enter all of the lines that are shown in the example. This probably doesn't quite make sense yet, but that is OK...keep rolling.
Creating "VirtualHosts" allows multiple websites to run under one installation of Apache. And it's probably where the term "Virtual Server" that so many web hosts use originally came from.
Place your cursor directly below that section of code and enter the following to define your first Virtual Host website:
# Virtual host definition for nara extranet
<VirtualHost *>
DocumentRoot "C:/www/www.example.com/"
ServerName local.example.com
</VirtualHost>
Obviously, change the "www.example.com" to whatever the domain name actually is in your case. Save the file. You have now defined your first "virtual host" website. But it's not quite ready to roll yet. Before this website will actually "work" on your computer, you need to do perform a couple more steps.
STEP 3
You now need to restart Apache so that it recognizes the fact that you edited the "httpd.conf" file. You will need to restart Apache every time you make a change to the httpd.conf file. To restart Apache, open a command prompt (AKA DOS Prompt) and enter the following command:
apache -k restart
Assuming Apache is already running, you will get a confirmation that Apache has started up again. If you have get any error messages, that probably means that either (1)Apache was not already running, or (2)There is a typo in your httpd.conf file. Check your syntax. As a side note, on some Windows machines I have found that for whatever reason, the "restart" command doesn't work properly. In these cases I have needed to first "stop" Apache and then "start" Apache in two explicit commands. To do this, I enter the following in the command prompt:
apache -k stop
...wait for confirmation, and then type:
apache -k start
...wait for confirmation that Apache has started again.
STEP 4
OK, assuming that Apache restarted OK, now you have to add some domain names to your Windows "hosts" file. Your "hosts" file is a file named "hosts" (with no file extension) that is buried deep inside your Windows system directory. To open this file, find it at:
C:\WINDOWS\system32\drivers\etc\hosts (the "hosts" at the end is the actual filename)
When you double click on the "hosts" file to open it, you may need to wait a moment for Windows to display a dialog box that asks you what program you want open this "unknown file type" with. Choose to open the file in Notepad.
When you open the file, you will see that it has a bunch of comments at the top (read them) and then a single entry that is not commented out (with a # sign) that looks like this:
127.0.0.1 localhost
Look a little familiar? Well in "IP-speak" the IP address 127.0.0.1 is always the IP address of the local machine. No matter what your computer's IP address is on your network, or with your ISP or whatever, this IP address (127.0.0.1) will always resolve to your local machine. And this particular line of code is actually what has allowed the default Apache web page to load whenever you enter "localhost" in your web browser. This file overrides and DNS lookup that your machine normally does and "forces" domain names to resolve to whatever IP address you specify in this file. So, as you can see, the domain named "localhost" is tied to your local computer with the 127.0.0.1 IP address. Now you just need to create entries for each of the "virtual host" websites that you defined in your Apache httpd.conf file. So, if you had:
# Virtual host definition for nara extranet
<VirtualHost *>
DocumentRoot "C:/www/www.example.com/"
ServerName local.example.com
</VirtualHost>
in your httpd.conf file, you would add the following line to your "hosts" file:
127.0.0.1 local.example.com
So, you see how the name you enter in the "hosts" file needs to correspond exactly with the value set for the "ServerName" line in the VirtualHost definition in the httpd.conf file.
So, assuming you created a test web page named "index.html" in the "C:/www/www.example.com/" directory you can now enter the following URL in your web browser and it will load your test web page.
http://local.example.com
You should see the test web page you created in your web browser. So now you are up and running!
So now just "rinse and repeat" for each separate, "local" website you want to create. To recap to process:
1. Create a directory to store the files for the "local" website.
2. Add a VirtualHost definition into the httpd.conf file.
3. Restart Apache
4. Add the entry for the "local" ServerName to the "hosts" file.
...works for me!
Good Luck!