Installing Linux Apache, Mysql, PHP on Ubuntu

First off, installing Apache:

[[email protected]]$ sudo apt-get install apache2

Setting up apache2-mpm-worker (2.2.22-1ubuntu1) ...
 * Starting web server apache2                                                               apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                                      [ OK ]
Setting up apache2 (2.2.22-1ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Note the seemingly error line: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

Though it’s not an error, it recurs every time Apache is restarted. It can be fixed by editing httpd.conf

kdesudo kate /etc/apache2/httpd.conf

This file is usually empty. The error message can be fixed by adding the following to that file:

ServerName localhost

Visit http://localhost/ in any browser and you can test Apache. If installed properly, you get a default page:

It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.

Installing PHP:

sudo apt-get install php5 libapache2-mod-php5

After installing php, Apache may need to be restarted to use the new config.

sudo /etc/init.d/apache2 restart

To test PHP, create a test page:

kdesudo kate /var/www/testphp.php

OR

sudo emacs /var/www/testphp.php

Add the following contents:

<?php phpinfo(); ?>

Now, open this page: http://localhost/testphp.php

The last step is to install MySql

sudo apt-get install mysql-server

You will be asked to set up a root password. I left it blank. I was asked for the mysql root password no fewer than three times!

Next, install Phpmyadmin:

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Make sure that you choose to reconfigure Apache2 during MySql installation:

      Configuring phpmyadmin ├───────────────────────────┐      
      │ Please choose the web server that should be automatically configured to run   │      
      │ phpMyAdmin.                                                                   │      
      │                                                                               │      
      │ Web server to reconfigure automatically:                                      │      
      │                                                                               │      
      │    [x] apache2                                                                │      
      │    [ ] lighttpd                        

You get another prompt asking for a database to be configured:

 ┌───────────────────────────────┤ Configuring phpmyadmin ├───────────────────────────────┐  
 │                                                                                        │  
 │ The phpmyadmin package must have a database installed and configured before it can be  │  
 │ used.  This can be optionally handled with dbconfig-common.                            │  
 │                                                                                        │  
 │ If you are an advanced database administrator and know that you want to perform this   │  
 │ configuration manually, or if your database has already been installed and             │  
 │ configured, you should refuse this option.  Details on what needs to be done should    │  
 │ most likely be provided in /usr/share/doc/phpmyadmin.                                  │  
 │                                                                                        │  
 │ Otherwise, you should probably choose this option.                                     │  
 │                                                                                        │  
 │ Configure database for phpmyadmin with dbconfig-common?                                │  
 │                                                                                        │  
 │                         
<Yes>                            <No>          

Choose Yes.
Hit Enter twice when asked for the user and MySql app password.

Now, restart Apache:

sudo /etc/init.d/apache2 restart

You can login to Phpmyadmin by visiting http://localhost/phpmyadmin

When trying to login as root and without a password, you will be greeted by a message: “Login without a password is forbidden by configuration (see AllowNoPassword)”

To fix this,:

kdesudo kate /etc/phpmyadmin/config.inc.php

And edit the corresponding line in the file so that it reads like this:

$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

by uncommenting the line from the following block:

    /* Uncomment the following to enable logging in to passwordless accounts,
     * after taking note of the associated security risks. */
    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

Now you will be allowed to login as root without a password.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.