You may have heard the term before: LAMP. It stands for Linux-Apache-Mysql-PHP, where Linux is the server operating system, Apache is the HTTP server, Mysql is the database server, and PHP is the hypertext pre-processor / scripting interpreter. These applications work together in unison to create dynamic, data-driven web applications and is sometimes referred to as the LAMP Stack.
You can deploy your own LAMP server in just under a half an hour using Google's Compute Engine. You'll need a valid Google account and you'll also need to setup an organization and billing account on Google Cloud.
So, without further ado, here is the tutorial video. A full explanation can be found below.
Create a new Google Cloud Project
First, we need to create a new project in the Cloud Console. Click the project drop down near the upper left of the screen. This will bring up a list of projects.
Then click Create Project
Now click on the left menu bar and scroll down to Compute Engine and then select VM Instances.
Enable the Compute Engine.
Go back to VM Instancesand launch a new Instance.
Name your instance and then scroll down to Boot Disk and click Change.
Select Ubuntu for operating system and Ubuntu 20.04 LTS for version.
Then scroll down to Firewall and check Allow HTTP and Allow HTTPS.
Now, save your instance and wait for it to launch. A green circle-check will appear once it's live. Notice the public IP address to the right. You'll want to copy that and create an A record with your DNS provider so our server can have a public hostname. Once that's set up, click the SSH button to launch the web-based Secure Shell.
Upgrade the server software
Run the following command:
This will take some time to complete.
Install tasksel and the LAMP stack
Tasksel is an app that will automate the installation and configuration of our LAMP stack.
Set up MySQL for production
Enter n for the first question. Then choose a root passwordand confirm. Then enter y for the remaining questions.
Create a MySQL superuser
Enter the following queries:
Now let's see if our server is working. Type the hostname you chose for the IP address in the address bar of your web browser. You should see the default Apache It Works page:
Set up Apache VirtualHost
Remove the default configuration file:
Then go to:
And create a new configuration file:
Copy the following configuration and paste it into the SSH session:
To save, hit CTRL-X, then Y, then ENTER.
Now we need to enable some Apache modules:
Then reload the Apache configuration:
Create Our Root Directory
Now let's make our default index page:
Enter the following code:
Then hit CTRL-X, Y, ENTER.
Now reload your page and you should see the PHP info page:
Secure With Let's Encrypt's Certbot
Now we need to create a symlink so we can run the command from our execute path:
Now run certbot:
Enter your admin email address, then hit Yif you accept the Terms and Conditions. You can opt to receive news from the Electronic Frontier Foundationby hitting Yor N. Personally, I get enough spam, so I chose no.
Now a list of Apache virtualhosts will appear. You can simply hit enter to select the all, or chose the number associated with the list. You can choose multiple numbers by separating them by a space, but we should only have one at this point.
Hit enter and certbot will work it's magic. It will verify your site automaticall by creating a token in your web server public directory, download it, and then issue you an SSL certificate valid for 45 days. This is a much shorter period than commercial SSL certificates, and that's for two reasons: One, they want to reduce the number of orphaned certificates in their database, and Two, they want to continually verify that your site is in good standing.
Now refresh your page and it should automatically redirect you from http to https. If not, just add the s to your URL in the address bar. You should see the Lock Icon now to the left of the address bar. Click on that to view your certificate and see that it is valid!
We're going to want a nice web-based UI to manage our database. You could do it from the command line, but it's cumbersome and tedious. There are several MySQL/MariaDB management web apps, but I"m partial to PHPMyAdmin, probably because it's the one I've used for years and years and I don't want to change! But there are others that may be better.
Now go back to your web page and append /phpmyadmin to your URL. Hopefully, the PHPMyAdmin login page will appear and you can log in with the superuser account we created.
Well, I hope everything went according to plan and you now have a fully-functional LAMP server. Thanks for reading and/or viewing and look forward to more to come!
Happy coding! :-)