I am trying to install PHP on a Google Cloud Workstation
, and have it persist after reboot. The problem I am having is that although I can get it installed in the default location, it does not persist after reboot. Here are the steps I tried:
First I updated and upgraded my packages with:
sudo apt-get update
sudo apt-get upgrade
Then I installed PHP afterwards:
sudo apt-get install php
Next I verified the location of the PHP executable using the command whereis php
and received this output:
php: /usr/bin/php /usr/bin/php7.4 /usr/lib/php /etc/php /usr/share/php7.4-readline /usr/share/php7.4-opcache /usr/share/php7.4-json /usr/share/php7.4-common /usr/share/man/man1/php.1.gz
Finally, after confirming that PHP was installed, I was then able to debug my PHP application using the command php -S localhost:8080
.
To help reduce costs, Cloud Workstations use an activity timeout that will automatically shutdown idle workstations. The problem arises when my Cloud Workstation is subsequently launched after being shutdown. The PHP installation is no longer present at the location where I previously installed it.
I suspect the reason why PHP is missing after reboot is because it was installed on the ephemeral Compute Engine VM where all runtime data is deleted when the workstation is stopped.
I though it might be possible to install PHP in the persistent home directory of the workstation mounted to the /home
folder so that it will persist between sessions.
Is this the best strategy for installing PHP on Google Cloud Workstations? If so, how do I install PHP in the /home
folder?