How to host WordPress website in Google Firebase

By hosting WordPress in Google Firebase you might think about installing WordPress in Firebase hosting and using it like on any recommended hosts like Bluehost, DreamHost, SiteGround, etc. Firebase only allows static websites to be uploaded which are made using just HTML, CSS and JavaScript.

Even if you can't install WordPress on Firebase, you can host the static version of your WordPress site. So if you follow through with this tutorial you will be able to covert your WordPress site to static files(HTML, CSS) and host it on Firebase.

So mainly the process includes two major steps.

  1. Converting WordPress site to static files.
  2. Hosting the static website in Firebase.

Converting WordPress site to static files.

You can generate a static version of your WordPress site using a plugin called Simply Static.

  • Download Simply Static plugin. (A zip file will be downloaded.)
  • Select section Plugins on WordPress dashboard.
  • Click on Add New button.
  • Click on Upload Plugin and select Simply Static (The zip file you just have downloaded).
  • Install and open the plugin.
  • Click on Generate Static Files.
  • In a moment static files will be generated. Download the files by clicking on Click here to download text.




Hosting the static website in Firebase.

If you know how to host a static website in Firebase, further steps are the same. You can host the downloaded static files in Firebase.

You can follow these steps to upload the static version of your WordPress site in Firebase and deploy your site online.


  • Go to Firebase console.
  • Create a project using default settings or you can also use an existing project.
  • Google will finish creating a project for you and redirect you to the project console.
  • Choose to create a web app.


  • Give an App nickname and register the app.
  • Uncheck Also set up Firebase Hosting for this app for now.



  • Continue to console.
  • Now you have the first site registered, Go to Hosting from the side menu.
  • Click on Get started.
Now Google will show you the steps to host your site online.

The first step is to Install Firebase CLI on your PC. To install the Firebase CLI you need to have node.js installed on your PC. If you don't have node.js installed on your PC, download and install node.js before continuing. 

  • Open your computer terminal, command prompt if you are using Windows.
  • Run this command to install Firebase CLI.
 npm install -g firebase-tools  

If node.js is installed successfully on your computer, this should install the CLI in some minutes.

Go back to the Firebase site and Click Next.
  • Initialize your project by the following commands on the terminal.

 firebase login  

  • Enter Y for Yes on the prompt.

This will ask you to authorize your Google account by signing in and allow the permissions.

Go back to the terminal run, you will see a successfully logged-in message if everything is going the right way.

  • Now find your download static files, It will be in a zip file extract it.
  • Open the extracted folder and copy the directory address.
  • Create a folder in that directory and name it public. 
  • Now go to your terminal and navigate to the address you have copied just now.
In windows:
 cd {COPIED ADDRESS}  

  • Then run the command to initiate the project.

 firebase init  

  • Press Y, for are you ready to proceed(on prompt).

Next, you will be asked to select the service, Using arrow keys and select by pressing the space key on Hosting: Configure and deploy Firebase Hosting sites (you will see a * before the selected feature that is Hosting). Then click Enter.

  • Select Use an existing project by clicking Enter key.
  • Choose the project you just created.
  • For the prompt What do you want to use as your public directory? (public), press Y.
  • Configure as a single-page app (rewrite all urls to /index.html)?  , press N.
  • For overwriting prompt, press N.

Now after the Firebase initialization is complete, Go back to the Firebase site and click on Next.



Now it's time to deploy.  
  • Run this command on the terminal.

 firebase deploy  

Now your website will be deployed on the Firebase server. You will be provided with a Hosting URL which you can use to view your site only from anywhere.

If everything went right you will be able to see your site online using the Hosting URL.

Conclusion

Remember that by this method your static version of your site is only uploaded. All the dynamic functionalities (eg: comments) that you have implemented on your site will not work. Your WordPress admin functionalities and features also cannot be accessed in Firebase because you are not using their server to run WordPress but only deployed the static version of your site in Firebase.

All the terminal commands for deployment are directly given in the Firebase site, you can either copy from there or here, it is the same.

Jobin Jose

No comments:

Post a Comment