Thursday, December 14, 2006

Adobe Flash Finally Free

Sick of finicky Macromedia Flash compatability for your Linux distribution? I know I've spent a significant amount of time installing the third-party, open-source plugins to Firefox in order to get Flash support in my browser. But now, that doesn't seem necessary anymore. Adobe released the Flash Player Scripting Engine last month, and in conjunction with the Mozilla Tamarin project, should result in an open-source, official Flash plug-in for Firefox.

Also, Acrobat Reader 8 is now available.

Wednesday, December 06, 2006

Home Linux Server Part 2: Web Server setup

This is the second installment of my series of posts on setting up a Linux-based server on your home network. In Part 1, we set up Debian 3.1 on an old system to run as the server, set up the telnet daemon, and installed a basic GUI but prevented it from running on boot.

Now in Part 2, we will configure our box as a Web server open to the public (if you want) using Apache. I am assuming your system is configured as per Part 1. Thus, you have a static internal IP address assigned to your server, and a unique hostname. Also, these instructions will allow you to create a publicly accessible web server even if you have a dynamic public IP address assigned to you by your ISP. For example, on my network, my server has hostname present-server and internal IP address 192.168.2.99. However, my public IP address is dynamically assigned by my ISP, Verizon DSL, and changes unpredictably. Using these instructions, however, my web server is always available from outside my network via http://present-server.dyndns.org:8080.
  1. Log into your server as root, or use telnet to log in as a regular user and run su to enable root access.
  2. Install Apache with the command apt-get install apache. When prompted, do not enable suExec.
  3. Apache defaults to the main server directory being /var/www. In this directory should always be a file called index.html. When installed, Apache creates a default dummy index.html. To see this file, point your web browser to the internal IP address of your server. This causes the browser to connect to your server on the default HTTP port, port 80. Apache intercepts this, and directs the visitor to the index.html file found in /var/www. However, this is the highest directory the visitor can access.
  4. You probably want to keep the default index.html file around, but obviously do not want it to be the page your visitor sees when he navigates to your site. Thus, rename the file with mv /var/www/index.html /var/www/index.html.old. Now, you can use the /var/www directory to hold all of the files needed for your website. Be sure to create a new index.html file as the entrance page for your site.

