• Increase font size
  • Default font size
  • Decrease font size

Install Apache, PHP, MySQL, & phpMyAdmin in Ubuntu

E-mail Print


Apache - Apache web server is the most widely utilized web server in the world and most of the world's websites are served on Apache web servers. Apache development is run by the Apache Software Foundation, which is a community of software developers. Apache is released with an open-source software license.

There are releases of Apache that can run on most operating systems including Unix, Linux, Windows and Apple to name a few. Most often Apache is run on Linux web servers. The website is hosted on an Apache webserver, using shared webhosting. Shared webhosting utilizes Apache's ability to host multiple websites on one web server, called virtual hosts.

PHP - is a programming or scripting language that is typically installed on a web server, but it can also be installed on an end user computer system. It is one of the most popular scripting languages to install on web servers in order to create dynamic web content. It is called a server-side scripting language in that the PHP code is interpreted by the web server, and html content is generated, and sent to the user's web browser. The PHP code is interpreted and executed by the PHP engine or interpreter which is often installed as a module in the web server. PHP is very useful for retrieving and sending data to and from relational databases like MySQL. PHP is freely distributed software and has available releases for most major operating systems. PHP is a competitor with other server-side programming languages, like Microsoft's Active Server Pages (ASP) and Sun's JavaServer Pages (JSP).

MySQL - MySQL is currently the most popular relational database management system (RDBMS) in the world. MySQL functions as a database server that allows users to connect to its stored databases. MySQL is open-source software released under the GNU public license (GPL). MySQL is used in conjunction with many popular web applications and content management systems like Joomla (this website), WordPress, and Drupal to name only a few.

PhpMyAdmin - is a graphical, browser-based management interface, for working with MySQL. PhpMyAdmin is an open-source project written in PHP. PhpMyAdmin can make managing MySQL databases more intuitive, and easier to learn.


Installation Steps

  1. Open a terminal

  2. Type in the following command to install Apache:
    sudo apt-get install apache2

  3. To check to see if Apache is running open Firefox and type in the following web address:
    http://localhost   or,
    You should see the message, "It Works!" This is the Apache homepage, the index.html file and it means the server has installed correctly and is currently running.

  4. If you didn't see "It Works!" try starting the server. The commands to start, stop and restart Apache are:
    sudo /etc/init.d/apache2 start
    sudo /etc/init.d/apache2 stop
    sudo /etc/init.d/apache2 restart

  5. Go to the Apache web directory (i.e. where you put your webpages and websites) and look for the index.html file. Type in the following commands:
    cd /var/www/
        In Mint 17 the directory is:
          cd /var/www/html

    You should see the index.html file listed in the directory

  6. Open the index.html file, edit it and save it. Type in the following command:
    sudo gedit index.html
    Edit the file by personalizing it, and save:
    <html><body><h1>Your Name's Website</h1>
    <p>Hello everyone, this is my homepage!</p>
    <p>I will update this page soon.</p>

  7. Refresh the web page in Firefox to see your changes. You now have an Apache web server running on your local computer and you know how to add/edit webpage content. Time to learn HTML, XHTML, and CSS... :-)

  8. To install PHP5 and the Apache library/module for PHP type in the following command:
    sudo apt-get install php5 libapache2-mod-php5

  9. Once PHP has been installed restart Apache. Type in the following command:
    sudo /etc/init.d/apache2 restart

  10. Now we need to test PHP by writing a PHP file and calling the phpinfo function. Type in the following command to create a php text file and open it in gedit:
    sudo touch /var/www/test.php
    sudo gedit /var/www/test.php

    In Mint 17 the command and directory is:
           sudo touch /var/www/html/test.php

  11. In Gedit type in the following lines and then file > save:
    <?php phpinfo(); ?>
  12. Open your Firefox browser and put in the following web address:

  13. If PHP is working you should see a long page of information about the installed version of PHP and its configuration parameters.

  14. Now to install MySQL server. Type in the following command:
    sudo apt-get install mysql-server
    During the installation you will be prompted to enter a password for MySQL root user, do so and hit the Tab key to highlight the <Ok> button and press enter. If you leave the password blank you can always enter it later by typing the following command:
    mysql -u root
    mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

  15. Once you have MySQL installed you will want to install the phpMyAdmin tool as an easy interface to working with MySQL. Type in the following command:
    sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
    During the installation you may need to choose Apache2 to be the database associated with MySQL and phpmyadmin. Make sure Apache2 is selected and tab, click enter
    During the installation you may need to choose 'yes' to have 'dbconfig-common' handle the database configuration for you. Choose yes and hit enter. You will be prompted twice for your MySQL root user password.

  16. Create a symbolic link from phpMyAdmin to the Apache www directory. Type in the following command:
    sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

    In Mint 17 the command and directory is:
    sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

  17. Now put the following web address in Firefox:
    You should see the phpMyAdmin login page, but if you get an error page instead, then restart the Apache webserver, and refresh the webpage in the web browser:
    sudo /etc/init.d/apache2 restart 
  18. Refresh http://localhost/phpmyadmin in your browser to get to the phpMyAdmin login page. Type in the user field as 'root' and the password you set during the installation process and log in. Cheers!


