How-to: Install and run a Linux-Webserver

In this Tutorial we will see, how to install and run a Webserver based on Ubuntu Linux 14.04 LTS Minimal System 64 bit.

So what will we have in the end of this Tutorial?

– Ubuntu Linux Operating System

– KDE Desktop (for Desktop PCs)

– Xfce Desktop (for remote access, with geany PHP editor)

– LAMP Server (Apache2, MySQL, PHP)

– PHPmyAdmin

– Imagemagick for image manipulation (for Typo3)

– Webalizer log analyzer

– FPDF to write PDF files out of PHP

– Xpdf to idex PDF files (for Typo3)

– FTP Server to Upload files on remote machines

– WebDAV directory to Upload files on remote machines in Windows Explorer and download via HTTP Browser

– OpenSSL encryption for HTTPS access to websites

– Xrdp remote desktop server to connect to the server via Windows Remote Desktop

– Typo3 6.2.14 installation with changes in PHP.ini

– Virtual Hosts to host more than one Website on the Server

The main steps in this Tutorial will be the same for other Versions of this distribution, i guess…

Step 1: Get a fresh Ubuntu Server with openSSH

The first thing that you will need, is a sever that has Ubuntu Linux (14.04 LTS) installed, and a preinstalled SSH-Server that you can connect to.

