LAMP Stack Install Ubuntu 18 04: Linux Apache MySQL and PHP

blog-image

I open up my linux box and make sure its always updated before anything by this command:

sudo apt-get update

Now we will install apache

sudo apt-get install apache2

and then y for yes

Now we will check on the firewall

sudo ufw app list

which shows all of apaches are all setup

sudo ufw app info "Apache Full"

This shows ports 80,443

Now lets allow that

sudo ufq allow in "Apache Full"

So now I am going to find the ip by this command:

ip a

Now leading to that ip in your browser will take you to the default apache page.

Now we will install my MySQL

sudo apt install mysql-server

and then y for yes and do it again when it asks

sudo mysql_secure_installation

This will ask a few questions just follow with what you would like.

After that MySQL will be all setup

sudo apt install php libapache2-mod-php php-mysql

Again just type y for yes

This will take a second but it is installing.

sudo nano /etc/apache2/mods-enabled/dir.conf

After that command you will want to see index.php and you will want to move it to the front to be the first thing it looks at.

Hit Ctrl X to get out and say yes to save. If you are having issues saving its because you did not do it as a super user.

Now restart apache

sudo systemctl restart apache2

and then check the status

sudo systemctl status apache2

and now it should show that it is active running

We are now going to create a index.php since we don’t have one

` cd /var/www/html

ls

nano index.php `

For a test I just have this put into it:

`

PHP Test

<?php echo ‘

Hello World

’ ; ?>

`

And then we just save it and check out our page which now shows Hello World.

  • Kevin Stevenson
  • Wednesday, Apr 8, 2020
View All Post