Skip to content
Follow
CMS Ubuntu Linux

How to Install PHP on Google Cloud Server

Richard
Written by
Richard
Nov 27, 2021 Updated Aug 13, 2026 3 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

    Opening an SSH connection to an instance is also possible 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.

    Running commands in Ubuntu Linux on your Google Cloud server works immediately after opening the terminal.

    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

    Standard package management tools handle the installation process on Ubuntu Linux instances. PHP is available in Ubuntu's software sources, allowing use of `apt-get` to download and install PHP like on any other Ubuntu machine. This process helps establish PHP on your Google Cloud server.

    PHP packages are available in Ubuntu's default repositories. Using the apt-get commands downloads and installs PHP on Ubuntu Linux.

    Installing PHP on Ubuntu Linux involves specific steps. Following this guide ensures successful setup and management of PHP software on the Ubuntu operating system.

    How to install PHP on Ubuntu Linux

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

    ⚠️Warning
    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

    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, type your domain name in your browser to view an example page similar to the one below:

    http://example.com/phpinfo.php

    Installing the Nginx web server with PHP-FPM displays 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

    Installing the Apache web server with PHP displays a page similar to the one below instead.

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

    The server hosted on Google Cloud now resolves your domain name and serves web content with PHP.

    Additional servers and software will be added later to 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.

    Progressing through this series builds more skills and knowledge for effectively setting up and managing your web presence.

    Installing PHP on a Google Cloud server running Ubuntu Linux lets your web server run dynamic websites and handle tasks like user sign-ups and database connections. PHP is a coding language that makes website content interactive, and you need version 7.4 or later to run most modern web frameworks and plugins properly.

    Getting PHP set up directly on your server helps it read and run code fast without needing outside help. You can finish this setup in a few quick steps using the command line.

    ⚡ 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 handles this process directly, removing the need for separate SSH clients. 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

      Opening an SSH connection to an instance is also possible 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.

      Running commands in Ubuntu Linux on your Google Cloud server works immediately after opening the terminal.

      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

    Standard package management tools handle the installation process on Ubuntu Linux instances. PHP is available in Ubuntu's software sources, allowing use of `apt-get` to download and install PHP like on any other Ubuntu machine. This process helps establish PHP on your Google Cloud server.

    PHP packages are available in Ubuntu's default repositories. Using the apt-get commands downloads and installs PHP on Ubuntu Linux.

    Installing PHP on Ubuntu Linux involves specific steps. Following this guide ensures successful setup and management of PHP software on the Ubuntu operating system.

    How to install PHP on Ubuntu Linux

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

    ⚠️Warning
    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

    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, type your domain name in your browser to view an example page similar to the one below:

    http://example.com/phpinfo.php

    Installing the Nginx web server with PHP-FPM displays 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

    Installing the Apache web server with PHP displays a page similar to the one below instead.

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

    The server hosted on Google Cloud now resolves your domain name and serves web content with PHP.

    Additional servers and software will be added later to 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.

    Progressing through this series builds more skills and knowledge for 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 Change Copy-Paste Settings in Microsoft Edge
    Browsers How to Change Copy-Paste Settings in Microsoft Edge
    How to Create a Google Cloud Server with Ubuntu Linux
    CMS How to Create a Google Cloud Server with Ubuntu Linux

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

    Leave a Comment

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