Install Apache, PHP and MySQL on Ubuntu 14.04

Install Apache, PHP and MySQL on Ubuntu 14.04

Michele Alexander Wittmann 28. July 2014 Expert Topics

0 Comments // Reading Time: 4 min.

What is the Apache web server?

The Apache HTTP Server Project is part of the Apache Software Foundation and is jointly managed by a group of volunteers around the world. In addition to this group, many users have contributed to the project with their codes, ideas and documentation. The scope of use of the Apache web server is very extensive. It is used by large as well as small companies, research institutes, schools and many more.

Field of application of Apache

The most basic task of the Apache HTTP Server is to process and respond to a request from a web browser about a file, such as an image. 

Over time, many other functions have evolved around this basic function:

  • Managing and checking permissions
  • Reactions to errors
  • Adaptability of different languages (localization)
  • Support of media file formats
  • Cache of frequently requested information for faster access. (proxy function)
  • Support of security protocols (HTTPS, SPDY, ...)

These were just some of the features that have been added.

Install the Apache

First you need a terminal with root privileges. Open the console and enter the following:

sudo -s

Confirm the command with your administrator password. In the console you now have root rights. You can omit the annoying "sudo" for all following commands you enter.

The installation of Apache is very simple and uncomplicated via the command:

apt-get install apache2

Confirms the installation of Apache2 with "J".

By entering "localhost" in your browser you can check immediately after the installation if your webserver is running.

You should get the following picture:

If the server doesn't work, it might help if you try to start the server manually by typing :

service apache2 start

Do you want to talk to web development specialists at eye level?


In the directory "/var/www/" are the (HTML/PHP-) files which should be called later via the browser. Since this directory is only writable with root rights, you now change the owner of the directory "www" with this command:

chown -R [USERNAME] /var/www

Instead of [USERNAME] your valid username must be entered in lower case letters. You can find out the current user by leaving "root" via "exit" and then executing "id". Then login again with "sudo -s" as root.

Install PHP module

PHP ("PHP: Hypertext Preprocessor", originally "Personal Home Page Tools") is a popular server-side programming language. So that you can use it on the server, the PHP Apache module must be installed next. Enter the following command in the console:

apt-get install php5

The installation must be confirmed again with "J".

If you enter the following command, the server will be restarted. Then the new PHP module can be recognized and loaded (files with the extension .php are recognized and executed by PHP only after the restart).

service apache2 restart

Install MySQL and create a database

By entering the following command you install the MySQL ("My Sequential Query Languge") database. This is used by web applications, for example via PHP.

MySQL is used by various applications on the web to store data in a relational form in various fixed tables. With the powerful and standardized Structured Query Language (kury SQL) you can read them again.

apt-get install mysql-server

As soon as the installation reaches its end you have to set a password for MySQL.

PHP and MySQL cannot communicate with each other until a connection has been established between them. This is done by installing the package "php5-mysql".

apt-get install php5-mysql

Like after installing the PHP module, you have to restart the server so that the changes are applied.

service apache2 restart

You can create new databases by typing

mysql -u root -p

and enter the previously set password into the MySQL database server. Now you are in the MySQL command line.

New databases are easy to create:

create database DATABASENAME;

These can be used later by PHP.

To delete created databases, use the following command:

drop database DATABASENAME;

In general the usual MySQL commands are used in the MySQL command line.

With "exit" you leave the MySQL command line and return to the normal shell.

Control the web server

service apache2 start
service apache2 restart
service apache2 stop

Start, restart and stop. It is important that you still need root rights for the commands or that you enter "sudo" before the commands.

Since the web server starts automatically when Ubuntu starts, this does not have to be done manually.

In a coming article I will show you how to install and configure TYPO3 on this stack.

Contact us!

We are a digital agency headquartered in Munich/Unterföhring, which works remotely worldwide. We are specialized in the development of digital products. Our core topics are websites and portals with TYPO3, eCommerce with Shopware and Android and iOS-Apps. In addition, we deal with many other topics in the field of web development. Feel free to contact us with your concerns!


No comments.
    Drop files here