In this tutorial I deployed a WordPress application into a virtual machine and served the website files over the internet.
This tutorial builds on a previous tutorial: How to setup a compute engine VM on GCP and install LAMP stack on the server.
Prerequisite
Complete tutorial: How to setup a compute engine VM on GCP and install LAMP stack on the server.
Steps
i) SSH into the VM
ii) CD into the html directory of the apache2 server
cd /var/www/html
ls
iii) Get into MariaDB database.
sudo mysql
Create database for WordPress application
CREATE DATABASE wordpress_database;
Create a user for the database named wordpress_user
CREATE USER 'wordpress_user'@'%' IDENTIFIED BY 'User@789dynamic!';
vi) Grant wordpress_user access to wordpress_database
GRANT ALL ON wordpress_database.* TO 'wordpress_user'@'%';
vii) Show databases.
SHOW DATABASES;
vii) Modify PHP.ini file
cd /etc/php/8.1/apache2/
[NB: Be careful to adapt to your own PHP version if it is not 8.1]
sudo nano php.ini
Set the following variables in the php.ini file to have the given values.
- max_input_time=30, upload_max_filesize=20M, post_max_size=21M
Return to web server root directory and remove test files if any (e.g. index.html, myphpinfo.php and mytodolist.php)
cd /var/www/html/
viii) Clone code from wordpress.org
sudo wget https://wordpress.org/latest.tar.gz
ix) Unpack files and change to the wordpress directory
sudo tar -xzvf latest.tar.gz
ls
cd wordpress
x) Move content to outer directory
sudo mv * ..
xi) Change to outer directory
cd ..
xii) Delete emptied wordpress directory and latest.tar.gz file
sudo rm wordpress/ -r
sudo rm latest.tar.gz
xiii) Copy wp-config-sample.php content into wp-config.php
sudo cp wp-config-sample.php wp-config.php
- [CONFIGURE wp-config.php APPROPRIATELY]
sudo nano wp-config.php
- define (‘DB_NAME’, ‘wordpress_database’);
- define (‘DB_USER’, ‘wordpress_user’);
- define (‘DB_PASSWORD’, ‘User@789dynamic!’);
Configure SALTS – Get values at:
https://api.wordpress.org/secret-key/1.1/salt/
Save updated wp-config.php file , save and exit.
xiv) Set up WordPress over the web. Login and test.
Conclusion
In this tutorial we:
i) Deployed a WordPress application into a virtual machine server;
ii) Configured a WordPress website on the cloud;
iii) Tested the deployed WordPress Website on a browser over the Internet
END
NOTE: If you are interested learning how to develop WordPress websites then see how on the following link on my website.
Training: WordPress Website Design Fundamentals – https://ugogineering.com/wordpress-fundamentals-training
References
- How to setup a GCP compute engine virtual machine and install Linux, Apache, MariaDB, PHP (LAMP) Stack on Ubuntu 22.04
- How to deploy a pre-built website code into a compute engine virtual machine and serve the website from GCP
- Hosting a website on Google Cloud Platform.
- How to sign up for your own GCP account.
- Hosting a Website on Google Cloud Platform | Free Hosting
- Caseray Cloud
- My (Ugochukwu Ukwuegbu’s) YouTube channel.