Web Server with Ubuntu 10.04

Install Apache2, MySQL5, PHP5 and PHPMyAdmin on Ubuntu

This is a collection of guide how to install Apache Httpd Web Server complete with latest PHP (as Apache mod), MySQL for Ubuntu. As a bonus, I even through in an additional guide to install PHPMyAdmin. Please do note that most of this guide can be found elsewhere which is listed at the bottom of the guide.

Getting Started

I’m sure everyone here is familiar on how to use Terminal which is available from:

Applications > Accessories > Terminal

Install Apache Httpd Web Server

To install Apache, type the following command into your Terminal:

> sudo apt-get install apache2

Testing Apache

Paste the following command into your Terminal

> sudo /etc/init.d/apache2 start

Then open http://localhost/ or http://127.0.0.1 from your web browser. At first run, you would probably see a directory listing or a HTML page with a text saying “It’s Work“.

To browse the file please navigate to the following folder

> cd /var/www/

Install PHP

Similar to Apache, all you need to do is type the following command in your Terminal:

> sudo apt-get install php5 libapache2-mod-php5

After the installation is complete, do restart your Apache Http Web Server.

> sudo /etc/init.d/apache2 start

This allow PHP to be include as Apache mod.

Testing PHP

A simple way to test your PHP is via phpinfo() function which display all related configuration of your PHP. To do so type the following command in your Terminal.

> sudo gedit /var/www/phpinfo.php

This will open gEdit text editor which you will type in

  • <?php phpinfo(); ?>

<?php phpinfo(); ?>

Open http://localhost/phpinfo.php in your web browser and you will get something like this:

You should see all of the info about your PHP installation listed on the page.

Install MySQL

Again, type the following command in your Terminal

> sudo apt-get install mysql-server

Note: As MySQL is installing, it will ask you to configure your root password. Make sure that you type it correctly, as it will only ask you once.

You might need to manually start MySQL for the first time, do so by typing this command in your Terminal.

> sudo /etc/init.d/mysql start

Testing MySQL

After that is finished, you can test MySQL by running this, where 123 is your password

> mysql -uroot -p123

mysql> show databases;

mysql> quit

Install PHPMyAdmin

As usual, run the following command in terminal

> sudo apt-get install phpmyadmin

This process is quite, as slow as MySQL installation and there are time you need to provide some information in order to complete the process but it quite optional. Once finish you need to create a soft link in /var/www/ to /usr/share/phpmyadmin using these command.

> sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

Now open up http://localhost/phpmyadmin your web browser.

Conclusion

If you find anything missing do drop a comment below. Any additional information are also welcome.

 

Note :

If you Can’t open PHP files in Firefox (Apache installed) – PHTML —->> You can try to reinstall libapache2-mod-php5 package again, see if it can reset the configuration of Apache.

How to Install Webmin @Ubuntu 10.04

Install and configure Webmin

Download Webmin:

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb

Install the Webmin dependencies:

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl

One other dependency is libmd5-perl, but has been deprecated and is no longer available in the Ubuntu repositories for 10.01. So to install it we need to use a workaround:
wget http://mirrors.kernel.org/ubuntu/pool/universe/libm/libmd5-perl/libmd5-perl_2.03-1_all.deb

sudo dpkg -i libmd5-perl_2.03-1_all.deb

Now it is time to Unpack Webmin

sudo dpkg -i webmin_1.510-2_all.deb

Woops, one more dependency problem…

dpkg: dependency problems prevent configuration of webmin:
webmin depends on apt-show-versions; however:
Package apt-show-versions is not installed.
dpkg: error processing webmin (–install):
dependency problems – leaving unconfigured
Processing triggers for ureadahead …
Errors were encountered while processing:

So we need to

sudo apt-get install apt-show-versions

and we get:

