Introduction
In today’s digital age, deploying a website on a scalable and secure platform is crucial for businesses to maintain a strong online presence. Google Cloud Platform (GCP) offers a robust infrastructure for hosting websites, and the LAMP stack (Linux, Apache, MySQL, PHP) is a popular choice for web development due to its flexibility and reliability. In this project, we will walk through the process of deploying a website using the Bitnami LAMP Stack on GCP. By the end of this project, you will have a fully functional website hosted on GCP, leveraging the power of the LAMP stack.
Project Objectives
Set Up Google Cloud Platform: Learn how to sign in to GCP and navigate the Cloud Console.
Deploy a LAMP Stack Using Bitnami: Use the GCP Marketplace to deploy a pre-configured LAMP stack.
Verify the Deployment: Ensure that the website is successfully deployed and accessible.
Manage the Website: Learn how to access the server via SSH, configure the website, and secure the deployment.
Step-by-Step Guide
1. Setting Up Google Cloud Platform
Step 1: Sign in to the Google Cloud Console using your Google account credentials.
Step 2: If you don’t have a GCP account, you can create one and set up a new project. Ensure that billing is enabled for the project.
Step 3: Familiarize yourself with the GCP dashboard, including the Navigation Menu, which provides access to various services like Compute Engine, Cloud Storage, and Marketplace.
2. Deploying the LAMP Stack Using Bitnami
Step 1: In the GCP Console, click on the Navigation Menu and select Marketplace.
Step 2: Search for "Bitnami LAMP Stack" in the Marketplace and select the Bitnami package for LAMP.
Step 3: Click on GET STARTED to begin the deployment process.
Step 4: Review and agree to the Terms and Agreements by checking the box and clicking AGREE.
Step 5: On the deployment page, configure the following settings:
Deployment Name: Enter a name for your deployment (e.g., lampstack-1
).
Zone: Select a zone (e.g., us-east4-c
).
Machine Type: Choose a machine type (e.g., e2-medium
with 2 vCPUs and 4 GB memory).
Step 6: Click DEPLOY to start the deployment process. The status will change to "lampstack-1 is being deployed" and eventually to "lampstack-1 has been deployed".
3. Verifying the Deployment
Step 1: Once the deployment is complete, click on the Site Address link provided in the right pane of the deployment page. This will open the default Bitnami LAMP stack landing page in a new browser tab.
Step 2: To verify that the website is functioning correctly, you can access the phpinfo.php
script, which displays the PHP configuration. The script is located in the web server’s document root.
Step 3: Close the browser tab once you have verified that the website is accessible.
4. Managing the Website
Step 1: In the GCP Console, under the Get Started with LAMP Packaged by Bitnami section, click on SSH to open a secure shell session on the virtual machine.
Step 2: In the SSH window, navigate to the Bitnami installation directory:
Step 3: To secure your deployment, change the temporary password provided by Bitnami. You can do this by running the following command:
sudo /opt/bitnami/ctlscript.sh stop
sudo /opt/bitnami/change_password
Step 4: If you need a static IP address for your VM instance, you can promote the ephemeral IP address to a static one. This ensures that your website’s IP address does not change after a reboot.
5. Customizing the Website
Step 1: To upload your website files, use an FTP client or SCP to transfer files to the /opt/bitnami/apache2/htdocs
directory, which is the document root for the Apache web server.
Step 2: If you need to configure the MySQL database, access the MySQL shell using the following command:
Enter the password when prompted. You can then create databases, users, and tables as needed.
Step 3: Restart the Apache server to apply any changes:
sudo /opt/bitnami/ctlscript.sh restart apache
Conclusion
In this project, we successfully:
Deployed a website using the Bitnami LAMP Stack on Google Cloud Platform.
Verified the deployment by accessing the website and checking the PHP configuration.
Managed the website by accessing the server via SSH, changing the default password, and configuring the MySQL database.
Customized the website by uploading files and configuring the Apache web server.
By following this guide, you can deploy and manage a website on GCP using the LAMP stack, ensuring a scalable, secure, and high-performance online presence. This project is a great addition to your personal blog, as it provides a step-by-step guide for anyone looking to host a website on GCP.
Additional Resources