Archive for the ‘ Developer ’ Category

How to Turn your Desktop PC or Laptop into a Test Web Server

Tuesday, April 6th, 2010

If you do any kind of web programming, it can become tedious to continuously upload and test your code on a remote server. One solution is to set-up a test server on your laptop or desktop computer, thus skipping the uploading part. Here’s how you can do it on either a Windows or Linux platform…

Photo by Whrelf Siemens

First thing you want to do is create fake hostnames that resolve to the localhost address, 127.0.0.1. You can create totally fictitious  hostnames or override real ones. On a Linux machine, edit the file /etc/hosts, while on Windows, it’s located at C:\Windows\System32\drivers\etc\hosts – make sure it’s writable/modifiable by users. For each hostname you need, add a line similar to the following to the hosts file:

127.0.0.1   www.fakedomain.com

Next, install the latest version of the Apache  web server (yes, on Windows too). Note that if you have Skype installed on a Windows computer, you’ll have to disable it by opening the task manager and killing all the Skype processes running. You’ll have to do that every time you boot your computer unless you uninstall Skype, as it intentionally listens on port 80. You could alternatively modify the Apache config (httpd.conf) and make it Listen to a different port, but this will force you to use ugly urls with the port number in your tests. Find and edit the file conf/httpd.conf in the Apache install directory, changing the Listen instruction to:

Listen 127.0.0.1:80

This will insure against Apache being open to the outside world. If you’re using a different port than 80, than the line above should be changed to the correct port. If you want to use several fake hostnames in your test web server add this line to httpd.conf:

NameVirtualHost 127.0.0.1

And create a virtual host. For example:

<Directory C:\htdocs>
Options All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html
</Directory>
<VirtualHost 127.0.0.1>
ServerName www.dingdong.com
DocumentRoot C:\htdocs
</VirtualHost>

Next, install the latest version of php, or re-launch its installer if you already have it (choose “change” in the first screen), and make sure you select “Apache  2.*  module” in the Web Server Set-up screen. If you’re working with a Linux computer, follow the same installation instructions from the php web site, exactly as if you were setting-up on a real server.

If you did everything right, you now have the perfect testing environment!

Related Articles:

  • None

The Perfect Set of Free Development Tools

Monday, April 5th, 2010

It’s possible to have a set of sophisticated web software development tools for your desktop, completely free, both for the Linux platform as well as Windows. I’ve used them for a long time now, and although I’ve been coding primarily in php, these tools will work just as well with other languages…

Komodo Edit: This is an exceptionally good IDE since it debugs automatically while you add or modify your code. It supports a wide variety of programming languages, including php, perl and C++. You can get it from the Activestate website. Note that in some cases, such as with php, you need to also have the actual language’s interpreter installed.

Putty (Windows only): A very nice ssh client. The Linux version isn’t nearly as good, but using your shell directly with openssh is more than fine. Get it here.

Filezilla: A very handy sftp client. Get it here.

Gimp: If you need to edit or create images, nothing compares to this very complete graphics editor. Get it here.

That said, any serious code slinger who creates web interfaces should test the output on all popular browsers: MSIE,Firefox,Chrome,Safari and Opera. Ideally, you’ll also have older versions of each installed, as page rendering can vary quite a bit from one release to the next.

An even more advanced development environment can be had by setting-up a web server to run directly on your PC, but that’s a topic on its own…

Related Articles:

  • None