How I switched the domain names of Laravel Apps hosted on the Google Cloud Platform: Learn and Save time

At a certain company, we developed a B2B web application and a mobile application. The web application also serves as the REST API to integrate the mobile app. The web application was developed using Laravel. And we deployed this web application on a Compute engine (CE) in the Google Cloud Platform (GCP).

So recently, we developed a new major version, code-named version 2, of the web application and the API. To put version 2 to the test, we published it to the public through a subdomain such as and we left the older version accessible via

Fortunately, the users have liked version two of the system; hence, there is a need to change domain names so that the newer major version will be on, whereas the older version will be on I have two systems:

Steps I will most likely take to achieve the goal.

I believe the following are the steps that I will have to perform to ensure that we server the newer version through a and the older version through a sub-domain with minimal or no downtime at all.

  1. First of all, I want to avoid as much downtime as possible. I want the system to be accessible throughout the process. The good thing is that both the old and new versions store and access data in the same database. That means if a user is using an old version or a new version, we are not worried about Data loss and synchronisation.

  2. Create sub-domain at the domain registrar and point it to the public IP address of GCP CE instance. To do this, I will have to login to our account and choose the domain name, then go to DNS and add a new A record. Since the value of the A record is the public IP address of the CE instance, I can access this from the GCP Instances listing page.

  3. Access the CE instance via SSH. I will use the GCP's web based SSH to avoid extra steps of setting SSH client and keys.

  4. Rename the web directory from to and ensure that the file permissions and ownership are intact otherwise reset them.

  5. Rename the web directory from to and ensure that the file permissions and ownership are intact otherwise reset them.

  6. Rename /etc/apache/sites-available/ to /etc/apache/sites-available/

  7. Edit and set webroot in /etc/apache/ to /var/www/domains/

  8. Disable in apache

  9. Enable in apache

  10. Restart Apache, and if everything is good, proceed to the next steps.

  11. Generate an SSL certificate for domain

  12. Delete the SSL certificates to declutter the CE Instance of unnecessary files and avoid errors at the point of renewing SSL certificates.