Easy install Ubuntu Server
As a typical web designer and PHP/MySQL developer I like to build my sites in an off-line environment, usually I use XAMPP on my desktop or as I’m a Apple Mac user, MAMP. However, there are occasionally good reasons develop on a separate Linux server set up on a network, which has the added bonus of enabling me to host a website, iTunes library, photo library or a wiki.
Why you should/shouldn’t use this guide
You should not use this guide if you are terrified of using the command line, or don’t want to have a computer that is always switched on - think of the energy being wasted!
You should use this guide if you’ve tried installing Linux before, have used the command line, but maybe didn’t get everything working quite right, and finally that you have a very low-powered computer that can be left switched on.
This guide is for the basic server installation of Ubuntu Server 7.10, Apache, PHP, MySQL, FTP and phpMyAdmin. I hope to add further guides for iTunes libraries, wikis, wordpress and so on later.
Requirements
- A computer - I currently use a low powered 750Mhz computer I got from freecycle. It includes a 120Gb hard disk and 256Mb of RAM.
- A Ubuntu Server CD - download this from here and burn to a CD. This guide is for the 7.10 Gutsy edition.
- Some experience of the command line (bravery will do for a complete novice).
- Experience of using a command line text editor such as vim.
Install from CD
Right let’s get going. Boot the computer up from the CD, and when prompted select ‘Install to the hard disk’.
You will be taken through the options for installing. I won’t detail every step of this process because it’s really quite straight-forward but you might want to have a look at this page if you get lost and come back here once you’ve rebooted.
The important things to select are
- When it says ‘Configuring the network with DHCP’ cancel this, or go back if it completes. You need a static ip address, so that you can always access the server at the same place.
- Choose a hostname that you want to use to access the server e.g. ‘ubuntu-server’ would mean that you can view webpages by entering http://ubuntu-server/ into your browser.
- When partitioning your disk, assuming you don’t want to keep any of the data on it select ‘Guided - use entire disk’.
- At the software selection stage, select LAMP and Open SSH
- You will be asked for a password for MySQL, it is advisable to use a different on to your main username.
On any Mac/Linux computers that you may access this server from add your ip address (in my case 192.168.1.100) and hostname (as specified above something like ubuntu-server) to /etc/hosts:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
192.168.1.100 ubuntu-server
For more information on the hosts file, and it’s location on windows computers I refer you to the wikipedia article.
To access the server you can use the physically connected keyboard, but this guide is geared towards logging in using SSH. On windows download PuttySSH and login using the ip address that you specified, or on a Mac or Linux use a terminal. On a Mac the terminal program can be found in Applications –> Utilities.
Update your system by running these commands:
sudo apt-get update
sudo apt-get upgrade
Apache
First we need to add the apache folders to your home directory so that you can add files by ftp. The main www pages are stored in /var/www and this can be changed to /var/your_user_name/www where you can access it.
cd ~
mkdir www
sudo vim /etc/apache2/sites-available/default
and replace the following lines
DocumentRoot /var/www
should read
DocumentRoot /home/your_user_name/www
and
should read
<Directory /home/your_user_name/www/>
To set the permission of this directory, run:
sudo chmod -R 755 ~/www
There are several web apps that I like to host (such as a personal productivity app and phpMyAdmin) which need to be kept private from other users of the web. First let’s create the directory.
cd ~/www
mkdir private
Now this needs password protecting, first edit the apache config file
sudo vim /etc/apache2/sites-available/default
and add the following lines to the end of the file just before: </VirtualHost>
# Password protected directory
<Directory /home/your_user_name/www/private>
AuthType Basic
AuthName "Private Files"
AuthUserFile /etc/apache2/passwords
Require valid-user
</Directory>
Now we need to create the password file, for this we can use the htpasswd utility from apache:
sudo htpasswd -c /etc/apache2/passwords enter_your_username_here
This will ask you for a password twice. Now’s the time to reboot the server
sudo reboot
When you now access your website http://your_ip_address_or_hostname/private you should be asked for a user name and password.
Install and configure an FTP Server
sudo apt-get update
sudo apt-get install vsftpd
Let’s edit the config file:
sudo vim /etc/vsftpd.conf
By default only anonymous FTP is allowed. We only want to allow access to users directories so change:
anonymous_enable=YES
to
anonymous_enable=NO
By default, local system users are not allowed to login to FTP server. To change this setting, you should uncomment (remove the #) the following line:
#local_enable=YES
By default, users are allowed to download files from FTP server. They are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line:
#write_enable=YES
Finally, lets restart the ftp server to enable the changes we’ve just made:
sudo /etc/init.d/vsftpd restart
Install phpMyAdmin
Assuming that you only need the english translations, download english.tar.gz from here (using your client computer).
Upload it to your private directory on the server using FTP (the downloaded file should be called something like this: phpMyAdmin-2.11.4-english.tar.gz.
Next log back into the server and decompress the file:
tar xzfv phpMyAdmin*.tar.gz
rm phpMyAdmin*.tar.gz
mv phpMyAdmin* phpmyadmin
Before we can access phpMyAdmin from a web browser we need to configure it
cd phpmyadmin
cp config.sample.inc.php config.inc.php
vim config.inc.php
The only line you need to change starts $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Between the quotes add a really long selection of random numbers and letters, but only numbers and letters (capitals allowed), the more the better.
Now you can configure MySQL by accessing phpMyAdmin from http://your_ip_address/private/phpmyadmin/ you will need to use ‘root’ for the username, and the password you specified when installing LAMP from CD.
Feel free to drop me a line if you’ve got any questions, but a really good place for support is the Ubuntu Forums.