Video Tutorial

In this video I download, install, and run Apache web server in Ubuntu

In this video I install PHP to an Apache web server in Ubuntu

In this video I install MySQL and PhpMyAdmin to an Apache web server in Ubuntu


If you choose advanced configuration option you may need to configure php to work with MySQL by editing the php.ini file:

sudo gedit /etc/php5/apache2/php.ini
Uncomment the following line by removing the semicolon:
; (to)
Also people report missing the "y" like this:
; (to)

sudo /etc/init.d/apache2 restart


If you choose to have your MySQL server on a network you may need to edit the bind-address. To do that type the following commands to edit the my.cnf file:
      sudo gedit /etc/mysql/my.cnf
Change the following line to your ip address:
      bind-address =


Last Updated on Wednesday, 11 February 2015 10:51

Cracking Hashes with Rainbow Tables and Ophcrack

E-mail Print

You may have heard of dictionary password attacks or brute force attacks but recently a popular way of cracking a Windows password uses a rainbow table. This method was made popular by Philippe Oechslin one of the creators of the program Ophcrack a tool for cracking Windows passwords.

You can use Ophcrack in a few different ways. Firstly, you can download the Ophcrack program and run it on your computer. Used this manner you will need to download the tables separately, save them to your hard drive, install them into the Ophcrack program, and then run the program which compares the hashed password to the hashes in the rainbow table searching for a match. Secondly, you can download an Ophcrack LiveCD .iso file, burn it as a bootable image, and booting to the CD use it to search for a system's password by comparing hashes in a similar manner. In this method the CD loads the password hashes directly from the Windows SAM (security accounts manager) files. This can be helpful for someone who has forgot their password, and needs to recover it. However, you do not want to use this method to attack a user's computer. You can download XP, and Vista / Windows 7 versions of Ophcrack.

Ophcrack website: (download)
About Ophcrack:

Hash functions:  

Network Authentication Protocols (one aspect of these protocols is to turn clear text passwords into a hash)

  • Windows LM hash (Lan Manager ) a flawed implementation based on DES, which was particularly easy to crack:
  • Windows NTLM (NT Lan Manager) - little to no improvement over LM hash partially due to backwards compatibility issues allowing the LM hash along with the NTLM hash;
  • Windows NTLMv2 - an improvement is still used in Windows Vista and Windows 7 in work group environments
  • Kerberos - Open Source project, MIT - Secure network authentication protocol used in Windows Domains and Active Directory;

Ophcrack step by step

  1.  When I installed the program I installed it to my Program Files folder so consequently it was not able to automatically download any rainbow tables. No matter, you can download the tables and install them after installing the program. Go to the website click on tables and download the free tables or just click here to go there directly: I downloaded the xp free small and the Vista free tables. Once you have downloaded the tables you will need to unzip them in separate folders. I made a folder called "hash-tables" and then made 2 more folders within for each table to unzip to. 
  2. Run the program and click on "Tables" button. Select the table you downloaded and click "Install", navigate to the folder where you unzipped the table, select it and then click "ok." You should see green lights next to the tables you installed.
  3. You need to supply the program with a hash for it to try and crack. For testing purposes you can generate one at this website. Go to scroll to the bottom of the page and submit a password using the web tool. The tool will output a hash that you can copy to a text file or copy to memory by selecting and pressing (Ctrl+C).
  4. On the website, I submitted the password "BlockMe" with the capital letters and I got the hash output: 9d79790fa072b69baad3b435b51404ee:facbe3fa7932e0d024590e0633d28510 
    On the Ophcrack program I clicked "Load" > "Single hash", pasted in the hash, clicked "ok", and then clicked "Crack" to start the process. It took a few minutes but Ophcrack was able to crack the password, from the hash, with the "XP Small Free" table installed and loaded into Ophcrack. I also installed the "Vista free" table but that must have been a non matching table to hash because it was unable to crack the password. One thing I learned was that you need the right kind of table to crack the right kind of hash.

  5. I want you to play with the program get it working and test out 5 different passwords of increasing complexity. Can you find a website that will generate a Vista NTLMv2 hash? 
  6. Post your experience and results using Ophcrack, in a comment at the bottom of this page.
    Note: You have to have a user account in order to login and post comments. You can create a user account on this site by going to the home page, or by clicking here.

Video Tutorial



Configure a DHCP Server in Ubuntu 11

E-mail Print

