Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

Install WordPress with Apache on Google Cloud with Let’s Encrypt SSL

by Cloudbooklet
4 years ago
in Google Cloud, Compute Engine
How To Install Wordpress With Apache On Google Cloud With Let’sencrypt Ssl
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

How to Install WordPress with Apache on Google Cloud with Let’s Encrypt SSL. In this article you are going to learn how to setup and install WordPress on Google Cloud with Ubuntu 18.04 LTS, Apache, PHP 7.3 and Cloud SQL. This setup is tested on Google Cloud Platform, it will also work fine on other […]

ADVERTISEMENT

How to Install WordPress with Apache on Google Cloud with Let’s Encrypt SSL. In this article you are going to learn how to setup and install WordPress on Google Cloud with Ubuntu 18.04 LTS, Apache, PHP 7.3 and Cloud SQL.

This setup is tested on Google Cloud Platform, it will also work fine on other cloud serveices and on any VPS or Dedicated servers running Ubuntu.

Prerequisites

  1. Your Compute Engine Instance running.
  2. For setting up Compute Engine, see the Setting up Compute Engine Instance.
  3. For installing Apache, see how to install Apache in Compute Engine Instance.
  4. Install PHP 7.3 for Apache on Google Cloud Platform.
  5. Set up Cloud DNS, see the Setting up Google Cloud DNS for your domain.
  6. Google Cloud SQL Setup, see Setup Cloud SQL and connect with Compute Engine.

Setup your website

Once you have installed PHP 7.3 and Apache you can proceed to setup your directories.

ADVERTISEMENT

Your website will be located in the home directory and have the following structure.

You might also like

How To Setup Ssh Keys On Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

4 months ago
Draggan Ai Editing Tool Install And Use Draggan Photo Editor

DragGAN AI Editing Tool Install and Use DragGAN Photo Editor

4 months ago

Replace yourdomainname.com with your original domain name.

home
 -- yourdomainname.com
 ---- log
 ---- public

The public directory is your website’s root directory and logs directory for your error logs

ADVERTISEMENT

Now we create these directories and set correct permissions

You need to SSH into your VM Instance and run these commands

ADVERTISEMENT
mkdir -p yourdomainname.com/logs yourdomainname.com/public
sudo chmod -R 755 yourdomainname.com

Now create a new V host configuration for your website in the sites-available directory.

sudo nano /etc/apache2/sites-available/yourdomainname.com

Copy and paste the following configuration, ensure that you change the server_name, error_log and root directives to match your domain name. Hit CTRL+X followed by Y to save the changes.

ADVERTISEMENT
<VirtualHost *:80>
      ServerAdmin [email protected]
      ServerName www.yourdomainname.com
      ServerAlias yourdomainname.com

      DocumentRoot /home/username/yourdomainname.com/public

      <Directory /home/username/yourdomainname.com/public>
           Options Indexes FollowSymLinks
           AllowOverride All
           Require all granted
      </Directory>

      ErrorLog ${APACHE_LOG_DIR}/yourdomainname.com_error.log
      CustomLog ${APACHE_LOG_DIR}/yourdomainname.com_access.log combined
</VirtualHost>

To enable this newly created website configuration, symlink the file that you just created into the sites-enabled directory.

sudo a2ensite yourdomainname.com

Check your configuration and restart Apache for the changes to take effect

ADVERTISEMENT
sudo systemctl restart apache2

Install SSL certificate

HTTPS is a protocol for secure communication between a server (instance) and a client (web browser). Due to the introduction of Let’s Encrypt, which provides free SSL certificates, HTTPS are adopted by everyone and also provides trust to your audiences.

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install python-certbot-apache

Now we have installed Cert bot by Let’s Encrypt for Ubuntu 18.04, run this command to receive your certificates.

sudo certbot --apache -m [email protected] -d yourdomainname.com -d www.yourdomainname.com

Select all the domains you need to receive the certificate and hit Enter

The Cert bot client will automatically generate the new certificate for your domain.

Now you will be asked to create a redirection to https

Select the appropriate option and hit Enter

