I am going over hosting WordPress on Google Cloud Platform in this article. This is a step by step guide on how to set up and host a WordPress website using a fresh installation.
Note: Be sure and install gcloud https://cloud.google.com/sdk/docs/downloads-apt-get
Setup Project and VM (micro)sudo apt update && sudo apt upgrade
sudo fallocate -l 1G /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo nano /etc/fstab
/swapfile swap swap defaults 0 0
sudo apt install tasksel
sudo tasksel install lamp-server
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc
Setup DNS
-Go to your web domain registrar and create A record pointing to your new server
Configure Apache conf for website
<Directory /var/www/example.com>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName <a rel="noreferrer noopener" target="_blank" href="http://example.com/">example.com</a>
ServerAlias <a rel="noreferrer noopener" target="_blank" href="http://www.example.com/">www.example.com</a>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.com
</VirtualHost>
$ mkdir -p /var/www/example.com
$ a2dissite 000-default.conf
$ a2ensite example.com.conf
$ systemctl reload apache2
Create database
$ mysql -u root
> CREATE DATABASE wordpress;
> GRANT ALL ON wordpress.* TO 'wordpressuser' IDENTIFIED BY 'Secure1234!';
> quit
$ mysql_secure_installation
Edit /etc/php/7.2/apache2/php.ini
max\_input\_time = 30
upload\_max\_filesize = 20M
post\_max\_size = 21M
https://codex.wordpress.org/Installing_WordPress$ wget https://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz
https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl
One important addition to setting up WordPress. Permission errors with the WordPress installation can be fixed with the following command.
$ chown -R www-data:www-data /var/www/html/*
This adds permissions for the Apache server user to use the files in the webpage directory.
In Conclusion, you now have WordPress on Google Cloud Platform. Enjoy the experience and let me know in the comments if you have any issues.
I live stream on Twitch and encourage you to drop in and ask a question. I regularly publish on YouTube and christitus.com, but if you need immediate assistance, check out the Terminal Cafe with Discord Invite Link.