Now your web server is fully functional if you want it to remain accessible only to those within your home network (i.e., to the intranet). Continue if you want to open it up to the internet.
  1. You need to tell your router to pass any HTTP requests from outside your network on to your server for Apache to handle. Thus, you need to forward port 80 in your router's Port Forwarding Settings to the IP and MAC address of your server. You can find the MAC address of your server with the command ifconfig. You may need to be logged in as root to run this command. The MAC address (also known as a hardware address, and is a unique number identifying your Network Interface Card to other computers) is shown next to HWaddr in the eth0 entry. Port forwarding differs from router to router. Consult your router documentation for this process.
  2. Now we need to find a Domain Name Server (DNS) to put our site in its zone. DynDNS.com provides a free service that places dynamic public IP addresses in its zone, provided you use a sub-domain of theirs (that is why my site's address is http://present-server.dyndns.org:8080). To set this up,
    1. Create a free account on DynDNS.com.
    2. Click "Dynamic DNS" under "Services," and then click "Create Host."
    3. Set the hostname to the same thing as the hostname on your server, and select an upper-level domain of your choice. Go to WhatIsMyIP.com, and put your public IP address in as the IP address in DynDNS. Click "Add Host" to complete the registration.
    4. You will not be able to test this domain if your router, like many, does not support loopback connections. Therefore, ensure there is a valid domain registration by asking a friend to point their browser to the domain you configured. They should see the index.html page you have put up if your ports are forwarded properly and the domain is set up correctly.

  3. Dynamic IP addresses, by definition, change sometimes. Thus, we need a way for our entry at DynDNS.com to update with the new IP. We will use the ddclient service for Linux to manage the updating automatically.
    1. Install ddclient with apt-get install ddclient.
    2. Select dyndns from the list of services.
    3. Enter in the domain your registered at DynDNS as the "fully qualified domain name."
    4. Enter the username and password you use to log in at DynDns.com.
    5. Enter the interface your webserver is using as an NIC. This is most likely eth0.
    6. Select No when asked if you want ddclient to run whenever a ppp connection is created.
    7. Enter 30d for a 30-day update cycle when prompted.
    8. Choose to run ddclient as a daemon so you do not have to start the service every time you reboot the server.
    9. Edit the configuration file /etc/ddclient.conf to enable access from behind a Cable/DSL router.
      • Run nano /etc/ddclient.conf as root to edit the file.
      • Replace the line use=if, if=ppp0 with the line use=web, web=checkip.dyndns.org, web-skip='Current IP Address: '
      • Press Ctrl-X, Y, Enter to save the configuration file and quit nano. Run ddclient to update the IP and make sure the daemon is working. This will run automatically every 30 days, but if you know your IP address has changed, run it manually to make the changes immediately effective.

Note: Some ISPs, including Verizon DSL, block listening on HTTP port 80 to try to discourage servers running with the less-expensive dynamic IP addresses, and get you to buy a static IP. If this is the case, you need to change the operating port to something besides 80. Edit the /etc/apache/httpd.conf file, replacing the port on the port 80 line with a different number. I recommend using port 8080. Then, change which port is forwarded by your router as well. When pointing web browsers to your site, you are no longer using the default port, so you need to tell which port to connect on. That is why my site is referred to with http://present-server.dyndns.org:8080.

Great. Apache web server should be up and running, and your DNS should be automatically updated and accessible from the internet. Have a friend check your site from the outside using the domain you registered with DynDNS, specifying the port you chose. If you need to view your site internally, you need to direct your browser to the internal static IP address on the specified port unless your router supports loopback addresing.

Sunday, December 03, 2006

Home Linux Server Part 1: Debian setup

I've decided to write a series of of posts on setting up a Linux-based server on your home network using Debian 3.1 ("Sarge"). Tonight is the first posting, detailing how to set up the base Debian system to later configure as a server. We'll set up only the critical installation files, the root account, one other account, and telnet and x-server.

I'm setting up my server on an old Dell Inspiron 3000 laptop. As you can tell, it is a terrible system. The only component I have added is a 100Mbit Ethernet card. Thus, pretty much any fairly recent machine you can find will work for what we want to do. I'm going to assume this machine also has a CD drive, and that it will be a dedicated server, in that you will not be dual-booting the system.
Debian server system

  1. Download and burn to CD the Debian 3.1 NetInstall disc image from here.
  2. Insert the NetInstall CD into the drive of the computer you'll be using as a server, and reboot the computer. Note: You will lose all data on the hard drive following these instructions. Be sure to back up anything you need.
  3. Start the installer with the linux netcfg/disable_dhcp=true debian-installer/framebuffer=false command, indicating we do not want to configure DHCP at this time, and we want the text-based setup (because it's easier, actually)
  4. Select your language, region, and keyboard layout
  5. Set up your network settings:
    • Choose an unused IP on your network. Check its availability using your router's status tools, or by using a different computer on the network to try pinging the desired IP. You will probably want to use 192.168.xxx.xxx. Make sure, though, that the first two octets match those used on the rest of your network.
    • Enter your subnet mask. If your first two octets are 192.168, the mask is 255.255.255.0
    • Enter your gateway address. Normally, this is the IP for your router.
    • For a DNS or name server, enter in either your ISP's nameserver, or, if your router does name serving, re-enter your gateway address.
    • Create a unique hostname for the sever. I used present-server.
    • Enter a domain name of your choice. I used present.net.

  6. Partition your hard drive:
    • Create a 256MB swap partition.
    • Create a 700MB root partition.
    • Create a final /home partition with the remaining space.

  7. Allow the installer to run for a while. When prompted, install GRUB to the Master Boot Record.
  8. Remove the CD from the disc drive and enter Continue to reboot from the hard-drive. Configure your timezones, root account, and user account. Do not use PPP to install the system if prompted. Choose to obtain your repositories from http, and select a local mirror.
  9. Do not install anything at the software selection screen. When prompted, do not configure Exim.
  10. Use the default root username.
  11. Press Enter at the "Thank You" screen, and note you are at a login prompt.
  12. Login as root using the password you provided.
  13. Allow telnetting to the server by installing the telnet daemon with apt-get install telnetd
  14. Install a minimal GUI with apt-get install x-window-system:
    • Choose "autodetect hardware"
    • Use "xfree86" for the keyboard rule.
    • Maintain maximum compatibility unless you know what to use, and choose "pc101" for the keyboard model.
    • Select your layout language
    • Select /dev/psaux for PS/2 mice, and PS/2 from the list of mouse models.
    • Answer the prompt about the LCD screen, and configure the monitor settings in the next few screens.
    • Use a 16-bit color depth.
    • Use a printer resolution of 300dpi.
    • Prevent x-server from starting during boot by renaming the symbolic link in the startup directory with mv /etc/rc2.d/S99xdm /etc/rc2.d/_S99xdm.

  15. Remove the CD and reboot the system with Ctrl+Alt+Del. Login as root.
  16. Edit .bashrc to set virtual terminal sessions to VT100 terminal type:
    • Run nano .bashrc to begin editing .bashrc with nano.
    • Add to the end of the file the line export TERM='vt100'.
    • Hit Ctrl-X, Y, enter to save the file and exit nano.

So that's it. Test x-server is up and running by running the command startx, and test telnet by connecting to the server at the IP you specified from a different machine. Next time, we'll start adding some tools for your server to make it do something.

More information, as well as the rough plans I followed in setting up my server, are available from AboutDebian.com.

Thursday, November 30, 2006

Ubuntu 6.10 Release: How did I miss it?

Wow, this was not something I thought I could miss. I completely failed to realize that Ubuntu 6.10 Edgy Eft came out over a month ago. I'm really quite embarrased.

The release announcement, dated October 26, is here. Looks good to me, I can't wait to try it out. You can download it from here.

I'm downloading Edgy now, when I install it I'll report on how it feels, although I'm regrettably pretty late.

Windows Command Line, I thought I knew Ye

I thought I knew a lot about how the Windows XP command line emulator worked. I've written a number of fairly complex batch programs, gotten pretty comfortable with a large number of command-line programs, and just today started working with the Borland C++ Builder 5.5, a command-line compiler for 32-bit Windows applications. But that led to me learning something new and surprising about the CLI today.

I have my My Documents folder on a different partition than my Windows installation. I installed XP to C:, but set My Documents to L:, which is my /home partition for my Linux OS on the same system (installed to U:). So when I was running the C++ Builder, and had to enter in files on the /home/My Documents partition as parameters to the C++ Builder, I got sick of writing the full file path.

Because I thought I had to. Until today, I couldn't figure out how to cd to another partition on my hard drive. I didn't realize that Windows was treating the partition as a virtual drive, even though it's obviously mounted as my L:. For some reason, it didn't occur to me to change drives like you switch to a directory on a floppy disk.

But that's all I had to do. Now, I don't need to write the full file path, because I can change drives and then cd to the proper directory. I'm basically an idiot for not realizing before that:
C:\> cd L:\ wouldn't work, and I need to type:
C:\> L: to change drives, and then:
L:\> cd programming\c++\helloworld to get to the directory containing my "Hello, World" source.

Moral of the Story: For those of you out there who, like me, couldn't figure out the obvious:
  • Windows treats mounted partitions as virtual disk drives, and not mounted directories like Linux and UNIX do.
  • You consequently need to change drives in a command prompt before you can change directories.
Hope this helps, it took me too long to figure it out.

C++ Compiler Predicament

I mostly program in Java and Visual Basic, but for some time I've been trying to become a bit more comfortable with C++. I had been compiling most of my programs under Ubuntu on my Linux partition using gcc, the free, open-source GNU C compiler. It's been working well, but I wanted to develop under Windows as well. That left me a two options.

First, I could run a Windows port of gcc through Cygwin (note to self: blog about Cygwin soon), a linux API emulator for windows. Cygwin effectively provides a bash shell from within Windows. Unfortunately, I couldn't easily set the Windows port of gcc up to run in Cygwin, although I admit I didn't try real hard.

My other option is to use a different compiler. Oh boy, which one to use. Well, Microsoft released the Visual C++ Express development platform for free (in fact, the entire MS Visual Studio 2005 Express suite is available for free download here) , so I set up VC++ and started developing under that. I guess I should note that I had to mess with some configurations and installations to set up the Windows Platform SDK and be able to compile native 32-bit executables without depending on the .NET framework.

So having to jump through hoops to use the VC++ compiler disappointed me. And I also didn't like working in the VC++ IDE. Sure, it's nice, and does a good job for someone who wants to produce working code quickly. But remember, my first goal is to learn and become comfortable with C++. Until I can write a bit more than a simple search algorithm or "Hello World" app, I don't want an IDE helping me along and handicapping me for later. Goodbye, VC++.

That left Borland C++ Builder 5.5. Honestly, I don't know why I didn't think of it before. It has all the functionality of gcc--maybe even more, but I'm no compiler guru. And it's entirely command-line based, which I like a lot. I feel that once you get a good sense of the tools available to you with a command line, the CLI is much more powerful and efficient for getting jobs done than a GUI. I don't have to deal with a bloated, albeit powerful, IDE like VC++. And, it's a free, small download.

Now, I can finally jump into Windows development and get a stronger foundation in C++, without being handicapped by an IDE I don't want or having to emulate an operating system that isn't what I want to use. Not to mention, C++ Builder is an easy to use but effective compiler.

Monday, November 27, 2006

Labels

Whew, three posts in a day. That's a record. Although I need to make up for not posting in over a month.

Anyways, I just finished cleaning up My Forty-Two Cents. I went through an deleted all of the comments that were spam, and added labels to every single old post. I like how the new beta of Blogger added those. They should add some relationships between posts, and make indexing services like Technorati do their job a bit easier.