Table of Contents
Was this article helpful?

1  out of  1 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

How to Install Apache, MySQL and PHP on Ubuntu 18.04

Last Updated: Tue, Jan 5, 2021
Linux Guides MySQL and MariaDB PHP Popular Ubuntu Web Servers

Install Apache

First, update your package manager.

sudo apt-get update -y
sudo apt-get upgrade -y

Install and start Apache.

sudo apt-get install apache2 -y
sudo systemctl start apache2.service

Verify that Apache was installed without errors by accessing it from your local browser. Enter hostname -I to obtain your IP address for the server and navigate to http://SERVER_IP/. You will see the default Apache2 page.

Install MySQL

Install the MySQL database server.

sudo apt-get install mysql-server -y

Then, run the mysql_secure_installation.

sudo mysql_secure_installation

You will be asked to set a password, followed by some other questions. Enter a secure password and then press ENTER to select the defaults.

Install PHP

First, install PHP.

sudo apt-get install php -y

Then install common PHP extensions such as gd, mysql and so forth.

sudo apt-get install php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y

Starting Apache and MySQL on boot

This is necessary to start your web environment on boot.

sudo systemctl enable apache2.service
sudo systemctl enable mysql.service

Finally, restart Apache to allow PHP to run.

systemctl restart apache2.service


Congratulations, you've successfully installed a LAMP stack on your Ubuntu 18.04 VPS.

Want to contribute?

You could earn up to $600 by adding new articles