Intranet Server For Free

Introduction

At the end of last year a client asked me for a recession friendly intranet server solution so his users could keep up to date with the latest company information, access common documents like holiday request forms etc.

He wanted something easy to maintain by anyone. He had been looking at SharePoint as an option. (An expensive option in my eyes) But within two days I had the solution, had it approved, and implemented it for him, this is what I did.

I set him up an Ubuntu Server with OpenSSH, Apache 2, MySQL, PHP, VSFTPD, and a Drupal content management system, on an old P4 that happened to be available for use saving on expensive hardware.

I did this using Ubuntu 8.10 and Drupal 6.9. Why Ubuntu, well it is the simplest OS to set up from install with the LAMP stack, and openSSH as an option during the install process. There is no need to configure much and it will work as soon as it is installed.

I will write how to do this using the latest Ubuntu 9.04 Server version, and Drupal 6.13.

Installing Ubuntu Server 9.04

Download and burn your image of Ubuntu Server from www.ubuntu.com, I have gone for the 32 bit version.

1) Boot from the CD image, and select your language.

2) Select ‘Install Ubuntu Server’

3) Choose the language for the installation process.

4) Choose your country.

5) At the auto detect keyboard layout screen I selected no as I wanted to make sure I got the right keyboard installed plus in the 8.10 version it did not detect properly.

6) As I selected no to auto detect the keyboard I had to choose my keyboard layout according to country in my case it was UK.

7) The next screen tries to eliminate the various UK keyboards I selected the default UK one.

8.) Choose the hostname for the server in my example I will name it intranet server

9) The partitioning section comes up the default partition scheme is to use the entire disk with LVM. (Click on LVM to find out what it means) select this option.

10) Confirm the disk to partition

11) Confirm write changes to the disk

12) Partitioning size confirmation for future upgradability. I Kept the default size

13) Confirm write changes to the disk

14) Add in the full name for a normal user that will use the system (maybe an admin) this will not have root privileges.

15) Add a username for this user usually the name entered previously is used as default but this can be changed.

16) Choose a password for this account and confirm the password. If it is week you will be prompted but you may continue by saying yes use week password.

17) Say no to encrypt your home directory unless you want it encrypted.

18) As we are using this as an internal system we will not need to configure a HTTP proxy just leave it blank and click next.

19) Choose the update method for the server, I would use the ‘no automatic updates’ setting in case any of the new updates disrupts anything we are installing. It is good practice to know what is being updated on a server.

20) In software selection choose LAMP server and OpenSSH server this will take care of Apache, MySQL, and the SSH connection protocol.

21) Choose a MySQL root password and confirm it.

22) The install finishes off and ejects the CD and asks for a reboot, remove the CD and click continue to reboot.

23) Once rebooted login with your username you created and password

If you successfully log in congratulations you have just set up a server with Apache, MySQL, PHP, and OpenSSH.

First things first and that is to update the software repository database so you can get the latest Ubuntu released software. Type in “sudo apt-get update” followed by your password.

You can now connect to your server through SSH, to do this from a Windows PC just use a program like putty and type in the IP address for the server. To get the IP address type in ‘ifconfig’ in a console prompt and take note of the IP address.

You can now run the server without a monitor and keyboard attached, and control it via another computer on the network through SSH. This could be enough to start an Intranet using HTML and PHP but we want easy management.

Next comes a content management system to take care of the content without the need for an editor again saving on costs. My preferred choice for this is Drupal.

Installing Drupal

We need to obtain our copy of Drupal so type in “sudo wget http://ftp.drupal.org/files/projects/drupal-6.13.tar.gz” this will download the Drupal file into your current directory. The default is your home directory.

We need to unpack the files issue the command “tar –zxvf drupal-6.13.tar.gz” this will extract the files into a folder in your home directory

We need to make a directory in the web root folder to keep the Drupal files in. To do this type in “sudo mkdir /var/www/drupal”