Renewing SSL Certificate

Certificates provided by Let’s Encrypt are valid for 90 days only, so you need to renew them often. Now you set up a cronjob to check for the certificate which is due to expire in next 30 days and renew it automatically.

sudo crontab -e

Add this line at the end of the file

0 0,12 * * * certbot renew >/dev/null 2>&1

Hit CTRL+X followed by Y to save the changes.

This cronjob will attempt to check for renewing the certificate twice daily.

Download WordPress

Now that our server software is configured, we can download and set up WordPress.

It is always recommended to get the latest version of WordPress from their website.

cd ~/yourdomainname.com/public
curl -LO https://wordpress.org/latest.tar.gz

This command will download the latest version and it needs to be extracted.

tar xzvf latest.tar.gz

Now, you can copy the entire contents of the directory into our document root.

sudo cp -a ~/yourdomainname.com/public/wordpress/. ~/yourdomainname.com/public

Next cleanup your root directory by deleting the wordpress folder and the downloaded tar file.

sudo rm -r ~/yourdomainname.com/public/wordpress
sudo rm -f ~/yourdomainname.com/public/latest.tar.gz 

Set correct permissions for the root folder. Don’t forget to replace the yourdomainname.com with your domain name

sudo chown -R www-data:www-data ~/yourdomainname.com

Installing WordPress and setting up Configuration File

Now visit your website in the browser and select the language you would like to use and click continue.

You will be prompted to enter your database, user, password, and hostname.

Enter the database name we created in Cloud SQL and the user assigned with the database with the password. Finally, enter the IP address of Cloud SQL as the hostname.

Now you can run the installation.

Once the Installation is complete we need to set the method that WordPress should use to write to the file system. Since we’ve given the web server permission to write where it needs to, we can explicitly set the file system method to “direct”. Failure to set this with our current settings would result in WordPress prompting for FTP credentials when we perform some actions like WordPress update, plugin updates, file upload, etc. This setting can be added below the database connection settings in the configuration file.

sudo nano ~/yourdomainname.com/public/wp-config.php

Find the line define('DB_PASSWORD', 'password'); and paste the following line below it.

define('FS_METHOD', 'direct');

Hit Ctrl+X and Y to save your configuration file.

Now your WordPress is installed and ready to use.

Tags: Compute EngineGoogle Cloud PlatformWordPress
ShareTweetSendShare
Cloudbooklet

Cloudbooklet

Comments 1

  1. Avatar Of Rik Rik says:
    3 years ago

    Hi there, thank you for the above instructions, very clear. However, I followed this and installing the SSH creates some kind of problem with the folder access. I get a 404 error on all requests. Any ideas on how to address this?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

Set Up Deep Learning With Nvidia, Cuda, Cudnn On Ubuntu

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

7 months ago
How To Install Or Upgrade Php 8.2 On Ubuntu 22.04

How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

9 months ago
How To Change Timezone On Ubuntu 22.04

How to Change Timezone on Ubuntu 22.04

1 year ago
How To Install Ansible On Ubuntu 22.04

How to Install Ansible on Ubuntu 22.04

1 year ago

Follow Us

Trending Articles

Contact Poster On Iphone

How to Create and Customize Stunning Contact Poster on iPhone

September 21, 2023

Microsoft Surface Event: The Most Exciting and Innovative Launches and Updates

AI Statistics and Trends: What You Need to Know in 2023

Top 10 Advantages of a Cloud VPS Server

7 Best AI Girl Generators for Creating Realistic and Beautiful AI Girls

10 Best AI Prompts for Writers to Improve Website SEO

Popular Articles

Cleanup Ai

10 FREE Cleanup AI Tools to Remove Objects and Cleanup Pictures

September 11, 2023

OpenAI Introduces ChatGPT Enterprise for Businesses

10 Best AI Summarizer Tools in 2023: A Review and Comparison

Amazon Prime Big Deal Days 2023: Best Deals

Top 7 Free Dating Sites for Men in 2023

10 Best Email Autoresponder Tool for Lead Generation

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.