I’ve been reading about having problems with this and have had problems with testing if I’ve installed Apache correctly out of Kevin Yanks book.
When typing in “http://localhost/” in the web browser, some people and myself, have not seen the “It Works” page. Instead, people have encountered “Unable to Connect” page on Firefox or “Internet Explorer cannot display the webpage” on IE.
I’m assuming people are taking the “http://localhost/” to literally. To make things easy, find the “Configure Apache Server” and click on the file “Edit the Apache httpd.conf Configuration File”. Scroll down about 1/3 of the page down and find “#ServerName” and copy the name after it and then past it after the “http://” in the browser address line and then press “Enter”. You should then see the “It Works” web page.
Example: http:///
and to run the first php test page
Type: http:///today.php
Please direct me to the proper way of configuring Apache, as I don’t want to encounter an issues down the line. Following the instructions in the textbook didn’t pan out well for me and the direction I took actually brought me to the “It Works” page.
When I previously installed Apache once, I didn’t even have the green arrow on the Apache icon in the systems tray. So when I reinstalled it, I finally got it working.
Now, I take exception to your proposed solution as what you’re doing is changing the name of the localhost server. If you want/need to have VirtualHosts on your test (or production) server, then use the correct tool for that: httpd-vhosts.conf. That’s what it’s there for!
IF people don’t see the It Works page, it’s generally because they don’t understand that the localhost is looking at Apache’s specified DocumentRoot: its htdocs folder. If that is changed, then there WILL be a problem.
IMHO, the proper way is for you to leave the default settings alone and use http://localhost for your “generic” pages. When it’s time to setup a VirtualHost, add:
# in the WinDoze version of Apache 2.x httpd-vhosts.conf file
<VirtualHost 127.0.0.1:80>
ServerName dk
DocumentRoot W:/datakoncepts.com
ServerPath W:/datakoncepts.com
</VirtualHost>
Of course, use your own alias for the ServerName and set the DocumentRoot and ServerPath to the local directory you prefer.
Then:
# in the WinDoze/system32/drivers/etc folder's hosts file
# (yes, it's extensionless)
127.0.0.1 dk
Where dk matches the ServerName from the httpd-vhosts.conf file.
That’s all there is to it (except to restart Apache) to access the files in the W:\datakoncepts directory as http://dk/.
Yes, it’s as simple as that! Of course, I’ve also created the phpmyadmin virtual host, too, as that GUI tool is indispensable for managing MySQL databases (and I can install that anywhere on my system).