How To Install Apache2 + Mysql + PhpMyadmin on Ubuntu

Люба х...ня

Continuing the Ubuntu topic. If you are reading this post, you probably have already Ubuntu on your computer. To begin with, I want to emphasize that we don't install a LAMP server, but install and set up each element separately. 

Ubuntu Apache2+php5+mysql+phpmyadmin

Remember to issue sudo command (sudo su -) to follow all the steps below.  

Install Apache 2

apt-get install apache2

Configure Apache2

nano /etc/apache2/apache2.conf

## Fix the warning when restarting Apache
ServerName localhost

## Enable php
AddType application/x-httpd-php .php .phtml

## Set up UTF-8 encoding
AddDefaultCharset UTF-8

Restart Apache

service apache2 restart

Open http://localhost/ and enjoy.

Set up virtual hosts (VirtualHost)

Write in the hosts /etc/hosts (nano /etct/hosts)

127.0.0.1    mysite.loc

Go to “/etc/apache2/” directory

Take a look what's inside:

root@HP:/etc/apache2# ls -l
total number 88
-rw-r--r-- 1 root root  7728 кві 26 22:55 apache2.conf
-rw-r--r-- 1 root root  7691 кві 26 22:34 apache2.conf~
drwxr-xr-x 2 root root  4096 кві 26 22:52 conf-available
drwxr-xr-x 2 root root  4096 кві 26 22:52 conf-enabled
-rw-r--r-- 1 root root  1782 січ  3 16:48 envvars
-rw-r--r-- 1 root root 31063 січ  3 16:48 magic
drwxr-xr-x 2 root root 12288 кві 26 22:27 mods-available
drwxr-xr-x 2 root root  4096 кві 26 22:27 mods-enabled
-rw-r--r-- 1 root root   320 січ  7 15:23 ports.conf
drwxr-xr-x 2 root root  4096 кві 26 22:43 sites-available
drwxr-xr-x 2 root root  4096 кві 26 22:44 sites-enabled

In the “sites-available” directory you'll find configurations of the available hosts and in the “sites-available” directory, there are links to active hosts.

Go to available hosts and create a configuration file for mysite.loc. By the way, if you default configuration file ends with .conf then create new configuration files with *. conf extension.

nano sites-available/mysite.conf

There we write:


    ServerName mysite.loc
    DocumentRoot /var/www/mysite.loc
    
        AllowOverride All
    

This is enough to get your local host working. Now, you need to create a link to it in the "sites-enabled" directiry:

  a2ensite mysite.conf

Mind the trap: if you get an error and you can't create a link, you can fix it this way:

ln /etc/apache2/sites-available/mysite.conf /etc/apache2/sites-enabled/

Now, you just need to reload the Apache2 configurations:>

service apache2 reload
##or if necessary
service apache2 restart

So Apache2 is working, the first host has been added.

Install MySQL

MySQL is available in the Ubuntu repositories. It is divided into several packages.

To install the MySQL server, run the following command:

sudo apt-get install mysql-server

The configure script will ask a user for an admin password (root) of the database. 

To install the MySQL module, run the following command:

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

Install PhpMyadmin

apt-get install phpmyadmin

Configure it to your needs: point out that you use Apache2, write the database password and the phpmyadmin password.

Trap: http //localhost/phpmyadmin not found ubuntu

Solution:

nano /etc/apache2/apache2.conf
## add it at the end of the file
Include /etc/phpmyadmin/apache.conf

In addition, there's a video.

If you've done everything right, you'll have a configured ready-to-use
local server. Good luck!

Let’s fill the brief, shall we?