Categories: LAMPUbuntuUbuntu Feed

Install LAMP On Ubuntu 15.04

Like in older version of Installing LAMP on Ubuntu 13.xx 14.xx there aren’t any major changes (except if you are using MySQL instead of MariaDB, in that case you change one keyword and, of course, our lovely systemd ) anyway, I will demonstrate the commands and procedures you need to  Install LAMP Stack On Ubuntu 15.04 .

As stated before, LAMP is acronym for Linux Apache MySQL and PHP. Now in our days it’s also MariaDB instead of MySQL or LAMPP, meaning Linux Apache MariaDB(MySQL) Php and PhpMyAdmin. Let’s begin.

Install LAMP On Ubuntu 15.04

1. Install Apache

Sponsored

Apache httpd is our web server. It provides a full range of web server capabilities including CGI, SSL and virtual domains.

To install Apache, type:

sudo apt-get install apache2

or exclude sudo if your are already root, but really it doesn’t matter a lot.

Testing Apache:

Open your web browser and navigate to http://localhost/ or http://server-ip-address/. You don’t know your local IP address because of dhcp ?

Try

ifconfig

or

ip addr

 

2. Install MySQL

MySQL is our relational database management system (RDBMS). There are also other choices like PostgeSQL, Firebird, Percona, but here we deal with the ..famous one, Mysql (and MariaDB eventually)

sudo apt-get install mysql-server mysql-client

During installation, you’ll be asked to setup the MySQL “root” user password. Enter two times a root password and it will be OK. Care, it’s not your system’s root password, it’s MySQL’s admin password. No need for the same password.

You can verify the MySQL server status using command:

On Ubuntu 15.04:

sudo systemctl status mysql

On Ubuntu 14.10 and previous versions:

sudo service mysql status

Sample output:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2015-05-22 14:37:29 IST; 7s ago
 Main PID: 3740 (mysqld_safe)
   CGroup: /system.slice/mysql.service
           ├─3740 /bin/sh /usr/bin/mysqld_safe
           └─4087 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --...

May 29 14:38:18 server systemd[1]: Starting MySQL Community Server...
May 29 14:38:18 server mysqld_safe[3740]: 150429 14:38:18 mysqld_safe Can't ...
May 29 14:38:18 server mysqld_safe[3740]: 150429 14:38:18 mysqld_safe Loggin...
May 29 14:38:18 server mysqld_safe[3740]: 150429 14:38:18 mysqld_safe Starti...
May 29 14:38:19 server systemd[1]: Started MySQL Community Server.

3. Install MariaDB

In case you want to use MariaDB instead of MySQL community edition, follow the steps below.

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

First you have to remove existing MySQL packages. To completely uninstall MySQL along with its configuration files, enter the following commands one by one:

sudo systemctl stop mysql
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql/
sudo rm -rf /etc/mysql/

After removing MySQL, run the following command to install MariaDB.

sudo apt-get install mariadb-server

Alternatively, you can install it using MariaDB repository if you want to try most recent version of MariaDB. Run the following commands to add PPA. As of writing this, MariaDB PPA is not yet updated to Ubuntu 15.04. However, we can use the repository of Ubuntu 14.10 instead.

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.kaist.ac.kr/mariadb/repo/10.0/ubuntu utopic main'

Update the software sources list and install MariaDB using following commands:

sudo apt-get update
sudo apt-get install mariadb-server

During installation you will be asked to set mysql ‘root’ user password. Enter the password twice, and complete the installation.

Note: In Ubuntu 15.04, MariaDB won’t ask you to set root user password during installation.

Also, you can’t set password using command:

mysql_secure_installation

It will throw the following error.

Sponsored
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

To fix this error, log in to mysql prompt without password as root user:

sudo mysql -u root

Then, run the following commands one by one in the mysql prompt:

use mysql;
update user set plugin='' where User='root';
flush privileges;
q

That’s it. Now, set database administrative “root” user password using command. Press Enter and go with the default settings.

mysql_secure_installation

Check if mariadb is running or not, using the following command:

sudo service mysql status

 

4. Install PHP

PHP (acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

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

To test PHP, create a sample “phpinfo.php” file in Apache document root folder.

sudo nano /var/www/html/phpinfo.php

Add the following lines.

<?php
phpinfo();
?>

Restart apache2 service.

On Ubuntu 15.04:

sudo systemctl restart apache2

On Ubuntu 14.10 and lower versions:

sudo service apache2 restart

Navigate to http://server-ip-address/phpinfo.php. It will display all the details about php such as version, build date, modules used, paths and commands etc.

5. Manage MySQL Databases (Optional)

Install phpMyAdmin

phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases. It is available in the Official Debian repositories. So install it with command:

sudo apt-get install phpmyadmin

Select the Web server that should be automatically configured to run phpMyAdmin. In my case, it is apache2.

Additional Note: if you followed all steps carefully, phpMyAdmin should work just fine. In case phpMyAdmin is not working, please do the following steps.

Open terminal, and type:

sudo nano /etc/apache2/apache2.conf

Add the following line at the end.

Include /etc/phpmyadmin/apache.conf

Save and Exit. Restart apache service:

On Ubuntu 15.04:

sudo systemctl restart apache2

On Ubuntu 14.10 and lower versions:

sudo /etc/init.d/apache2 restart

6. Access phpMyAdmin Web Console

Now, you can access the phpmyadmin console by navigating to http://server-ip-address/phpmyadmin/ from your browser.

The post Install LAMP On Ubuntu 15.04 appeared first on NixPal.

Ubuntu Server Admin

Recent Posts

Building RAG with enterprise open source AI infrastructure

One of the most critical gaps in traditional Large Language Models (LLMs) is that they…

15 hours ago

Life at Canonical: Victoria Antipova’s perspective as a new joiner in Product Marketing

Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…

2 days ago

What is patching automation?

What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…

3 days ago

A beginner’s tutorial for your first Machine Learning project using Charmed Kubeflow

Wouldn’t it be wonderful to wake up one day with a desire to explore AI…

4 days ago

Ubuntu brings comprehensive support to Azure Cobalt 100 VMs

Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…

4 days ago

Ubuntu Weekly Newsletter Issue 870

Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…

4 days ago