How to Install a LAMP Stack and phpMyAdmin and Microsoft Visual Studio Code on Ubuntu (2022)

Shameless ad

Some of the links in this article are "affiliate links", a link with a special tracking code. This means if you click on an affiliate link and purchase the item, we will receive an affiliate commission.

The price of the item is the same whether it is an affiliate link or not. Regardless, we only recommend products or services we believe will add value to our readers.

By using the affiliate links, you are helping support our Website, and we genuinely appreciate your support.

LAMP with phpMyAdmin

Why use LAMP with phpMyAdmin?

LAMP with phpMyAdmin allows you to make local websites on your Ubuntu PC. It provides the Apache web server, PHP, MySQL, and phpMyAdmin.

Useful LAMP with phpMyAdmin Information

LAMP with phpMyAdmin Configuration Information

Once installed, the local website can be found at http://localhost/.

/var/www/html/ is the folder for http://localhost/.

Another shameless ad

Great webhosting at a price that you won't believe.

Interserver

http://localhost/phpmyadmin to access phpMyAdmin.

Change the 8.1 to the number for your PHP version.

/etc/php/8.1/apache2/php.ini is the PHP initialization file path.

/usr/bin/php is the PHP executable file path.

Remember This

You will see packages installing. Unless told otherwise, simply use the defaults. For example, if you are asked to continue and the choices are Y/n, simply press Enter. The default is Y, so Y will be chosen.

If sudo prompts you for a password, enter the password you use to log into Ubuntu.

Proceed with Caution

You can seriously mess up your computer if you do not know what you are doing in Terminal.

Terminal is for advanced users only. Terminal assumes you are an expert and does not do the “Does the user know what they are doing?” checks the GUI does.

Terminal assumes you are an expert. It will simply not question you, and will obey.

This a very powerful feature, but is a two-edged sword if Terminal is used carelessly.

Installing LAMP with phpMyAdmin

Installing Linux

Ubuntu is a Linux distribution. If you are wanting to run a LAMP stack on Ubuntu, you likely have Ubuntu installed already.

If not, and you want to install Ubuntu on a PC, visit the Ubuntu website.

Preparing Ubuntu

First, ensure Ubuntu has the latest and greatest packages in apt.

Open Terminal.

Ubuntu Preparing Open Terminal

Enter the following command into Terminal.

sudo apt update
Ubuntu Preparing sudo apt update

apt will update.

Ubuntu Preparing apt update start end

Enter the following command into Terminal.

sudo apt upgrade
Ubuntu apt upgrade

apt will upgrade.

Ubuntu sudo apt upgrade start
Ubuntu sudo apt upgrade middle
Ubuntu sudo apt upgrade end

Installing Apache

To install, Apache, enter the following command into Terminal.

sudo apt install apache2
Ubuntu Apache sudo apt install apache2

Apache will install.

Ubuntu Apache installing start
Ubuntu Apache installing middle
Ubuntu Apache installing end

Tell Ubuntu to start Apache when Ubuntu on startup. Enter the following command into Terminal.

sudo systemctl start apache2
Ubuntu Apache sudo systemctl start apache2

In a browser, go to http://localhost/.

Ubuntu Apache go to localhost

If you see the Apache Default Page, Apache is installed and working!

Ubuntu Apache working localhost

Installing PHP

To install PHP, enter the following command into Terminal. Change 8.1 to your version of PHP.

Change 8.1 to your version of PHP.

sudo apt install php8.1 php8.1-mysql php-common php8.1-cli php8.1-common php8.1-opcache libapache2-mod-php8.1
Ubuntu PHP install PHP

PHP will install.

Ubuntu PHP installing PHP start
Ubuntu PHP installing PHP middle
Ubuntu PHP installing PHP end

Restart Apache. Enter the following command into Terminal.

sudo systemctl restart apache2
Ubuntu PHP sudo systemctl restart apache2

Find the PHP initialization file path. Create a temporary phpinfo.php file by entering the following command into Terminal.

echo '<?php phpinfo(); ?>' | sudo tee -a /var/www/html/phpinfo.php > /dev/null
Ubuntu PHP Create a temporary phpinfo_php file

In a browser, go to http://localhost/phpinfo.php.

Ubuntu PHP go to localhost:phpinfo_php

Find the section for Loaded Configuration File.

Ubuntu PHP find Loaded Configuration Path section

The Loaded Configuration File is the PHP initialization file path.

Ubuntu PHP find Loaded Configuration Path

Copy the loaded configuration file path and keep it in a safe place for future use.

Ubuntu PHP copy initialization filepath

Delete the temporary phpinfo.php for security reasons. Enter the following command into Terminal.

sudo rm /var/www/html/phpinfo.php
Ubuntu PHP Delete temporary phpinfo_php

Find the PHP executable file path. Enter the following command into Terminal.

which php
Ubuntu PHP which php

It will tell you the PHP executable file path.

Ubuntu PHP executable filepath

Copy the PHP executable file path and keep it in a safe place for future use.

Ubuntu PHP copy PHP executable filepath

Installing MariaDb

To install MariaDb, enter the following command into Terminal.

sudo apt install mariadb-server mariadb-client
Ubuntu apt install mariadb-server mariadb-client

MariaDb will install.

Ubuntu MariaDb installing start
Ubuntu MariaDb installing end

Enter the following command into Terminal.

sudo mysql_secure_installation
Ubuntu MariaDb mysql secure installation