Installation and Configuration

To install dhcp server on Ubuntu 11.10 open a terminal (Dash Home > search "terminal") and follow these steps and terminal commands:

  • sudo apt-get update (update your repositories)
  • sudo apt-get install dhcp3-server (installs dhcp server - after the installation, Linux will try to start the server and it will fail to start, because the server has not been configured yet)
  • Next you need to edit the dhcp configuration file. Put in the following commands to edit in gedit or nano:
    sudo gedit /etc/dhcp/dhcpd.conf
    sudo nano /etc/dhcp/dhcpd.conf

  • In gedit go to Edit > Preferences > and checkmark "display line numbers." Now you can see line numbers as a reference. In the conf file any line that begins with a "#" character has been commented out. Meaning it does not effect the server. The lines that do not begin with "#" have been uncommented and are active configurations for the dhcp server. To configure your dhcp server you will want to uncomment and alter the following lines in the conf file:

    Lines 38  through 46 make the following changes and remove the "#" comment from the beginning of the lines:

    subnet netmask {
        option domain-name-servers;
        # option domain-name "myDomain.local"
        option routers;
        option broadcast-address;
        default-lease-time 600;
        max-lease-time 7200;

    Save the file and close.
    The example above would work on the Linux network in my classroom lab, where all the linux machines are on a network, the addresses to be handed out are were specific to the user (e.g. Daniel handed out the range to, the router is, there is no local domain/domain controller, and the DNS server is Google's
  • Now you need to restart your DHCP server. Type in the following commands:
      sudo /etc/init.d/isc-dhcp-server restart
  • If you want to check to see if your DHCP server has leased any ip addresses type in the following command:
        sudo tail /var/lib/dhcp/dhcpd.leases
    and you should see information if any computer has picked up an ip address!



Video Tutorial

In this video, I install and configure DHCP server in Ubuntu, and then lease an IP address to a client on the network

Notes on troubleshooting

  • On my dhcp server when I restarted, it failed. Bummer.
  • For my dhcp server, I used a laptop with both a wireless ethernet card and a wired ethernet card. Following the online example I used the line  INTERFACES="wlan0 eth0" in the dhcp3-server file, which seemed logical. However, I have enough experience to know that the network cards could be recognized differently by the operating system, so I used the following command in order to check my network configuration:

    and I could see that my system had recognized my network cards as "eth0" and "eth1", with eth1 being the active interface. So I changed my configuration to  INTERFACES="eth1", restarted my server and it worked!
  • I put this tutorial together, using the following web page as my reference:
  • In my example, in order to test my Ubuntu DHCP server, I logged into my linksys wireless router, disabled the dhcp server on the "basic setup" page, and from another Windows computer on the network, released and renewed my ip address with an "ipconfig /release" and an "ipconfig /renew". Afterward, I ran the "ipconfig /all" command a couple times and I noticed I had successfully pulled an ip address from my Ubuntu server and had internet connectivity! If I had been on another Ubuntu computer I could have restarted my network interface cards or used the following commands to restart my network interfaces:
    ifconfig eth0 down
      ifconfig eth0 up

      The example infers my active interface is eth0, otherwise use eth1, wlan0, etc..


Last Updated on Friday, 09 January 2015 02:01

Install & Configure the BIND DNS Server

E-mail Print


BIND also known as NAMED is the most widely used DNS server software in the world. The Berkeley Internet Name Domain (BIND) is  domain name server software that can run on Linux, Unix, and Windows computer operating systems. 

Command Steps

1. Make sure you have internet connectivity and install the BIND DNS server.
yum install bind

2. Set your DNS server setting to resolve to your loopback interface by echoing to /etc/resolv,.conf or by editing your your outside interface configuration file (example: ifcfg-eth0) adding the line: DNS1=, and taking the interface down and up again (ifdown eth0, ifup eth0). The benefit to ediing the ifcfg file and then bringing the interface down and up again is that the confguration will be permanent, whereas echoing to resolv.conf is not a saved configuration. Once you set the DNS server setting to you will lose internet connectivity until you restart BIND.
echo "nameserver" > /etc/resolv.conf 
vim /etc/sysconfig/network-scripts/ifcfg-eth0
add the following line to the configuration file: DNS1=
ifdown eth0
ifup eth0

3. Check the resolve.conf file to verify that your DNS setting of is available.
cat /etc/resolv.conf

4. Restart the BIND DNS server. The BIND DNS server is referenced by command as "named"  pronounced "name - d", the name daemon.
service named restart 

5. Now try to see if your DNS server can reach other DNS servers over the internet in order to resolve dns lookups.

Troubleshooting - If you get a "server can't find SERVFAIL" message you can try these troubleshooting scenarios:
1) If you are using VMware virtual machines try shutting down your Windows firewall
2) Make sure your iptables is accepting traffic on the loopback interface. Use the iptables-save command and you should see the following line: -A INPUT -i lo -j ACCEPT . If not, you can add it directly to the iptables configuration file by editing /etc/sysconfig/iptables. Then restart iptables: service iptables restart
3) Also, check that you have the right date set on your system. Use the
date command to check the date and timestamp. You can fix it with the following command: date -s 'year-month-date time' (e.g. 2012-4-23 12:10:00). I experienced DNS server nslookup failure due to incorrect date.
4) If you still have problems and are unable to resolve domain names using nslookup then try looking at your log files: tail /var/log/messages