(for example from

The second thing that you will need, is the Windows Version of “PuTTY” to connect to your new Server via SSH.


– Download and Open “putty.exe” and just enter the Hostname or IP Adress of your Server. Then click “open”.

– Putty will ask for a Username: root

– Putty will ask for a Password: root-Password you got from the Server company

Now you are connected to your Server!

Step 2: Install the Software to run a Webserver (LAMP,phphmyadmin,imagemagick)

Ubuntu offers a nice Tool that will install a basic LAMP Server. To open that tool, type:


in the black “Putty” Window.

Then select the “LAMP Server” by adding a * (hit space bar) to the selection.

Then you will be asked for a MySQL root Password. Choose one and go on with the installation.

Now the Server should be up and running.

Test the Server by Browsing to


You should see “It works!”.

Then  you can install PHPmyAdmin by typing

sudo apt-get install phpmyadmin

You will be asked if you want to configure. Choose “Apache2? and OK and dbconfig-common NO.

Now you should be able to login to PHPmyAdmin with your Webbrowser on


by using your chosen MySQL root password.

Now you can go on by installing ImageMagick

sudo apt-get install imagemagick

and Webalizer

sudo apt-get install webalizer

and some additional Tools like gZip etc…

sudo apt-get install build-essential

Now you have got all the basic software for a Webserver that can run Typo3 or WordPress or other stuff based on PHP and Imagemagick.

Step 3: Expand your PDF capabilities (fpdf,xpdf)

If you like to generate and “search” inside of PDF documents, you will need FPDF to generate PDF files, and xPDF to search inside and extract Text from PDF files.

Install FPDF with

sudo apt-get install php-fpdf

and create a Symlink into the main Webroot of Apache2 by going to the new FPDF directory where the fpdf.php library is placed:

cd /usr/share/php/fpdf

and create a Symlink there

ln -s /usr/share/php/fpdf /var/www/html/fpdf

that redirects from the www/html directory.

Because of the Symlinks you have to restart Apache

sudo service apache2 force-reload

and you can create a new .PHP file to test your installation:

vi /var/www/html/fpdf/index.php

and type

< ?php ob_start(); require('fpdf.php'); $pdf=new FPDF('P','mm','A4'); $pdf->AddPage();
$pdf->SetFillColor(252, 211, 191);
$pdf->Rect(0, 0, 500, 500, ‘F’);
$pdf->Cell(40,10,’Hallo Welt!’);
$pdf->Output(‘blabla.pdf’, ‘I’);

by Browsing to


you should see your first php-generated PDF document!

If you like or need to index PDF files (in Typo3) you will need to install xPDF by typing

sudo apt-get install xpdf

that will create the “pdftotext” software inside of

cd /usr/bin/

That is the place where Typo3 will expect pdftotext by default.

Step 4: Install a FTP Server to Upload and Download files (vsftpd)

We will install the vsftpd Server by typing

sudo apt-get install vsftpd

later we can configure it by editing

vi /etc/vsftpd.conf

but now we only want to allow “root” to access out server by editing

vi /etc/ftpusers

and add a # before “root”, so that root will not be disabled anymore.

Now you should be able to log in to your Server with your FTP-Client by using your IP-Adress and the User “root” with the root-password!

Step 5: Install a WebDAV directory (webdav)

Install WebDAV to copy files on the Server and make them downloadable with a Webbrowser by

sudo a2enmod dav


sudo a2enmod dav_fs

and restart Apache

sudo /etc/init.d/apache2 restart

and create a new directory for webdav

sudo mkdir /var/webdav

and change the owner of this directory to Apache

sudo chown www-data:www-data /var/webdav

and add the alias and directory to the Apache configuration

vi /etc/apache2/sites-available/000-default.conf

and type in:

Alias /webdav “/var/webdav/”
< directory " /var/webdav/ " DAV on Options +Indexes < /directory >

and add the directory rules in

vi /etc/apache2/apache2.conf

and type in:

< Directory /var/webdav/ >
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
< /Directory >

and restart Apache

sudo /etc/init.d/apache2 restart

and now you should be able to see the content of var/webdav by browsing to


and download the files that are inside!

Step 6: Add SSL encryption (ssl,webdav)

To secure the connections to your Server (especially with WebDAV) you have to activate SSL.

Windows will require SSL to make a connection to WebDAV!!

Activate openSSL by generate a key

openssl genrsa -out /etc/ssl/private/apache.key 2048

create a certificate that is valid for 1 year

openssl req -new -x509 -key /etc/ssl/private/apache.key -days 365 -sha256 -out /etc/ssl/certs/apache.crt

(Now you will be asked some Questions, fill in the stuff you like to fill in)

sudo a2enmod ssl

restart Apache

sudo /etc/init.d/apache2 restart

Edit the Apache SSL config

vi /etc/apache2/sites-available/ssl.conf

and add:

< VirtualHost *:443 >
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache.crt
SSLCertificateKeyFile /etc/ssl/private/apache.key
DocumentRoot /var/www/html/
< /VirtualHost >


sudo a2ensite ssl.conf

restart again

sudo service apache2 force-reload

And now you should be able to browse to


and add a new Windows Network Resource by adding


in the Windows Explorer (Network).

Step 7: Secure WebDAV by Password for a User

Now that our WebDAV works, we need to secure it by creating a user that can connect via WebDAV by

vi /etc/apache2/sites-available/000-default.conf

and extend the previous input:

Alias /webdav ” /var/webdav/ ”
< Directory "/var/webdav/" >
DAV on
Options +Indexes
AuthType Basic
AuthName DAV
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
< /Directory >

Now we need some Apache module

sudo apt-get install apache2-utils

to add a new user

htpasswd -c /etc/apache2/.htpasswd user1

and add password


now create a second WebDAV only user

htpasswd /etc/apache2/.htpasswd webdav

and add password


and restart Apache

sudo /etc/init.d/apache2 restart

Now you should be prompted for a password , if you want to access the WebDAV folder again!

You can access the folder by using user “webdav” and “password2?.

Step 8: Install Remote Desktop Access from Windows (xRDP,xFCE4,geany)

Now we want to add a nice looking Desktop to our Server, where we can log on from our home Windows-machine.

First we add the Remote Desktop Server

sudo apt-get install xrdp

and start it

sudo /etc/init.d/xrdp start

Then we install the Kubuntu KDE Desktop with a bunch of Standard software:

sudo apt-get install kubuntu-desktop

and the alternate Desktop that uses less resources and is better for remote control:

sudo apt-get install xfce4

and we add a PHP / Text Editor “geany”

sudo apt-get install geany

Now that we have our Desktop, we want to make it accessable for remote machines by

echo xfce4-session >~/.xsession


vi /etc/xrdp/

and change from

. /etc/X11/Xsession



and restart xrdp

sudo service xrdp restart

Now we should be able to login from Windows Remote Desktop and see our new xFCE4 Desktop by opening in Windows Remote Desktop

sesman-XVNC / IP-Adress / root / root-password

The first time we open the Desktop, we can select “use default config”.