Skip to content
Follow
CMS Ubuntu Linux

How to Install PHP on Google Cloud Server

Richard
Written by
Richard
Nov 27, 2021 Updated Jul 14, 2026 4 min read
How to Use Sticky Notes in Windows 11
How to Use Sticky Notes in Windows 11
  • Web browsers
    • The latest version of Google Chrome
    • Firefox
    • Microsoft Edge
    • Microsoft Internet Explorer 11 and later
    • Safari 8 and later. Note that Safari is not supported in private browser mode.

    Virtual machine configurations

    • All Linux VM images are natively available in Google Cloud.

    Google Cloud offers all Linux VM images right out of the box, so you won’t need extra software or browser extensions. Log into your Google Cloud Console and navigate to Menu ==> Compute Engine ==> VM instances.

    From there, click the SSH button next to the instance you want to connect to.

    Establishing SSH connection to Google Cloud VM instances
    establish ssh connection to vm instances

    You can also open an SSH connection to an instance by clicking its name and then selecting SSH from the instance details page.

    An SSH terminal window with the Ubuntu Linux instance you created in the series’s second post will open.

    You should now be able to run commands in Ubuntu Linux on your Google Cloud server.

    Connecting to Google Cloud instance host via terminal
    connect to google cloud instance host

    How to install PHP on Ubuntu Linux on Google Cloud Server

    Installing PHP on your Ubuntu Linux server on Google Cloud uses standard Ubuntu commands. PHP is available in Ubuntu’s software sources, allowing you to use `apt-get` to download and install PHP like on any other Ubuntu machine. This process helps you get PHP running on your Google Cloud server.

    PHP packages are available in Ubuntu’s default repositories. You can use the apt-get commands to download and install PHP on Ubuntu Linux.

    Installing PHP on Ubuntu Linux involves specific steps. Following this guide lets you successfully set up and manage PHP software on your Ubuntu operating system.

    How to install PHP on Ubuntu Linux

    With PHP installed, your domain name should now be able to bring up a default web server PHP test page when anyone browses your domain name, followed by /phpfinfo.php.

    First, create a test PHP file called phpnfo.php in the web server’s default home directory.

    🐧Bash / Shell
    sudo nano /var/www/html/phpinfo.php
    ⚠️Warning
    Then copy and paste the line into the file and save it.
    🐘PHP
    <?php phpinfo( ); ?>

    Save the file and exit.

    Restart your web server (Nginx or Apache).

    Next, go and type your domain name in your browser, and you should see an example page similar to the one below:

    http://example.com/phpinfo.php

    ⚠️Warning
    If you installed the Nginx web server with PHP-FPM, then you should see a page similar to the one below.
    Installing PHP-FPM with Nginx on Ubuntu Google Cloud server
    php fpm install with nginx ubuntu google cloud server

    If you installed the Apache web server with PHP, you should get a page similar to the one below instead.

    Installing PHP with Apache on Ubuntu Google Cloud server
    php install with apache ubuntu google cloud

    As you can see, your server hosted on Google Cloud is now resolving your domain name and serving web content with PHP.

    We’ll continue to add other servers and software so you can run a functional website online.

    Conclusion:

    This post demonstrated how to install PHP on a Google Cloud server running Ubuntu Linux. Here are the key points to remember:

    • Connecting to your Google Cloud server can be easily accomplished using SSH from the Google Cloud Console.
    • Installing PHP on Ubuntu is straightforward with the use of apt-get commands.
    • A test page can be created to verify that PHP functions correctly on your web server.
    • Both Nginx and Apache web servers can successfully serve PHP content.
    • This process lays the foundation for building and running dynamic websites on your Google Cloud server.

    As you progress through this series, you will gain more skills and knowledge about effectively setting up and managing your web presence.

    Installing PHP on your Google Cloud server running Ubuntu Linux lets you run dynamic websites.

    PHP is a popular open-source coding language that helps make websites interactive. By installing it directly on your Google Cloud server, the server can understand and run PHP code.

    This step is essential for building modern websites, especially if you’re just starting. You’ll likely need PHP version 7.4 or a newer one to use the latest web features.

    Once PHP is ready, your server can handle things like user sign-ups, database connections, and showing custom content to people visiting your site.

    ⚡ Quick Answer

    Connect to your Google Cloud server via SSH. Open your terminal and run sudo apt update followed by sudo apt install php to install PHP on your Ubuntu instance.

    How to connect to the Google Cloud server

    Connecting to your Google Cloud server directly from your web browser using SSH is possible. The Google Cloud Console simplifies this process, eliminating the need to install any extra programs. This feature works with common browsers like Chrome, Firefox, Edge, and Safari, letting you connect quickly.

    SSH from the browser supports these web browsers:

    • Web browsers
      • The latest version of Google Chrome
      • Firefox
      • Microsoft Edge
      • Microsoft Internet Explorer 11 and later
      • Safari 8 and later. Note that Safari is not supported in private browser mode.

      Virtual machine configurations

      • All Linux VM images are natively available in Google Cloud.

      Google Cloud offers all Linux VM images right out of the box, so you won’t need extra software or browser extensions. Log into your Google Cloud Console and navigate to Menu ==> Compute Engine ==> VM instances.

      From there, click the SSH button next to the instance you want to connect to.

      Establishing SSH connection to Google Cloud VM instances
      establish ssh connection to vm instances

      You can also open an SSH connection to an instance by clicking its name and then selecting SSH from the instance details page.

      An SSH terminal window with the Ubuntu Linux instance you created in the series’s second post will open.

      You should now be able to run commands in Ubuntu Linux on your Google Cloud server.

      Connecting to Google Cloud instance host via terminal
      connect to google cloud instance host

    How to install PHP on Ubuntu Linux on Google Cloud Server

    Installing PHP on your Ubuntu Linux server on Google Cloud uses standard Ubuntu commands. PHP is available in Ubuntu’s software sources, allowing you to use `apt-get` to download and install PHP like on any other Ubuntu machine. This process helps you get PHP running on your Google Cloud server.

    PHP packages are available in Ubuntu’s default repositories. You can use the apt-get commands to download and install PHP on Ubuntu Linux.

    Installing PHP on Ubuntu Linux involves specific steps. Following this guide lets you successfully set up and manage PHP software on your Ubuntu operating system.

    How to install PHP on Ubuntu Linux

    With PHP installed, your domain name should now be able to bring up a default web server PHP test page when anyone browses your domain name, followed by /phpfinfo.php.

    First, create a test PHP file called phpnfo.php in the web server’s default home directory.

    🐧Bash / Shell
    sudo nano /var/www/html/phpinfo.php

    Then copy and paste the line into the file and save it.

    🐘PHP
    <?php phpinfo( ); ?>

    Save the file and exit.

    Restart your web server (Nginx or Apache).

    Next, go and type your domain name in your browser, and you should see an example page similar to the one below:

    http://example.com/phpinfo.php

    If you installed the Nginx web server with PHP-FPM, then you should see a page similar to the one below.

    Installing PHP-FPM with Nginx on Ubuntu Google Cloud server
    php fpm install with nginx ubuntu google cloud server

    If you installed the Apache web server with PHP, you should get a page similar to the one below instead.

    Installing PHP with Apache on Ubuntu Google Cloud server
    php install with apache ubuntu google cloud

    As you can see, your server hosted on Google Cloud is now resolving your domain name and serving web content with PHP.

    We’ll continue to add other servers and software so you can run a functional website online.

    Conclusion:

    This post demonstrated how to install PHP on a Google Cloud server running Ubuntu Linux. Here are the key points to remember:

    • Connecting to your Google Cloud server can be easily accomplished using SSH from the Google Cloud Console.
    • Installing PHP on Ubuntu is straightforward with the use of apt-get commands.
    • A test page can be created to verify that PHP functions correctly on your web server.
    • Both Nginx and Apache web servers can successfully serve PHP content.
    • This process lays the foundation for building and running dynamic websites on your Google Cloud server.

    As you progress through this series, you will gain more skills and knowledge about effectively setting up and managing your web presence.

    Was this guide helpful?

  • Was this helpful?
    Richard

    About the Author

    Richard

    Tech Writer, IT Professional

    Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

    📚 Related Tutorials

    How to Install PHP on Ubuntu Linux
    Ubuntu Linux How to Install PHP on Ubuntu Linux
    How to Install Ubuntu Linux
    Ubuntu Linux How to Install Ubuntu Linux
    How to Set Google Chrome to Use System Default Printer
    Browsers How to Set Google Chrome to Use System Default Printer
    How to Change Copy-Paste Settings in Microsoft Edge
    Browsers How to Change Copy-Paste Settings in Microsoft Edge

    No comments yet — be the first to share your thoughts!

    Leave a Comment

    Your email address will not be published. Required fields are marked *