I found myself forced to use classic ASP. Of course, I would never use Windows willingly so I started looking for ways to run ASP on Linux. It turned out there aren’t any.
Mono runs only .NET applications. And as ASP is so damn old, even the two commercial alternatives that have obviously existed: chili!ASP and Instant ASP, that could eventually run on Linux are just not available anymore anywhere.
So, the obvious alternative was to use a virtual machine running Windows. I already had setup a Windows XP virtual machine with VirtualBox.
I’ll try to present what I actually did to use ASP.
Prerequisites
Results
- I am accessing the virtual machine from the host machine just like they were in a local network.
- I have IIS running on port 8077 so I open a browser and go to http://{local-guest-ip}:8077/test.asp and am able to run the test.asp script which I put in the Home directory of IIS.
- I have a samba share of the IIS Home directory mounted in a localdir, let’s say /home/foo/asp-root/ and I can edit files with vim right in there, then refresh the page and see the results. I just keep the virtual machine on a different desktop, so I don’t even have to look at the damn thing.
Failed attempts
I tried to do this with forwarding a port on the host machine, for example 8088, to the guest machine port 8077 where IIS listens, and then sharing a directory from the host to the guest through VirtualBox shared folders. Then I tried to make this shared directory the Home dir for IIS by selecting “A shared directory located on another computer” in
Control Panel -> Administrative Tools -> IIS -> … -> Default Web Site (right click)-> Properties.
That didn’t work. The Windows XP guest sees the share just fine, has read and write access and stuff, but… IIS won’t work. It dumped some permission errors. I tried making the same user/pass pair on both the host and guest and using that in the IIS “connect to:” setting for the shared directory, or in the Directory Security tab. Whatever I did either other errors appeared or the mighty error message:
Incorrect function.
appeared in the browser (Opera); Internet Explorer, though, just showed Internal Server Error.
Success story
So it obviously needs to be done the other way around — share from the guest and access from the host.
Here’s how I did it (I hope I don’t miss something).
Bridging a host network interface with the guest
I used these instructions in ArchWiki. They are pretty straight-forward, but if you can’t apply them, you need to know what to look for and that is,
You need to make a bridge (for example, br0) from an interface of your choice (for example, eth0) to vbox0, which I guess is a VirtualBox interface.
Then you need to attach a “Bridged Adapter” in the network settings of the virtual machine and choose “br0″.
After finishing the instructions you should have something similar to:
$ ifconfig br0
br0 Link encap:Ethernet HWaddr 00:23:3C:CD:31:44
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::221:9bff:fecf:86e0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:3151 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:1150259 (1.0 Mb)
You should watch out if you have other network interfaces not to clash with them! Every interface should be on a different subnet – that is the first 3 numbers of the IP address should not be the same for any two interfaces on the same machine.
Then, in the guest Windows machine you should set up a static IP in the same subnetwork like your br0 (for example 192.168.0.3). You should get a response from
$ ping 192.168.0.3
on the host machine and
ping 192.168.0.2
on the guest machine (Start->Run..->cmd).
Also, openning http://192.168.0.3:8077/test.asp (or whatever other test file you’ve got) on the host machine should work. If not, you should
open TCP port 8077
on the Windows XP firewall.
Google it if you don’t know how – it’s easy.
Setting new Home dir on IIS and sharing it
In the guest machine, go to
Control Panel -> Administrative Tools -> IIS -> … -> Default Web Site (right click)-> Properties -> Home Directory.
There, choose a directory which will be the root of the default site.
After that, I won’t explain in detail — use google if you don’t know how to do it, you should
Create a user in Windows, or use an exisitng one; disable simple file sharing; share the folder you chose for a home directory; Give full access to the user and restrict Everyone.
Now, on the Linux host machine, open /etc/fstab as root and add something like this:
//192.168.0.3/{share-name} /where/i/want/my/asp/files/ cifs umask=000,rw,exec,noauto,noatime,username={win-user},password={win-pass},gid=users,uid=foobar 0 0
where:
- {share-name} is the name of the share you did on the guest machine (by default, same as the dir name).
- {win-user} is the name of the user you gave Full access for the share and {win-pass} hiss password.
- You should edit the mountpoint (/where…), gid (your linux user’s group — users will probably do) and uid (your username)!
Now type
mount //192.168.0.3/{share-name}
and go to /where/i/want/my/asp/files. You should be able to edit them.