Overview
It is always best to avoid doing development work on a production server. if you get a forever loop in there, you might get your account in trouble. here's how to install a development server.
I have had trouble with getting bitnami servers to work out of the box (WAMPP) - seems to just break, so I stick with XAMPP.
basic lockdown
1st step: your hosts file
Your c:\windows\system32\drivers\etc\hosts file needs at least these 2 adresses in it for IPV6 Support, like below. If you are on windows 2000 (NT4 does not have IPV6 support), it's c:\winnt\system32\drivers\etc\hosts
the hosts file can be edited with notepad, but I prefer Notepad++ (programmer's editor) since it does not try to forcefully turn it into a .txt file like Notepad does.
#Example hosts file #anything with a # in front is a comment and is ignored, # and blank lines are ignored 127.0.0.1 localhost ::1 localhost
I generally comment out the ::1 localhost because it causes problems.
security you need to know about default httpd.conf
for a development/testing server, you should edit c:\xampp\apache\conf\httpd.conf with dreamweaver or notepad++ and set Listen 127.0.0.1:80 or Listen [::1]:80 or both. this is localhost.
Otherwise, you will be broadcasting everywhere on every network card you've got and leaving ports open where you don't want them open - on the internet side.
this is taken care of if you use my config.zip's files.
virtual hosts/virtual servers
apache article on name-based vhosts.
also note that you should make changes to DNS to do this. for our development/testing server, we are simply going to make changes to our c:\windows\system32\drivers\etc\hosts file.
If you are on windows 2000 or NT4 (NT4 does not have IPV6 support), it's c:\winnt\system32\drivers\etc\hosts
PLEASE NOTE: using name-based virtual hosts means you can't use .com or .org or .net etc. domain names in your test server domain name, because this will block out YOUR access to the real production one on the internet.
use single-word-based names or names with dashes in them. (I think you can use names with dashes in them). the following names would be good examples:
joes-diner-com joes_diner flakypetesrestaurant gonow-com vanc
your httpd.conf file would have this appended to it:
NameVirtualHost 127.0.0.1:80
LoadModule authn_alias_module modules/mod_authn_alias.so
#-----probably don't need this, but I included it anyway just to be sure.
LoadModule vhost_alias_module modules/mod_vhost_alias.so
<VirtualHost 127.0.0.1:80>
#-----this is a test domain named simply, http://test
#-----its directory is c:\www\somewebsite\
#-----use this like your test for your web site.
#-----hopefully there are no http://somewebsite.com
#-----type of absolute outside url's in your site.
ServerName test
DocumentRoot /www/somewebsite
<Directory /www/somewebsite/>
allow from all
</Directory>
#ServerAlias www.joesdiner.com
ServerAdmin nobody@nowhere.com
ErrorLog logs/t-error.log
CustomLog logs/t-access.log common
</VirtualHost>
<VirtualHost 127.0.0.1:80>
#-----http://junk and http://j
#-----(but these are local)
#-----use this for unit-testing little things out
#-----which you might not put on your web site.
ServerName junk
DocumentRoot /junk
<Directory /junk/>
allow from all
</Directory>
ServerAlias j
ServerAdmin nobody@nowhere.com
ErrorLog logs/junk-error.log
CustomLog logs/junk.log common
</VirtualHost>
<VirtualHost 127.0.0.1:80>
#-----http://gonow.com and http://www.gonow.com
#-----(but these are local)
ServerName gonow.com
DocumentRoot /xampp/htdocs/gonow-com
<Directory /xampp/htdocs/gonow-com/>
allow from all
</Directory>
ServerAlias www.gonow.com
#-----you need entries in your hosts file for both
#-----gonow.com and www.gonow.com for testing/development
ServerAdmin nobody@nowhere.com
ErrorLog logs/gonow-com-error.log
CustomLog logs/gonow-com-access.log common
</VirtualHost>
<VirtualHost 127.0.0.1:80>
#-----http://vanc (but this is local)
ServerName vanc
DocumentRoot /xampp/htdocs/vanc
<Directory /xampp/htdocs/vanc/>
allow from all
</Directory>
#ServerAlias vancouverlocknkey.com
ServerAdmin nobody@nowhere.com
ErrorLog logs/vanc-error.log
CustomLog logs/vanc-access.log common
</VirtualHost>
<VirtualHost 127.0.0.1:80>
#-----http://flakypetesrestaurant.com and http://www.flakypetesrestaurant.com
#-----(but these are local)
ServerName flakypetesrestaurant.com
DocumentRoot /xampp/htdocs/flakypetesrestaurant-com
<Directory /xampp/htdocs/flakypetesrestaurant/>
allow from all
</Directory>
ServerAlias www.flakypetesrestaurant.com
ServerAdmin nobody@nowhere.com
ErrorLog logs/flakypetesrestaurant-com-error.log
CustomLog logs/flakypetesrestaurant-com-access.log common
</VirtualHost>
<VirtualHost 127.0.0.1:80>
#-----http://joesdiner.com and http://www.joesdiner.com
#-----(but these are local)
ServerName joesdiner.com
DocumentRoot /xampp/htdocs/joes-diner-com
<Directory /xampp/htdocs/joes-diner-com/>
allow from all
</Directory>
ServerAlias www.joesdiner.com
ServerAdmin nobody@nowhere.com
ErrorLog logs/joes-diner-com-error.log
CustomLog logs/joes-diner-com-access.log common
</VirtualHost>
The way things work is, your local computer will look up the domain name first in the c:\windows\system32\drivers\etc\hosts file, if it doesn't find it there it looks it up in c:\windows\system32\drivers\etc\lmhosts, if it doesn't find it there, it looks it up on the internet, and if it doesn't find it there, then the browser gives an error.
XHTML support
by default, XHTML will be served up as HTML. what you will get is "tag soup" and improper rendering. you must modify httpd.conf according to this article:
comment out a certain set of mod rewrite rules:
#RewriteEngine on
#RewriteCond %{HTTP_USER_AGENT} ((.*MSIE.*)|(Lynx.*))
#RewriteCond %{REQUEST_URI} \.xhtml$
#RewriteRule .* - [T=text/html]
add this:
#handle XHTML properly
AddType application/xhtml+xml;q=0.8 .xhtml
DirectoryIndex index.xhtml index.html
<IfModule mod_rewrite.c>
RewriteEngine on
# Uncomment RewriteBase line if adding inside per-directory
# configuration files (e.g., .htaccess):
# RewriteBase /
RewriteCond %{REQUEST_URI} \.xhtml$
RewriteCond %{HTTP_USER_AGENT} MSIE [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml\s*;\s*q=0\.?0*(\s|,|$)
RewriteRule .* - [T=text/html]
</IfModule>
this stuff is in the httpd.conf in the config.zip above.
gotchas
know that this virtual hosts configuration ONLY works on YOUR machine due to lack of DNS support. anything more than this configuration requires a DNS server at least, and that that DNS server be interfaced to the internet's DNS servers.
some technical support folk will want to reset your hosts file, so keep a backup somewhere where you can find it!
how about in your \xampp\ directory?
instructions for xp and below machines
there should be NO issues with running xampp.
- [windows-logo-flag-key]-E to bring up Windows Explorer, or start, my computer.
- change the options for viewing folders so that you can view file extensions for known file types and view hidden folders. be careful when using this feature! know what you are doing. file extensions have certain uses to different programs. .exe's are executables, and .html is a web document that's essentially a renamed .txt file, but the text is in a certain format.
- download xampp (seeresources)
- download my config.zip
- download notepad++ and run notepad++ installer as administrator to install it.
- download winmerge and run as administrator to install it. turn on plugins.
- download 7-zip and run as administrator to install it. choose to integrate into Windows Explorer. this step is optional, since windows has a limited (and in the past, broken) built-in zip and unzip utility into Windows Explorer.
- browse in my computer to your downloads where your xampp setup file is, and right-click on the file and run as administrator to install it (this is not possible in XP or 2000).
- install xampp into its default location,
c:\xampp\ - install apache (web server) and mysql (database) at the very least. filezilla is purely optional (ftp server).
- make sure you install a xampp desktop icon, it could be handy from time to time
- after finished and xampp control panel is up, stop the services.
- rename the old
httpd.conftohttpd.conf.original - right click on config.zip and extract into
c:\xampp\apache\conf\ - use notepad++ to edit the virtual hosts in
c:\xampp\apache\conf\httpd.confand hosts.add to suit your liking.hosts.add's virtual TLD domain names MUST match yourServerNameandServerAliasinhttpd.conf - create the directory structure you outlined in httpd.conf in the virtual hosts.
- run winmerge, click on the open folder button, browse the two files to
httpd.conf.originalandhttpd.conf - turn on the setting in winmerge in edit, options, editor: automatic rescan, character level, break at whitespace, preserve original EOL chars, tab size 4
- merge the changes to how you like. it works as an editor also. it does not save on exit, so be sure to save with ctrl-s if you want your changes!
- start the services in the xampp control panel.
- if a service doesn't start, check the application log in event viewer. to get to event viewer fast, [windows-logo-flag-key]-R eventvwr[Enter]
- run notepad++ and open your
c:\xampp\apache\conf\httpd.confand make any required change and save with ctrl-s. leave it running until the debugging process is over and apache starts completely and you get a green light from the xamppcontrolpanel or it shows "started" from the service control manager. - attempt to start the apache service. if it works, you are done! skip the remaining steps.
- if you do not get a green light for Apache, or service contrl manager does not show "started", alt-tab back to event viewer, refresh the application log, and look at the latest Apache error to see what chanbges you need to make. note the line number of any syntax error.
- alt-tab back to notepad++ and do ctrl-g and type in the line number and hit [Enter] this will take you to that line number.
- repeat previous 3 steps as necessary.
instructions for vista/7/8 and up machines
in windows vista/7/8 and above, because the c:\windows\system32\drivers\etc\hosts file is under the c:\windows\ directory, it is a protected file just like c:\program files\. this means in order to change the hosts file, you umust run Notepad++ as Administrator. Also, because of the manifest that is in the executables of xampp may be causing it not to start unless you run it as Administrator.
- [windows-logo-flag-key]-E to bring up Windows Explorer, or start, my computer.
- change the options for viewing folders so that you can view file extensions for known file types and view hidden folders. be careful when using this feature! know what you are doing. file extensions have certain uses to different programs. .exe's are executables, and .html is a web document that's essentially a renamed .txt file, but the text is in a certain format.
- download xampp (seeresources)
- download my config.zip
- download notepad++ and run notepad++ installer as administrator to install it.
- download winmerge and run as administrator to install it. turn on plugins.
- download 7-zip and run as administrator to install it. choose to integrate into Windows Explorer. this step is optional, since windows has a limited (and in the past, broken) built-in zip and unzip utility into Windows Explorer.
- browse in my computer to your downloads where your xampp setup file is, and right-click on the file and run as administrator to install it (this is not possible in XP or 2000).
- install xampp into its default location,
c:\xampp\ - install apache (web server) and mysql (database) at the very least. filezilla is purely optional (ftp server).
- make sure you install a xampp desktop icon! you will need this!
- after finished and xampp control panel is up, stop the services.
- rename the old
httpd.conftohttpd.conf.original - right click on config.zip and extract into
c:\xampp\apache\conf\ - click on SCM button of xampp control panel to bring up services. or type [windows-logo-flag-key]-R services.msc[Enter]
- right click on Apache service, properties, and set to login as system (doesn't seem to like anything else, I was told
.\yourUserNameif you have admin rights). - run notepad++ as Administrator to edit the virtual hosts in
c:\xampp\apache\conf\httpd.confand hosts.add to suit your liking.hosts.add's virtual TLD domain names MUST match yourServerNameandServerAliasinhttpd.conf - create the directory structure you outlined in httpd.conf in the virtual hosts.
- run winmerge, click on the open folder button, browse the two files to
httpd.conf.originalandhttpd.conf - turn on the setting in winmerge in edit, options, editor: automatic rescan, character level, break at whitespace, preserve original EOL chars, tab size 4
- merge the changes from
httpd.conf.originalto how you like intohttpd.confby right clicking on lines and copying them to right or left, whichever is appropriate. if you need to. it works as an editor also. it does not save on exit, so be sure to save with ctrl-s if you want your changes! - right-click on the desktop's xampp shortcut icon, properties, set it to run as administrator. this is critical. you will need this every time you start xampp. at least until they fix xampp.
- start the services in the xampp control panel.
- if a service doesn't start, check the application log in event viewer. to get to event viewer fast, [windows-logo-flag-key]-R eventvwr[Enter]
- run notepad++ and open your
c:\xampp\apache\conf\httpd.confand make any required change and save with ctrl-s. leave it running until the debugging process is over and apache starts completely and you get a green light from the xamppcontrolpanel or it shows "started" from the service control manager. - attempt to start the apache service. if it works, you are done! skip the remaining steps.
- if you do not get a green light for Apache, or service control manager does not show "started", alt-tab back to event viewer, refresh the application log, and look at the latest Apache error to see what chanbges you need to make. note the line number of any syntax error.
- alt-tab back to notepad++ and do ctrl-g and type in the line number and hit [Enter] this will take you to that line number.
- repeat previous 3 steps as necessary.
(these steps are not for XP) When you reboot in vista/7/8 and up, xampp control panel will no longer be logged in as administrator. the xampp control panel applet in the notification area that starts up with windows will be useless. so:
- [Ctrl]-[Alt]-[Delete] and choose task manager. or, [windows-logo-flag-key]-R taskmgr[Enter]
- do an end-task on xampp control panel.
Downloads
config.zip contains httpd.conf which contains the changes you need below which replaces XAMPP's c:\xampp\apache\conf\httpd.conf and hosts.add which you append to c:\windows\system32\drivers\etc\hosts.
software
\xampp\apache\conf\httpd.conf is set to listen on ALL interfaces, which is NOT secure, and they tell you this up front. for a development server, you should set Listen 127.0.0.1:80 or Listen [::1]:80 or both. this is localhost, and you should have those 2 IP addresses in your hosts file as I show you above for future IPV6 support.