Mar 26, 2009

Installing Ubuntu As A Development Web Server

Recently I've been noticing lots and lots of error messages on my home development server. So, last weekend in between painting the shutters and scraping the porch, I reinstalled Ubuntu on an old IBM NetVista 6578-LAU that was given to me years ago. (NetVista... right, this thing still has a "Designed for Windows 98" sticker on it). The server's specs are unimpressive, 700 MHz Pentium III processor, 512 MB of RAM, and I added a 160 GB HDD to it, but, it's enough for me to play with Moodle, Joomla, and VTCalendar that I use in the websites I work with.

My requirements were fairly simple, I wanted to be able to manage the server primarily from my school-issued Windows XP laptop. I don't mind using the Ubuntu interface, but, I primarily run this "server" without a monitor and access it via Firefox, VNC, and Samba. This led me to install Ubuntu Desktop Edition, the LAMP stack and Webmin on my little server I called Tux. The notes below are how I did it. This configuration provides the most efficient tools for me, your mileage may vary. :-)

So, first, I installed Ubuntu 8.10 (Intrepid Ibex). I had recently requested a free set of CDs for my Networking classes, and I just really like how simple Ubuntu is to use and install.

After your first boot, go ahead and do the recommended system updates. This will take quite a while, so, I use the time wisely by doing the following steps:

Note: many of my notes use the domain tux.edu. This is an intranet domain that I set up on my Smoothwall firewall for in-house testing. I don't own this domain, but, it's appropriate since my machine's hostname is Tux and I learn on it. ;-)

Create a root password
I know it's not the "Ubuntu" way, but I started using Linux with early versions of Mandriva, Red Hat, and even Gentoo. I'll admit it... I'm used to having root access, I just don't like sudo, so, to actually have a root password and use su again type the command:

sudo passwd

Note: by issuing this command you can issue su - one time and avoid having to use sudo anywhere below.

Allow Others to View Your Desktop (Remote Desktop for VNC)
I connect to my server when I want to look at a Linux desktop via VNC (I like UltraVNC) at tux.edu:0. Just enable remote desktop and all is well... see the screenshot below:

System > Preferences > Remote Desktop
 
Once this step has been done, I generally switch the monitor, keyboard, and mouse back to my home desktop (I do love my KVM switch), then fire up tux.edu:0 in my VNC Viewer. Wait for the updates to finish and reboot.

After rebooting the fun begins... I add new services and programs to allow me to use this as a development server:

Add SFTP and SSH support

Allows access to sftp and ssh into the server (this is disabled by default in Ubuntu)

sudo apt-get install openssh-server openssh-client

I like SSH Secure Shell Client v 3.2.9 as my Windows SSH (and SFTP) client. It's been discontinued by SSH Secure Shell , but, it's free and available for use for education.

Add LAMP (Apache, MySQL, and PHP)

This is almost too easy to install LAMP in Ubuntu. I found https://help.ubuntu.com/community/ApacheMySQLPHP which mentions the following command:

sudo tasksel install lamp-server

Add Moodle-specific php extensions

I do a lot of work with Moodle, these extensions are used in current and future versions of Moodle. They are a must-have for me...

sudo apt-get install php5-curl php5-xmlrpc

Add Webmin for easy remote management

I used Webmin on my very first Linux server, and I've recently "rediscovered" it. From http://www.ubuntugeek.com/ubuntu-serverinstall-gui-and-webmin-in-ubuntu-810-intrepid-ibex-guide.html, issue the following commands:

sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl

Latest version of Webmin as of 3/20/09 is 1.470 so.. enter the following:

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.470_all.deb
sudo dpkg -i webmin_1.470_all.deb


I can then login to webmin at https://tux.edu:10000

Add user to www-data group

So that I can easily add files to the web server directory, I like to add my local user to the www-data group. To do that:

Click on System > Users and groups
Locate and click on local user - geof
In Secondary Groups - scroll down to locate www-data group
Press -> to add as a group

Create html directory

Red Hat and most of my web hosts have an html directory (or httpdocs, etc). I like to create one in Ubuntu too... so, using Webmin or my SSH Client:

cd /var/www/
sudo mkdir html
sudo chown geof:www-data html


This allows my local user - geof - to be able to write to my html directory without having to worry about changing permissions, etc later. Quick and easy...

Use html directory as the location of all documents in web server

In Webmin...
Servers > Apache Webserver
Click on Existing virtual hosts tab
Click on Virtual Server icon (see pic)

Scroll down to Document Root and enter new directory /var/www/html
Press the Save button here, then go back up to the top right of the screen and click the Apply Changes link

Add phpMyAdmin

phpMyAdmin is the de facto standard for managing MySQL databases, it's the simplest way to manage databases for all of my LAMP scripts.

sudo apt-get install phpmyadmin

** Note: I ran into an issue here, I couldn't get http://tux.edu/phpmyadmin/ to work... maybe because I added /var/www/html to the mix?? Entering the following commands "fixed" my issue, maybe it will yours.

cd /var/www/html
sudo ln -sf /usr/share/phpmyadmin/


Extras

To have a "squiggle account" for quick tests (i.e. http://tux.edu/~geof). I used directions from: http://www.virtualmin.com/forums/help-home-for-newbies/preview-web-site-before-dns-propagation-.html#17477

In Webmin
Servers > Apache Web Server
Click on Global Configuration tab
Click on Configure Apache Modules
Place check beside userdir
Press the Enable Selected Modules button at the bottom of the page, then go back up to the top right of the screen and click the Apply Changes link

Samba (Windows File Sharing)

Must have for me to easily swap files between Windows laptop and server. Directions from: http://www.howtogeek.com/howto/ubuntu/install-samba-server-on-ubuntu/ helped me here.

sudo aptitude install samba smbfs

Use Webmin to configure samba

I always hated configuring samba... how many times have I had to redit the smb.conf file to add new features. Webmin makes this so much easier. Directions from: http://www.webmin.com/samba-howto.html

In Webmin
Servers > Samba Windows File Sharing
Click on Windows Networking
Enter details... my screen is shown below:
Press the Save button on the bottom of the screen
Next click on the Authentication Icon next to the Windows Networking Icon. Enable encrypted passwords then save the changes.
Click on the File Share Defaults icon and then on the Security and Access icon.
Enter details... my screen is shown below: (note that my network is pretty secure, and I only use this at home)

By default your home directories are shared when you enable Samba, so, you should have no problems accessing the public_html files we added before (squiggle account), but, most of the stuff we need in in /var/www/html so, why not add that as a Windows share?

In Webmin at Servers > Samba Windows File Sharing
Click on the Create a new file share. link on the top of the page
Enter the details to create html as a Windows Share on your server
Be sure to check the Security and Access Control to ensure that your user is a valid user.
Once done, click on Restart Samba Server to activate all the changes you've made.

Issue the smbpasswd command in a Terminal OR Webmin (Others > Command Shell)

Well, that does it! This left me with a local server I could administer and/or use on my network via web browser, My Network Places and SFTP/SSH. Note that there is also a File Browser in Webmin as well (Others > File Manager) - so you can upload files and manage your server from anywhere you can access this server by IP address.

No comments: