Fit-PC2

In this "how to", I will document the setup of a Fit-PC2 running Ubuntu/Linux. My experience with Linux is limited, so I have decided to document this process for both my own sake as well as others. Let me also say that I turned to the internet for many of the instructions in the how-to, and I have even copied some of the text from other tutorials directly into this how-to. I hope this doesn't offend anybody. Let's get started.


How To Install Java 6 on Ubuntu

Installing Java on Ubuntu turned out to be very easy. This is how:

Before you begin, you need to ensure that your repositories are up to date by issuing the following:

sudo apt-get update

If you are developing Java applications, you will require Java Development Kit (JDK), on the other hand if you just require Java to run Java applications, then you need just Java Runtime Environment (JRE). For the former, the command is as follows:

sudo apt-get install sun-java6-jdk sun-java6-plugin

For JRE:

sudo apt-get install sun-java6-jre sun-java6-plugin

Once either one is done, run the

sudo update-java-alternatives -s java-6-sun

command and finally add the line

/usr/lib/jvm/java-6-sun

to the top of the /etc/jvm file (nano /etc/jvm). Save and exit. To test your Java(TM) setup in the terminal type:


java -version

If you get an output like below, then you are done!


java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

How To Install MySQL on Ubuntu

Next I wanted to install MySQL, because what is a web server without a database! It turns out that installing MySQL has not been easy for a lot people, but I must say that I had no problems at all with this series of steps:

First make sure your package management tools are up-to-date.

sudo apt-get update

Also make sure you install all the latest software available.

sudo apt-get dist-upgrade

After a few moments (or minutes, depending on the state of your system), you're ready to install MySQL. By default, recent Ubuntu/Debian systems install a MySQL Server from the 5-branch. This is a good thing, so don't worry. First, install the MySQL server and client packages:

sudo apt-get install mysql-server mysql-client

That's almost it. You can now log using the following command:

mysql -u root;

When logged in, you should start by setting the password on the root account. This is important. Here is how:

set password for root@localhost=password('your_password_here');

Now log out and log in using your new password:

mysql -u root -p;

While logged in, let's also take care of a couple of house-keeping procedures. There are some accounts/users you don't need, so delete them now (for security reasons):

use mysql;

delete from user where User='';

delete from db where User='';

flush privileges;

Finally, we should make an account for basic use:

GRANT ALL PRIVILEGES ON *.* TO 'new_username'@'localhost' IDENTIFIED BY 'new_password' WITH GRANT OPTION;

If you want to set up netword access to your new mysql installation (right now you can only make connection from localhost), you will need to make a small change to your mysql config file. Here is how:

Locate the my.cnf file, which is the master configuration file for MySQL server. (On a Ubuntu system this file may be located in /etc/mysql.)

Open this file in your favorite editor and look for the following entry:

bind-address = 127.0.0.1

To instead make the MySQL server listen on all interfaces, edit this entry to the following:

bind-address = 0.0.0.0

Save the file, then restart the MySQL server:

sudo /etc/init.d/mysql restart

How To Install Apache Tomcat 6 on Ubuntu

Next, I wanted to install the Tomcat web server. So I downloaded and extracted Tomcat from the apache site. You should check to make sure there is not another version and adjust accordingly.

wget http://apache.idnr.ws/tomcat/tomcat-6/v6.0.24/bin/apache-tomcat-6.0.24.tar.gz

tar xvzf apache-tomcat-6.0.14.tar.gz

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat6, but you could move it somewhere else if you wanted to.

sudo mv apache-tomcat-6.0.14 /usr/local/tomcat6

Tomcat requires setting the JAVA_HOME variable.
The best way to do this is to set it in your .bashrc file. You could also edit your startup.sh file if you so chose. The better method is editing your .bashrc file and adding the bolded line there. You'll have to logout of the shell for the change to take effect.

vi ~/.bashrc

Add the following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

At this point you can start tomcat by just executing the startup.sh script in the tomcat/bin folder.

Tomcat should now be fully installed and operational. Enjoy!

How To Install VSFTPd on Ubuntu

Finally, I wanted to install an ftp server. I looked around for a little while, and it quickly became obvious that most people install either vsftp or proftp. I ended up installing vsftp because it appears to be the most secure.

Now, I didn't want just the standard installation, but rather I was interested in creating virtual users, so I could quickly add additional users and folder as I found the need. Here is the final installation process:

First download and install vsftp.

apt-get install vsftpd

We are going to use pam_userdb to authenticate the virtual users. This needs a username / password file in 'db' format -- a common database format. We need 'db_load' program:

For Ubuntu:

apt-get install db4.2-util


To create a 'db' format file, first create a plain text file 'virtual-users.txt' with the usernames and passwords on alternating lines:

user1
user1Password
user2
user2Password

Then execute the following command to create the actual database:

db4.2_load -T -t hash -f virtual-users.txt /etc/vsftpd/virtual-users.db

Now, create a PAM file /etc/pam.d/vsftpd-virtual which uses your database:

auth required pam_userdb.so db=/etc/vsftpd/virtual-users
account required pam_userdb.so db=/etc/vsftpd/virtual-users


Create a configuration file /etc/vsftpd/vsftpd-virtual.conf:

# disables anonymous FTP
anonymous_enable=NO
# enables non-anonymous FTP
local_enable=YES
# activates virtual users
guest_enable=YES
# virtual users to use local privs, not anon privs
virtual_use_local_privs=YES
# enables uploads and new directories
write_enable=YES
# the PAM file used by authentication of virtual uses
pam_service_name=vsftpd-virtual
# in conjunction with 'local_root',
# specifies a home directory for each virtual user
user_sub_token=$USER
local_root=/var/www/virtual/$USER
# the virtual user is restricted to the virtual FTP area
chroot_local_user=YES
# hides the FTP server user IDs and just display "ftp" in directory listings
hide_ids=YES
# runs vsftpd in standalone mode
listen=YES
# listens on this port for incoming FTP connections
listen_port=60021
# the minimum port to allocate for PASV style data connections
pasv_min_port=62222
# the maximum port to allocate for PASV style data connections
pasv_max_port=63333
# controls whether PORT style data connections use port 20 (ftp-data)
connect_from_port_20=YES
# the umask for file creation
local_umask=022



Create each user's home directory in /var/www/virtual, and change the owner of the directory to the user `ftp:

# mkdir /var/www/virtual/mary
# chown ftp:ftp /var/www/virtual/mary


Now we can start VSFTPD by the command:

# /usr/sbin/vsftpd /etc/vsftpd/vsftpd-virtual.conf

and test the FTP access of a virtual user:

# lftp -u mary -p 60021 192.168.1.101


Note: if you want to run your ftp server on port 21. Then change the following line in your conf file:

listen_port=60021 to
listen_port=21
, and restart

Note 2: Answer to common questions:
How to add another virtual user:
  1. Add new user and user password to "virtual-users.txt"
  2. Recreate the actual database: db4.2_load -T -t hash -f virtual-users.txt /etc/vsftpd/virtual-users.db:

That's it for now;