Reading package lists… Done
Building dependency tree
Reading state information… Done
You might want to run `apt-get -f install’ to correct these:
The following packages have unmet dependencies:
apt-show-versions: Depends: libapt-pkg-perl (>= 0.1.21) but it is not going to be installed
E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

so now we try

sudo apt-get -f install

Hooray, we now have Webmin installed

Webmin install complete. You can now login to https://numberip:10000/
as root with your root password, or as any user who can use sudo
to run commands as root.

So try it out, open a browser and go to https://192.168.36.16:10000/ using the ip of your ubuntu server. You will need to get through the security certificate warnings then log in as a user in your sudors file.

Now we need to install the Dansguardian module for Webmin

Download the module:
wget http://sourceforge.net/projects/dgwebminmodule/files/dgwebmin-devel/0.7.0beta1b/dgwebmin-0.7.0beta1b.wbm/download

Then open webmin and go to Webmin>Webmin Configuration>Webmin Modules
Chose install from local file and navigate to the file home>user ,where user is your user name, then choose the file and click install module.

Now click on servers and you will see that Dansguardian Web Content is in the list. Unfortunately when we click on it we get the error:

Warning – DansGuardian binary file not found, maybe you need to update your module config (especially the directory paths).
(Expected location: /sbin/dansguardian)

Warning – the version of DansGuardian you have is not supported by this Webmin module version
Webmin Module Version 0.7.0beta1b supports DG version 2.10 (& 2.9)
Currently installed DG version ?

Warning – running as root(superuser) risks new files not being readable by production DansGuardian

Kinda frightening, but have no fear. Click on module config and change the full path to Dansguardian Binary to /usr/sbin/dansguardian.

We now have a functioning proxy server with content filter and a gui to help configure it. Dansguardian has zillions of configuration options, but I find that I generally only worry about the Exception site (domain) list /etc/dansguardian/lists/exceptionsitelist which can be found under View/Edit A Filter Group’s Lists. I have also changed the Banned (file)extension list /etc/dansguardian/lists/bannedextensionlist as the list of banned extensions is more restrictive than what we allow here.

Anyway, I hope this helps someone out there. Please let me know if I have made any mistakes, or if you have any questions.

Terminal Action

root@desktop:/usr/local/src# sudo apt-get install apt-show-versions

Reading package lists… Done

Building dependency tree

Reading state information… Done

You might want to run `apt-get -f install’ to correct these:

The following packages have unmet dependencies:

apt-show-versions: Depends: libapt-pkg-perl (>= 0.1.21) but it is not going to be installed

webmin: Depends: libnet-ssleay-perl but it is not going to be installed

Depends: libauthen-pam-perl but it is not going to be installed

Depends: libio-pty-perl but it is not going to be installed

E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

root@desktop:/usr/local/src# sudo apt-get -f install

Reading package lists… Done

Building dependency tree

Reading state information… Done

Correcting dependencies… Done

The following extra packages will be installed:

apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl

libnet-ssleay-perl

The following NEW packages will be installed:

apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl

libnet-ssleay-perl

0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.

1 not fully installed or removed.

Need to get 122kB/403kB of archives.

After this operation, 1,819kB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://repo.bppt.go.id/ubuntu/ lucid/main libapt-pkg-perl 0.1.24 [88.5kB]

Get:2 http://repo.bppt.go.id/ubuntu/ lucid/universe apt-show-versions 0.16 [33.7kB]

Fetched 122kB in 13s (9,360B/s)

Selecting previously deselected package libnet-ssleay-perl.

(Reading database … 145159 files and directories currently installed.)

Unpacking libnet-ssleay-perl (from …/libnet-ssleay-perl_1.35-2ubuntu1_i386.deb) …

Selecting previously deselected package libauthen-pam-perl.

Unpacking libauthen-pam-perl (from …/libauthen-pam-perl_0.16-2_i386.deb) …

Selecting previously deselected package libio-pty-perl.

Unpacking libio-pty-perl (from …/libio-pty-perl_1%3a1.07-2build1_i386.deb) …

Selecting previously deselected package libapt-pkg-perl.

Unpacking libapt-pkg-perl (from …/libapt-pkg-perl_0.1.24_i386.deb) …

Selecting previously deselected package apt-show-versions.

Unpacking apt-show-versions (from …/apt-show-versions_0.16_all.deb) …

Processing triggers for man-db …

Setting up libnet-ssleay-perl (1.35-2ubuntu1) …

Setting up libauthen-pam-perl (0.16-2) …

Setting up libio-pty-perl (1:1.07-2build1) …

Setting up libapt-pkg-perl (0.1.24) …

Setting up apt-show-versions (0.16) …

** initializing cache. This may take a while **

Setting up webmin (1.510-2) …

Configuration file `/etc/pam.d/webmin’

==> File on system created by you or by a script.

==> File also in package provided by package maintainer.

What would you like to do about it ? Your options are:

Y or I : install the package maintainer’s version

N or O : keep your currently-installed version

D : show the differences between the versions

Z : background this process to examine the situation

The default action is to keep your current version.

*** webmin (Y/I/N/O/D/Z) [default=N] ? N

Webmin install complete. You can now login to https://numberip:10000/

as root with your root password, or as any user who can use sudo

to run commands as root.