iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To install LAMP on Google Cloud, create a Linux virtual machine in Compute Engine, install Apache, MySQL, and PHP with the VM’s package manager, then allow web traffic through Google Cloud’s VPC firewall and verify the site over HTTP. This guide uses Ubuntu LTS; Compute Engine provides the VM, but you manage the software running inside it.
What does LAMP on Google Cloud include?
LAMP is a web application stack: Linux is the operating system, Apache handles web requests, MySQL stores relational data, and PHP runs server-side application code. “P” can also refer to Perl or Python, but the steps here install PHP.
Google Cloud Compute Engine supplies a Linux VM that you administer like a standard Linux server. Apache, MySQL, and PHP are installed on that guest OS, rather than being included automatically when you create the VM. This gives you direct control over the machine, while leaving you responsible for routine software administration.
A request normally travels through several layers. A browser resolves your domain or uses the VM’s external IP, Google Cloud evaluates the VPC firewall rule, the guest operating system accepts the connection, and Apache selects a site configuration and serves a file or passes a PHP script to the PHP runtime. MySQL is normally reached locally by the application, not by an internet user. A failure at any one of these layers can look like a generic “site is down” error, so checking them separately makes troubleshooting faster.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
What do you need before installing LAMP?
- A Google Cloud project with billing enabled. Compute Engine resources are billable; the machine type and price should be checked in the Google Cloud console when you create the VM.
- A Compute Engine VM running an Ubuntu LTS image. Google’s OS reference lists Ubuntu 24.04 LTS and 22.04 LTS. It lists support through June 2029 for 24.04 LTS, with ESM through April 2034, and through April 2027 for 22.04 LTS, with ESM through April 2032. Confirm current image availability and support details when choosing an image.
- SSH access to administer the VM.
- A plan for network access: TCP port 80 for HTTP, and TCP port 443 only when HTTPS is configured.
- A site name and DNS plan if the application will use a domain. A domain is not required for the first test because the VM’s external IP can be requested directly.
Choose a machine type based on expected traffic, memory use, storage, and budget rather than copying a tutorial’s size. A small VM can be adequate for a learning exercise or light site, but PHP workers, MySQL buffers, logs, and the operating system all compete for memory. Review current Compute Engine machine types and estimated charges in the console; prices and available configurations can change.
Google’s older community LAMP tutorial, published on February 15, 2017, uses an e2-micro example and notes that Compute Engine resources are billable. Treat its machine-type example as historical, not a current sizing or pricing recommendation.
How do I install Apache, MySQL, and PHP on a Google Cloud server?
Use the VM’s Ubuntu package manager to install the software, then check Apache locally and from outside the VM. Installing the packages is only one part of making the site reachable: Google Cloud ingress rules and the guest operating system both affect access.
1. Create an Ubuntu VM
- In Google Cloud, select or create a project and enable billing.
- Create a Compute Engine VM and choose an Ubuntu LTS image. Pick a machine type appropriate to your workload and budget; available types and prices can change.
- During VM creation, enable Allow HTTP traffic if you want to test a public website over HTTP. Enable Allow HTTPS traffic when you are ready to serve configured TLS traffic.
The HTTP option is intended to create the network access needed for web requests, but verify that the applicable VPC firewall rule permits TCP 80 and targets this VM. Google Cloud firewall rules apply independently of the Linux firewall: allowing a port in UFW alone does not open Google Cloud ingress. Conversely, a permissive VPC rule cannot help if a guest firewall blocks the connection.
Record the VM name, zone, network, network tags, and external IP shown in the console. Those values are useful for the SSH command, firewall targeting, DNS, and later support work. If the VM is intended to be private behind another service, do not add a public address merely for convenience; use the access design appropriate for that architecture.
2. Connect over SSH
Use the VM’s SSH button in the Google Cloud console, or connect with the Google Cloud CLI:
gcloud compute ssh VM_NAME --zone=ZONE
Replace VM_NAME and ZONE with the VM’s actual name and zone. Prefer key-based access or OS Login, and limit SSH access to trusted administration paths rather than exposing it broadly. SSH is an administration channel, not a web-service port, so its source ranges should be narrower than the public ranges used for HTTP.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
3. Install and check Apache
Update Ubuntu’s package index, install Apache, and check that its service is running:
sudo apt update
sudo apt -y install apache2
sudo systemctl status apache2
The package-index update lets Ubuntu select current packages from the configured repositories. The service check should show Apache as active. If it is not active, read the status output and Apache’s service logs, correct the configuration or package issue, and check the service again before debugging Google Cloud networking.
From a browser or command-line client outside the VM, request http://EXTERNAL_IP, replacing the example with the VM’s external IP. Use HTTP for this initial test; HTTPS is not expected to work until a certificate and TLS virtual host are configured. Seeing Apache’s default page confirms that the request reached the web server, but it does not yet prove that PHP or MySQL is working.
4. Install MySQL and PHP support for Apache
On Ubuntu, this command installs the MySQL server, PHP, Apache’s PHP module, and PHP’s MySQL driver:
sudo apt -y install php libapache2-mod-php mysql-server php-mysql
Package names and availability can vary by distribution release. Confirm the package set for the Ubuntu image you selected before using these commands in automation. After installing, check Apache again with sudo systemctl status apache2. The PHP Apache module is what allows Apache to process a .php request instead of treating it as an ordinary downloadable text file. The MySQL driver allows PHP applications to connect to the database server; installing it does not create an application database or user.
At this stage, the database server is installed on the same VM. Keep its listening interface and firewall exposure private unless a specific design calls for a separate database client. A typical one-VM deployment has the PHP application connect locally while only Apache receives internet traffic.
5. Verify PHP through Apache, then remove the test file
Create a temporary PHP information page in Apache’s default document directory, request it through the VM’s external IP, and delete it immediately after verification:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
echo '<?php phpinfo();' | sudo tee /var/www/html/info.php
curl http://EXTERNAL_IP/info.php
sudo rm /var/www/html/info.php
A successful request should return PHP-generated output rather than downloading the file or displaying its source as text. The phpinfo() page reveals configuration details, so do not leave it accessible on a production server. Replace Apache’s default page with your application’s index file when ready.
Test in stages. First request the VM from inside the VM or another trusted path to distinguish an Apache problem from an ingress problem. Then request the external IP from outside Google Cloud. Finally test the domain after DNS is configured. If the external request fails but Apache is active locally, inspect the VPC rule, target tag, external address, and any guest firewall rule before changing application code.
How do you make the LAMP site reachable from the internet?
A running Apache service does not by itself make a website public. The VM needs a reachable external address, the Google Cloud VPC firewall must allow the relevant ingress, and Apache must be listening and configured to serve the requested site.
Allow only the web traffic you are ready to serve
- For an HTTP test, permit inbound TCP 80 with a VPC firewall rule that applies to the VM, such as through its network tag or other configured target.
- For HTTPS, permit inbound TCP 443 only after the certificate and Apache TLS virtual host are in place.
- If UFW is enabled in Ubuntu, its guest-level rules may also need to permit the configured web traffic. A guest rule cannot override a blocking VPC firewall rule.
- Do not make the database port publicly accessible for a normal single-VM LAMP setup. Keep administration access, including SSH, restricted to trusted sources.
Google Cloud always enforces enabled VPC firewall rules, including when a VM has not fully started. Therefore, selecting “Allow HTTP traffic” during creation is not a substitute for understanding which rule, target, protocol, and port are active. If you later change network tags or move the VM to another network, recheck that the intended rule still targets it.
Decide whether the external IP should stay fixed
Compute Engine external addresses may be ephemeral or static. An ephemeral address can change, which can leave DNS or an integration pointing at the old address. Reserve and assign a static external IP when a domain or another client needs a stable address. Set the domain’s A or AAAA record to the appropriate address only after confirming the VM’s firewall behavior and Apache virtual-host configuration.
DNS changes can take time to appear through recursive resolvers. During setup, testing the current external IP avoids confusing a DNS delay with an Apache failure. Once the address is stable, configure the Apache virtual host for the intended hostname and verify that requests using the domain reach the expected site rather than the default page.
Why does my Google Cloud Apache page not load?
Start by identifying whether the request times out, reaches Apache but fails to run PHP, or works by IP but not by domain. Each symptom points to a different layer of the stack.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
| Symptom | Check first | Likely correction |
|---|---|---|
| Browser times out | VPC firewall rule, whether the rule targets the VM, external IP, and Apache service status. | Permit TCP 80 for HTTP, or TCP 443 only for configured HTTPS, then check or restart Apache. A UFW rule does not open Google Cloud ingress. |
| Apache’s default page appears, but PHP downloads or displays as text | Whether libapache2-mod-php is installed, Apache’s PHP module is enabled, and the requested file has a .php extension. |
Install the Apache PHP module if needed, restart Apache, and test with a PHP file. |
| The site worked, then the domain stopped resolving to it | Whether the VM uses an ephemeral external address that changed. | Reserve and assign a static external IP, then make sure DNS points to the current address. |
| SSH is reachable from too many sources | VPC and guest firewall source ranges for SSH. | Restrict SSH to administration sources; do not open database ports publicly. |
http:// works but https:// fails |
TLS certificate, Apache SSL virtual host, and TCP 443 ingress. | Configure the certificate and TLS virtual host, then permit TCP 443. |
| The site works by IP but not by hostname | DNS A/AAAA records, the address assigned to the VM, and Apache’s hostname configuration. | Point DNS to the current stable address, allow propagation, and configure the matching Apache virtual host. |
What should you change before using LAMP in production?
A basic installation proves that the stack can serve a page; it does not establish a secure or resilient production deployment. Choose controls according to the application and your organization’s requirements.
- Run the distribution’s MySQL hardening workflow, then create a dedicated application database and a database user with only the permissions the application needs. Do not use an unrestricted administrative account in application configuration.
- Keep SSH restricted to trusted administration paths, and keep database access private unless a specific architecture requires otherwise.
- Apply security updates, including a plan for unattended security updates where appropriate, and review update behavior so maintenance does not surprise the application.
- Configure backups and test recovery. A backup plan should account for both database data and files the application needs, and should define where backups are stored and how long they are retained.
- Monitor the VM, Apache, PHP application, disk usage, and database health. Monitoring should alert on service failure and resource exhaustion rather than merely recording logs.
- Configure HTTPS with a certificate and Apache TLS virtual host before enabling public HTTPS traffic. Redirect or otherwise manage HTTP according to the application’s requirements after TLS is working.
- Remove temporary diagnostic files, including
info.php, and replace the default Apache page with the intended application. - Document the VM name, zone, static address, DNS records, firewall targets, backup location, and recovery steps so another administrator can operate the service.
Google’s installation and networking guidance explains how to install Apache and how network firewall rules behave; it does not certify a complete production-hardening recipe. The controls above should be adapted to the application, compliance requirements, and failure tolerance.
Should you use a self-managed LAMP VM or managed services?
A single Compute Engine VM is a direct fit when you want control over a conventional Linux server and are prepared to administer its software. Managed components can shift some operational work, but the right choice depends on which responsibilities you want to retain.
| Decision area | Self-managed LAMP on one VM | Managed database or deployment option |
|---|---|---|
| Operational control | You control the VM and the software installed on it. | Some infrastructure or database management is handled by the service; the exact scope depends on the product. |
| Patching responsibility | You maintain the guest OS and installed stack. | Responsibility may be shared or reduced for managed components; verify the service’s current terms and capabilities. |
| Database backups and failover | You must plan and operate the database backup and recovery approach. | Available backup and failover features vary; check the current product configuration rather than assuming they are included. |
| Network isolation | You configure the VM’s firewalling and database exposure. | Network controls depend on the chosen service and architecture. |
| Cost predictability | VM and related resource charges apply; check current pricing for the configuration. | Pricing and billing units depend on the product and deployment, so compare current estimates. |
| Migration effort | Applications and data are already arranged on the VM, but scaling or separating tiers may require a redesign. | Moving components can require application, connectivity, or data changes. |
| Typical fit | A straightforward workload that benefits from one-server administration. | A multi-tier production design or a team that wants to delegate some infrastructure operations. |
Compute Engine provides ordinary VM control. A managed database or marketplace image may change the work you operate, but current product capabilities, listing availability, partner terms, and pricing should be verified before choosing one. For a small proof of concept, one VM minimizes moving parts; for a growing or highly available service, separating web and database tiers can make maintenance, scaling, and failure recovery easier.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What is the recommended installation sequence?
- Create the project, enable billing, and select an Ubuntu LTS image and suitable machine type.
- Create the VM, record its zone and address, and enable only the web access you intend to test.
- Connect with SSH using a restricted administration method.
- Install and check Apache, then test
http://EXTERNAL_IP. - Install PHP, the Apache PHP module, MySQL Server, and the PHP MySQL driver.
- Use a temporary PHP file to verify that Apache executes PHP, then remove that file.
- Configure the application database and least-privilege account, keeping database ingress private.
- Reserve a static address and configure DNS when a stable hostname is required.
- Add the certificate, Apache TLS virtual host, and TCP 443 rule for HTTPS.
- Apply updates, hardening, backups, monitoring, and recovery documentation before treating the VM as a production service.
Frequently Asked Questions
Can I install LAMP on a Google Cloud VM without a public IP?
Yes, a VM can be used without direct public web access, for example behind a separately configured load balancer or within a private network. The exact design depends on how users reach the application; a VM with no public external address cannot be tested directly from an ordinary internet connection by its external IP.
Can I use MariaDB instead of MySQL on Compute Engine?
The LAMP name traditionally specifies MySQL, but Linux web servers can use other MySQL-compatible database software when the application supports it. Confirm compatibility, package availability, and operational requirements for the chosen database before substituting it.
Do I need a domain name to test Apache on a Compute Engine VM?
No. A domain is not necessary for an initial reachability check; the VM’s external IP can be used for an HTTP request. A domain becomes useful for a stable public name, and DNS should point to a stable address appropriate for the deployment.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Why does my Google Cloud Apache page time out even though Apache is running?
Check the VM’s external address, the VPC firewall rule and its target, and TCP 80 for an HTTP test. If UFW is enabled, check its guest-level rule as well. Google Cloud ingress and the guest firewall are separate controls, so both must allow the connection.
Why does PHP download instead of execute?
Confirm that PHP and libapache2-mod-php are installed, that Apache’s PHP module is enabled, and that the requested filename ends in .php. Restart or recheck Apache after correcting the package or module configuration.
When should I reserve a static external IP?
Reserve and attach one when DNS, an integration, or another client needs a stable address. An ephemeral address can change when VM lifecycle or configuration events occur, leaving a domain pointed at the wrong location.
Do I open port 443 immediately when creating the VM?
Open TCP 443 when you are ready to serve configured HTTPS traffic. First verify the site over HTTP, then configure a certificate and Apache TLS virtual host and allow the corresponding VPC ingress.
Is an e2-micro machine type still the right choice?
The 2017 community tutorial used an e2-micro example, but that is historical guidance. Compare current machine types, resource needs, and prices in the Google Cloud console instead of assuming that size is suitable today.
The Bottom Line
Install LAMP by creating an Ubuntu LTS Compute Engine VM, installing Apache, MySQL, and PHP with apt, and validating PHP over HTTP. Make TCP 80 reachable through the VPC and guest firewalls, use a static address when DNS needs stability, then add HTTPS, least-privilege accounts, updates, backups, and monitoring before production use.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