You will be ask for the current root password. Since there is none, press Enter.

Ubuntu MariaDb Enter MariaDb root password

When asked to switch to unix_socket authentication, press Enter.

Ubuntu MariaDb switch to unix_socket authenication

When asked if you want to change the root password, press Enter.

Ubuntu MariaDb Change the root password

Create a password. Store it in a secure place for future use. Enter the password.

Ubuntu MariaDb Enter root password

Re-enter the password exactly when prompted.

Ubuntu MariaDb Enter root password again

When asked to remove anonymous users, press Enter.

Ubuntu MariaDb remove anonymous users

When asked to disallow root login remotely, press Enter.

Ubuntu MariaDb disallow root login remotely

When asked to remove the test database and access to it, press Enter.

Ubuntu MariaDb remove test database and access to it

When asked to Reload the privilege tables now, press Enter.

Ubuntu MariaDb reload privilege tables now

MariaDB is now installed!

Ubuntu MariaDb Thanks for using MariaDb

The PHP Initialization File Path for LAMP

The easy way is to just take my word for it.

/etc/php/8.1/apache2/php.ini is the PHP initialization file path. Change the 8.1 to the number for your PHP version.

The PHP Executable File Path for LAMP

The easy way is to just take my word for it.

/usr/bin/php is the PHP executable file path.

Installing phpMyAdmin

Enter the following command into Terminal.

sudo apt install phpmyadmin
Ubuntu apt install phpmyadmin

You will see packages installing.

Ubuntu apt install phpmyadmin installing

Eventually, you will get to this.

Ubuntu Apache selected

When the prompt appears, “apache2” is highlighted but not selected. You must press Space to select Apache, or the installer will not set up the appropriate files during installation.

Press Space. An asterisk will show up in the red area, indicating you chose Apache.

Press Tab. The OK button will turn red. Now, press Enter to select Apache.

You will be asked if you want to configure the database for phpMyAdmin with dbconfig-common. Press Enter.

Ubuntu Yes for dbconfig-common

You will be asked to create a password. Enter the password you want. Then press Tab, then press Enter.

Keep a copy of the password in a safe place for future use. This is the phpMyAdmin root password.

Ubuntu phpMyAdmin root password

Ubuntu phpMyAdmin root password ok

You will be asked to confirm the password you just typed in. Type the password again. The two passwords you just entered must be identical.

Ubuntu phpMyAdmin confirm root password

Press Tab, then Enter.

Ubuntu phpMyAdmin confirm root password ok

Enter the following command into Terminal.

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
Ubuntu configure phpMyAdmin

Enter the following command into Terminal.

sudo a2enconf phpmyadmin.conf
Ubuntu a2enable phpMyAdmin_conf

Enter the following command into Terminal.

sudo systemctl reload apache2.service
Ubuntu reload apache2_service

In your browser, go to http://localhost/phpmyadmin/.

Ubuntu Go to localhost phpmyadmin

You will see the phpMyAdmin login page. Enter root in the Username field. Enter the phpMyAdmin root password into the Password field. Click the Go button.

Ubuntu Log into phpMyAdmin

Now, you are logged into phpMyAdmin!

Ubuntu phpMyAdmin

Congratulations! You have now successfully installed LAMP with phpMyAdmin on Ubuntu Desktop.

Important Information about LAMP with phpMyAdmin

LAMP with phpMyAdmin Configuration Information

Once installed, the local website can be found at http://localhost/.

/var/www/html/ is the folder for http://localhost/.

http://localhost/phpmyadmin to access phpMyAdmin.

Change the 8.1 to the number for your PHP version.

/etc/php/8.1/apache2/php.ini is the PHP initialization file path.

/usr/bin/php is the PHP executable file path.

Resources

Apache Friends

How to Install Microsoft Visual Studio Code

Microsoft Visual Studio Code

What is Microsoft Visual Studio Code?

Visual Studio Code is a streamlined code editor with support for development operations like debugging, task running, and version control. It aims to provide just the tools a developer needs for a quick code-build-debug cycle and leaves more complex workflows to fuller featured IDEs, such as Visual Studio IDE.

code.visualstudio.com

How to Install Microsoft Visual Studio Code

Open Ubuntu Software.

Open Ubuntu software

Click on the search icon and search for code. In Ubuntu, Microsoft Visual Studio Code is simply called code.

Ubuntu VS Code search for code

Microsoft Visual Studio Code

Microsoft Visual Studio Code

The following screen will appear. Click on the Install button.

Click on the Install button.

Visual Studio Code will install.

VS Code will install

Microsoft Visual Code is now installed.

VS Code is now installed.

Click on Show Applications.

Click on Show Applications

Search for code.

Show Applications search for code

Right-click on the Visual Studio Code icon. Click Add Fovorites.

add favorites

Open Visual Studio Code.

Open VS Code

Click Get Started.

Click Get Started

Click open a folder.

Click open a folder

Select the folder you wish to code in. Then click the Open button.

select folder

Click the “Yes, I trust…” button.

Microsoft Visual Code is now installed!

settings.json

{
“phpserver.phpConfigPath”: “/etc/php/8.1/apache2/php.ini”,
“phpserver.phpPath”: “/usr/bin/php”,
“php.executablePath”: “/usr/bin/php”,
“php.validate.executablePath”: “/usr/bin/php”,
}

Struggling when creating PHP code?

Copy and paste website features with EvergreenCode.

';
Scroll to Top