How to Install Apache & MySQL Server on Ubuntu 20.04.3

in ubuntu •  4 years ago  (edited)

Install Ubuntu 20.04.3

Tested: 16/01/2021

I'm writing this as a self reference guide and to assist anyone trying to install Apache and MySQL on Ubuntu.

1 - Check for Ubuntu Updates:

sudo apt update

2 - Install any updates (Y to confirm any upgrades/additional disk space):

sudo apt upgrade

[often best to reboot after any upgrades]

3 - Install Apache (Y to confirm additional disk space)

sudo apt install apache2

4 - Install MySQL Server (Y to confirm additional disk space)

sudo apt install mysql-server

5 - Secure the MySQL Server Deployment: https://dev.mysql.com/doc/refman/8.0/en/mysql-secure-installation.html

sudo mysql_secure_installation

*in this example we type "No" to avoid any password requirement issues. You can adjust after if required.

6 - Set root MySQL password:

type password & confirm

7 - Remove Anoymous Users:

Y [type Y]

8 - Disallow remote root login: [might be required in production environment]

Y [Type Y]

9 - Remove "test" database:

Y [Type Y]

10 - Reload privileges

Y [Type Y]

11 - Install PHP Module for Apache & PHP Module for MySQL:

sudo apt install php libapache2-mod-php php-sql

[Y for additional disk space to be used when installing]

12 - Verify PHP Installed:

php -v

[should see PHP 7.4.3]

13 - Verify MySQL Installed:

mysql --version

[should see 8.0.22]

14 - Apache directory is "/etc/apache2":

cd /etc/apache2

15 - List apache directory ["ls"]:

*this will list the directory contents including apache2.conf file and your "sites-available" and "sites-enabled" directories.

16 - Change directory into "available-sites":

cd /etc/apache2/sites-available

*"ls" will list .conf files. We are interested in "000-default.conf":

sudo vi 000-default.conf

*this will open "000-default-conf" in the vi editor, you will see the default document root is set to: "/var/www/html"

17 - Change directory to www root folder:

cd /var/www/html

18 - List files in www/html folder

ls

or

ls -la [for more info]

19 - Visit the "Apache2 Ubuntu Default Page" in browser

In web browser visit: localhost [or 127.0.0.1]

You should see the default page confirming it works.

20 - Change default page to ''404 Not Found"

sudo vi /var/html/index.html

To empty the file:

Type:

:1,$d

and press enter. This will move the cursor to the bottom and $ is an indication of which lines the following command "d" should work on, In this case the range from one to the last line indicated by $, do you don't need to know the number of lines in the file.

Or press dd to delete lines one by one or press the Esc key to go to "normal mode".

Type:

404 Not Found.

Then press escape and type: wq [and press enter]

*This will "write all" changes and quit saving the file.

Load: http://localhost to verify the changes.

VI Tutorial: https://www.guru99.com/the-vi-editor.html

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

As for the MySQL database, it's better to use delphi mysql component.