6. Now put in a chkconfig command to allow BIND (NAMED) to start on system startup.
chkconfig named on

7. Before you begin configuring the DNS server you should know what your hostname. You were asked to create your hostname (computer name) during your CentOS linux installation. Your hostname follows your username and the "@" symbol in your terminal command prompt. For instance, my terminal shows the following prompt [dan@centos-server ~]$, "dan" is the username, "centos-server" is the hostname, " ~ " refers to my current directory - which is home, and the "$" prompt means I am in user mode as "dan" (a # would mean I am currently the root user). To verify your hostname type the command hostname in the terminal and hit enter.

You can temporarily change the hostname by issuing the hostname command. However this will not be permanent upon restart.
hostname <example-server-name>

To permanently change the system hostname even upon reboot, edit the following file in a text editor: /etc/sysconfig/network
nano /etc/sysconfig/network
and add the following line after NETWORKING="yes":

8. Beyond knowing the server hostname, to use the full potential of the DNS server you will also need to know your fully qualified domain name (FQDN). You will probably need to configure your servers FQDN. To do this you will need to edit the configuration file of your outside facing network interface using a text editor, in my example the file is ifcfg-eth0.
nano /etc/sysconfig/network-scripts/ifcfg-eth0

and add your domain name by adding a line to the configuration file:

then take the interface up and down. Check to see if the change is reflected in the /etc/resolv.conf file, and the run the hostname --fqdn command to see your FQDN. The FQDN should be your server hostname followed by a dot and your domain name (e.g. If your computer does not recognize your fully qualified domain name (fqdn), just keep going, the server should recognize the FQDN by the time you have finished configuring the DNS server conf file and zone files.
ifdown eth0
ifup eth0
cat /etc/resolv.conf
hostname --fqdn

9. Now that your hostname and fully qualified domain name are configured it is time to configure the BIND (NAMED) DNS server.The first file to configure is: /etc/named.conf
nano /etc/named.conf

10. Now you can add master lookup zones to the named.conf file like the entries in my example below. I inserted the two zones right before the line ( zone "." IN { ). The first zone is for forward lookups and the second zone is for reverse lookups. Forward lookups resolve names to IP addresses and reverse lookups resolve ip addresses to names. Make sure to substitute your own domain name and the network portion of your IP address in reverse (outside interface).

 zone "" IN {
     type master;
     file "";
     allow-update { none; };

 zone "" IN {
     type master;
     file "";
     allow-update { none; };

11. You can see in the two zones above that the third line in each zone references a file ( and You will need to create two text files, one to match each of those names, and save them in the /var/named/ directory.
touch /var/named/
touch /var/named/

12. Now you will need to edit and save each file with zone configurations. Make sure to substitute your own domain name and IP address (outside interface). First, the forward lookup zone file.
nano /var/named/

$TTL 86400
@    IN    SOA (
            2001062501 ; serial                    
            21600      ; refresh after 6 hours                    
            3600       ; retry after 1 hour                    
            604800     ; expire after 1 week                    
            86400 )    ; minimum TTL of 1 day            
    IN    NS    dns1.
    IN    MX    10    mail.

    IN    A

dns1    IN    A

example-server-hostname    IN    A

ftp    IN    A

mail    IN    CNAME   

www    IN    CNAME   

13. Second, the reverse lookup zone file.
nano /var/named/

$TTL 86400
@    IN    SOA (
            2001062501 ; serial                    
            21600      ; refresh after 6 hours                    
            3600       ; retry after 1 hour                    
            604800     ; expire after 1 week                    
            86400 )    ; minimum TTL of 1 day            

@    IN    NS
1    IN    PTR

2    IN    PTR

3    IN    PTR

4    IN    PTR

14. Now restart your server and try resolving your domain names with nslookup. You should see that they resolve to your server!!!
service named restart

Video Tutorials

In part 1, I install and troubleshoot the BIND (named) DNS Server in CentOS Linux


In part 2, I set the hostname, domain name, and edit the named.conf configuration file


In part 3, I configure the master forward and reverse lookup zones


Last Updated on Thursday, 12 September 2013 11:07

Page 11 of 16

Pearson Education (InformIT)