I need a local installation of WordPress to experiment with on my Ubuntu computer. This blog post is how to set up the LAMP stack prior to installing WordPress. Most of the resources that I found for local installations of WordPress are for Mac or Windows operating systems. While the concept is simple. Install a LAMP, then install WordPress. It took my quite a few tries to get to the point where I now agree the setup is simple however my learning curve was steep. Hopefully the steps I have listed below will help someone learn quicker.
Linux
The L in LAMP is Linux. I am assuming you have a computer that is running a version of Linux. For the steps below I started with a fresh installation of Ubuntu 20.04 LTS.
Apache
The A in LAMP is Apache. Apache is a free open source web server if you are interested in learning more check out the Apache Software Foundation web site.
- Pre-check – Open a web browser and type in 127.0.0.1 (the local host address) into the search address search. The result should be an unable to connect message.
- Open the terminal (CTRL+ALT+T) and type the following commands.
- $ sudo apt update
- $ sudo apt install apache2
- Confirm – Open a web browser and type in 127.0.0.1 into the search address search. You many need to restart the browser. The result should be the Apache2 Ubuntu Default Page.
MariaDB
The M in LAMP is MariaDB. MariaDB is free open source DataBase. Here is a link to the MariaDB Foundation website if you want to learn more.
- Open the terminal (CTRL+ALT+T) and type the following commands.
- $ sudo apt update
- $ sudo apt install mariadb-server
- Secure MariaDB with the following steps. I am using a different password here than my sudo password. Note: I am using my install for local testing and not web hosting. More security may be needed if other will be accessing the computer.
- $ sudo mysql_secure_installation
- Enter current password for root (enter for none): – hit enter
- Set root password – Y
- pass work picked – password_goes_here
- Remove anonymous users – Y
- Disallow root login remotely – Y
- Remove test database and access to it? – Y
- Reload priviledg tables now? – Y
- Check the status of MariaDB with the next command. Note use “Q” to quit the status if needed.
- $ sudo systemctl status mariadb
- You can check the version number of MariaDB with the following command.
- $ mariadb –version
php
As you probably guessed at this point the P in LAMP is php. To run WordPress you need an operating system, webserver, database and a programming language. Php is the scripting programming language to complete the LAMP stack. For more reading on php visit the php website.
- Open the terminal (CTRL+ALT+T) and type the following commands.
- $ sudo apt install php php-mysql php-cgi php-cli php-gd libapache2-mod-php
- In the following steps we will write a small php program to confirm php was installed and is running.
- $ sudo nano /var/www/html/test.php
- <?php
- echo “Hello Karl”
- ?>
- To exit nano use CTRL-X
- Save modified buffer? = Y
- Press enter to confirm the file name
- Next restart apache
- $ sudo systemctl restart apache2
- Confirm – Open a web browser and type in 127.0.0.1/test.php into the search address search. The result should be Hello Karl or what ever you had between the quotes in the above echo statement.
If everything went correctly you will now have a LAMP stack for a local WordPress install. At this point you could code a website using HTML, CSS and PHP however my goal is to run a development environment for WordPress and I have those steps documented in WordPress on Ubuntu.
Please contact me with any comments or questions.