We need to move the Drupal content over to the web folder. Type in “sudo mv drupal-6.13/* drupal-6.13/.htaccess /var/www/drupal”

We need to set up folders for media associated with the site to do this issue “sudo mkdir /var/www/drupal/sites/default/files” then “sudo chown www-data:www-data /var/www/drupal/sites/default/files

We need to copy and set the Drupal initial config file. To do this we first set copy the settings file by issuing “sudo cp /var/www/drupal/sites/default/default.settings.php /var/www/drupal/sites/default/settings.php” then we need to make sure this file is accessible by issuing the command “sudo chown www-data:www-data /var/www/drupal/sites/default/settings.php”

Next we need to make sure there is a database in MySQL that Drupal can use. Issue the command “mysqladmin –u root –p create drupal” at the prompt type in the MySQL password you added during the Ubuntu setup.

Drupal will also need the right to read and write data to the SQL database. Log into MySQL by typing “mysql –u root –p” followed by the MySQL password At the mysql> prompt type in “GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON drupal.* TO ‘drupaluser’@'localhost’ IDENTIFIED BY ‘drupalpass’; note this is important we do not want the root password for SQL being used all the time so the above command creates a Drupal user and Drupal password. Replace ‘drupaluser’ and ‘drupalpass’ with something else.

Next at the mysql> prompt type in “FLUSH PRIVILEGES;” then when executed type in “\q” to quit MySQL.

Now we need to restart Apache to make sure the settings take effect. Type in “sudo /etc/init.d/apache2 restart”

Do an “ifconfig” to get your IP address then head over to another computer on your network. Open up a web browser and type in the IP address from the server in the address bar e.g. 192.168.1.4, you will be presented with an “it works!” page which is apache telling you its server is up.

Next add a /drupal to the IP address in the address bar and you will be taken to the Drupal configuration page to set up the content management system and interface. If you see this congratulation you are nearly there.

Drupal now needs setting up, most of it is self explanatory but here are the steps:

1) Click on install Drupal in English

2) Type in the database name in this example it was called ‘Drupal’

3) Type in the username for the MySQL account for Drupal in this example it is ‘drupaluser’

4) Type in the password for the username in this example it is ‘drupalpass’

5) Enter in a site name I am calling my one ‘Intranet’

6) Site Email address is for whatever email address you want to associate with the site.

7) Type in an administrator name I will keep this straight forward and call it ‘Administrator’

8.) Choose and confirm the password for this user.

9) Choose the time zone you are located in.

10) Uncheck check for updates automatically. (I want it as it is then update it when I want to)

11) Save and continue

12) Then click on ‘your new site’

That is Drupal set up and ready to be customised and content added. There are plenty of tutorials on the internet on how to use Drupal’s features and how to add content. The site itself is quite self explanatory and you should be able to work yourself through it. You can also set up user accounts so you can control who logs in and who can do what according to what administration group they belong to. Any questions please get in touch my details are in the contact page.

Now we need a way to get files to and from the server in case we want to display any pictures or upload any documents. To do this we will need to install some sort of file transfer mechanism. But to be honest it will rarely be used.

Installing a FTP server

The FTP server of choice for me is VSFTPD but you could use any.

I would configure VSFTPD in the following way so only the local account on the server has FTP access which should be the administrator.

You can add other users to the local accounts on the server to allow other select people to upload files this is up to you. To set this up follow the following steps:

1) Type in the command in a shell prompt “sudo apt-get install vsftpd” and type Y when asked about additional disk space needed when installing.

2) Now it has installed we need to edit the configuration file. Type in “sudo nano /etc/vsftpd.conf”

3) Go through the file and change the settings to allow you the control you need to provide FTP access. I did the following for my configuration:

  • a. Change ‘anonymous_enable=YES’ to ‘NO’ to disable anonymous login.
  • b. Uncommented the line by removing # from the front of ‘write_enable=YES’ so we can write files to the FTP server.
  • c. Uncomment the line ‘local_enable=YES’ to allow local system user accounts on the server to log into the FTP server.
  • d. Uncomment the line ‘ftpd_banner=Welcome to blah FTP service’ and changed the wording after the ‘=’ to anything you want displayed when users connect. e. Press ctrl+x to exit and save changes made.

4) Restarted the FTP server so changes take effect by issuing “ sudo /etc/init.d/vsftpd restart”

Now you can log on to the ftp server through a client like filezilla from anywhere on the internal network with the IP address of the new intranet server.

Last but not least you will want to administer the database associated with Drupal and perform backups etc. To help with this task I installed phpMyAdmin.

Installing phpMyAdmin

This add-on is a must with mySQL, it makes life so much easier. To install it open a shell prompt and type ” sudo apt-get install phpmyadmin” then type in your user password associated with your user account.

Follow the prompts when they come up, one will be to select the web server being used, the other will be to connect to the mySQL database, and then one for phpMyAdmin login.

Once installed you can access the user interface from the address http://serveripaddress/phpMyAdmin from any web browser on any computer on the internal network.

The End

And that is it, A complete intranet built and ready within 90 min using Ubuntu Server, Apache 2, PHP 5, mySQL 5, Drupal CMS, openSSH, VSFTPD, and phpMyAdmin. The rest of the configuration is down to you as it can be tweaked a lot.

Hope you all enjoy this post. Any comments please feel free to post them, if you would like any advice please get in touch; my contact details are available on the contact page or just email k_gohlar@hotmail.co.uk.


About this entry