How to install Apache, MySQL, PHP and PhpMyAdmin in Linux Mint from command line?

I am a great fan of Linux Mint. It’s Ubuntu based. I have been using Linux Mint for the past three years. Recently, I migrated to the latest version – Linux Mint 9 codenamed ‘Isadora’.  The default installation of the desktop edition of Linux Mint 9 does not install Apache, MySQL and PHP. Therefore, I decided to write a post that would be useful for other fellow readers, users of Linux Mint 9 detailing how to install Apache, MySQL and PHP on Isadora.

The installation can be divided into multiple steps.

  1. Install the core packages – Apache2, MySQL and PHP.
  2. Test if the web server is up and running.
  3. Test if PHP is working.
  4. Install PhpMyAdmin.
  5. Test MySQL (via PhpMyAdmin).


Step 1: Issue the below command to install Apache2, MySQL and PHP.

sudo tasksel install lamp-server

During the course of installation, the install wizard will prompt you for the password for the MySQL Administrative ‘root’ user. Key-in your desired password.

The install continues after the password prompt.

The installation proceeds with installing ‘apache2.2-common’.


Step 2: Test if the web server is up and running.

To test if Apache2 is working and ready to serve web pages, open your browser and key-in ‘localhost‘ in the address bar and press the ‘Enter’ key. It should open a webpage with information similar to the below image.


Step 3: Test if PHP is working.

To confirm if PHP is configured and working as expected, create a new file named ‘test.php’ in ‘/var/www‘ folder. Insert the below line in the newly created ‘test.php’ file:

<? php phpinfo(); ?>

Open your browser and key-in ‘localhost/test.php’ in the address bar and press ‘Enter’ key. This would display a webpage similar to the image below.


Step 4: Install PhpMyAdmin

Issue the below command on the terminal to install PhpMyAdmin.

sudo apt-get install phpmyadmin

The install kicks-in and may display some output on the terminal windows as portrayed by the image below.

During the course of installation, the install wizard will display a screen similar to the image below which allows the user to choose the right web server installed in the system.

Choose ‘apache2’ on the ‘Configuring phpmyadmin’ install screen as portrayed below and choose ‘<Ok>’.

PhpMyAdmin requires access to the database so that it can configure itself for access it later. Therefore, the install wizard display the below screen. Choose ‘<Yes>’ and continue.

Since we choose ‘<Yes>’  in the previous screen, PhpMyAdmin install wizard will prompt for the MySQL administrator password. Enter the password and choose ‘<Ok>’.

The next screen will ask for the PhpMyAdmin password. Please key-in a valid password and choose ‘<Ok>’.

The install wizard will display password confirmation dialog where the password entered in the screen portrayed above should be retyped.

The installation will proceed as usual and restart the ‘apache2’ web server daemon during the final stage of the installation. This signifies that the installation of PhpMyAdmin has completed successfully.


 

Step 5: Test MySQL (via PhpMyAdmin)

To confirm that PhpMyAdmin is installed successfully and configured to connect the MySQL database server, open the below mentioned URL in your browser.

This URL will open a webpage similar to the one portrayed in the image below.

Key-in the user name and password to access the MySQL database web server. Since no users other than ‘root’ is configured to access MySQL database web server, enter the user name as ‘root’ and the associated password and click the ‘Go’ button. This will open the PhpMyAdmin web interface as portrayed by the image below.

That’s it. Apache2, MySQL, PHP and PhpMyAdmin are successfully installed and configured on your system.


Resources:

6 thoughts on “How to install Apache, MySQL, PHP and PhpMyAdmin in Linux Mint from command line?

  1. thanks you!
    i just want to add 2 things :
    before step 3, I had to restart apache:
    sudo /etc/init.d/apache2 restart

    After installing phpmyadmin, I had 404 error.
    So I needed to add “Include /etc/phpmyadmin/apache.conf” in the file “/etc/apache2/apache2.conf”
    And restart apache again

Leave a reply to whynnot Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.