Comprehensive Guide to Setting Up a Google Cloud Virtual Machine for Web Hosting
![]() |
Google Cloud Virtual Machine Using Plesk |
A Comprehensive Guide to Setting Up a Web Hosting Site on a Google Cloud Virtual Machine Using Plesk
Setting up a web hosting site has become more accessible than ever, thanks to the advent of cloud computing and user-friendly control panels like Plesk. Google Cloud Platform (GCP) offers a robust environment for hosting websites, and when combined with Plesk, it simplifies the management of your hosting environment. This article provides a step-by-step guide to setting up a web hosting site on a Google Cloud virtual machine using Plesk.
Table of Contents
Introduction to Web Hosting on Google Cloud and Plesk
Prerequisites for Setting Up Your Hosting Environment
Step 1: Creating a Virtual Machine on Google Cloud
Step 2: Configuring Your Virtual Machine
Step 3: Installing Plesk on Your Virtual Machine
Step 4: Configuring Plesk for Web Hosting
Step 5: Setting Up Your Website
Step 6: Securing Your Server
Step 7: Maintaining Your Server
1. Introduction to Web Hosting on Google Cloud and Plesk
Google Cloud Platform offers a powerful and scalable infrastructure for hosting websites. By leveraging Google Compute Engine, you can create virtual machines (VMs) that serve as the backbone for your web hosting needs. Plesk, a leading web hosting control panel, simplifies the management of your hosting environment by providing an intuitive interface for setting up websites, managing domains, and configuring server settings.
This guide will walk you through the process of setting up a web hosting site on a Google Cloud virtual machine using Plesk. It is designed to be comprehensive, ensuring that even users with minimal technical expertise can follow along.
2. Prerequisites for Setting Up Your Hosting Environment
Before you begin, ensure you have the following:
A Google Cloud Account: If you don’t already have one, sign up for a Google Cloud account. You can start with the free tier to explore the platform before committing to paid services.
Basic Knowledge of SSH: You’ll need to connect to your virtual machine using SSH, so familiarity with basic SSH commands is helpful.
Domain Name: If you plan to host a live website, you’ll need a registered domain name. You can purchase one from a domain registrar or use Google Domains.
Billing Information: While Google Cloud offers a free tier, some services may require a valid payment method.
3. Step 1: Creating a Virtual Machine on Google Cloud
Log in to Google Cloud Console: Navigate to the Google Cloud Console and log in with your Google account.
Select a Project: If you have multiple projects, select the one you want to use for your web hosting. If you don’t have a project, create a new one.
Navigate to Compute Engine: In the sidebar, select Compute Engine > VM instances.
Create a New VM Instance: Click on Create VM Instance.
Choose Your Machine Configuration:
Machine Type: Select a machine type that suits your needs. The f1-micro instance is a good starting point for small websites.
Boot Disk: Choose a boot disk image. For this guide, we recommend using Ubuntu or CentOS, as they are compatible with Plesk.
Networking: Ensure your VM is assigned a public IP address. You can also configure a static IP address if needed.
Add Firewall Rules: Under the Networking tab, add firewall rules to allow HTTP and HTTPS traffic. Check the boxes for Allow HTTP traffic and Allow HTTPS traffic.
Create the VM: Review your settings and click Create.
4. Step 2: Configuring Your Virtual Machine
Connect to Your VM via SSH:
In the Google Cloud Console, navigate to Compute Engine > VM instances.
Find your VM instance and click on the SSH button next to it. This will open a browser-based SSH terminal.
Alternatively, you can connect to your VM using a tool like PuTTY if you’re on Windows.
Set Up a Static IP Address (Optional):
If you plan to host a live website, you’ll need a static IP address. Navigate to VPC Network > External IP addresses and reserve a static IP address.
Update Your System:
Run the following commands to update your system packages:
sudo apt update && sudo apt upgrade -y
For CentOS/RHEL:
sudo yum update -y
5. Step 3: Installing Plesk on Your Virtual Machine
Download and Install Plesk:
Plesk offers an automated installation script. Run the following command:
sudo wget https://autoinstall.plesk.com/one-click-installer && sudo chmod +x one-click-installer && sudo ./one-click-instagramer
Follow the on-screen instructions to complete the installation. The process may take several minutes.
Access Plesk:
Once the installation is complete, you can access Plesk by visiting http://your-server-ip:8880 in your web browser.
Log in using the root credentials for your VM.
6. Step 4: Configuring Plesk for Web Hosting
Initial Plesk Setup:
After logging in, you’ll be prompted to set up your Plesk profile. Enter your name, email address, and set a strong password.
Configure your server settings, including the server name, time zone, and default IP address.
Create a Hosting Plan:
Go to Hosting Plans under the Hosting section.
Create a new hosting plan that defines resource limits for your website (e.g., disk space, bandwidth, and number of domains).
Set Up a Domain or Subdomain:
Navigate to Domains under the Hosting section.
Click on Add a domain and enter your domain name. If you’re using a subdomain, you can create it here as well.
Configure DNS Settings:
Update your domain’s DNS records to point to your Google Cloud VM’s IP address. This typically involves setting an A record for your domain and a CNAME record for any subdomains.
7. Step 5: Setting Up Your Website
Upload Your Website Files:
Use an FTP/SFTP client like FileZilla to upload your website files to your Plesk server. You can also use the built-in File Manager in Plesk.
Upload your files to the appropriate directory for your domain (e.g., /var/www/vhosts/yourdomain.com/httpdocs).
Set Up Databases:
If your website requires a database, create a new database and user in Plesk under the Databases section.
Ensure your website is configured to connect to the database using the correct credentials.
Secure Your Website with SSL:
Install an SSL certificate to secure your website. Plesk offers a free Let’s Encrypt SSL certificate option. Navigate to SSL/TLS Certificates and follow the instructions to obtain and install an SSL certificate.
8. Step 6: Securing Your Server
Configure a Firewall:
Ensure that your server has a firewall configured to allow only necessary ports (e.g., 80, 443, 22, and 8880 for Plesk).
You can use UFW (for Ubuntu) or firewalld (for CentOS) to configure your firewall rules.
Change the SSH Port:
Edit your SSH configuration to use a non-default port. Open the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Change the Port directive to a custom port number and restart the SSH service.
Disable Root Login:
For enhanced security, disable root login via SSH. Instead, use a non-root user with sudo privileges.
9. Step 7: Maintaining Your Server
Regular Backups:
Configure regular backups in Plesk to ensure your data is safe in case of a failure. You can set up backups to be stored locally or on a remote server.
Monitor Resource Usage:
Keep an eye on your server’s resource usage (e.g., CPU, memory, and disk space) to ensure it’s running smoothly.
You can use Google Cloud Monitoring or Plesk’s built-in monitoring tools to track performance metrics.
Update Software Regularly:
Regularly update your operating system, Plesk, and any installed software to ensure you have the latest security patches and features.
10. Conclusion
Setting up a web hosting site on a Google Cloud virtual machine using Plesk is a straightforward process that offers a high degree of control and scalability. By following the steps outlined in this guide, you can create a robust and secure hosting environment tailored to your needs. Whether you’re hosting a personal blog, a small business website, or a high-traffic e-commerce site, this setup provides the flexibility and performance you need to succeed.
Remember to stay vigilant about security, maintain regular backups, and keep your software up to date to ensure your hosting environment remains reliable and secure.
Additional Resources:
Google Cloud Documentation
Plesk Documentation
Let’s Encrypt
Transcript, visit our blog.
By mastering these steps, you’ll be well on your way to becoming a proficient web hosting administrator using Google Cloud and Plesk.
Today, we're going to look at how to set up a web hosting site on a Google Cloud virtual machine using Plesk. Let's get started.
To set up a web hosting site on a Google Cloud virtual machine using Plesk,
You'll need to follow a few simple steps.
We'll cover everything you need to know from creating a virtual machine on Google Cloud to installing and configuring Plesk for web hosting.
We'll also provide tips and best practices to help you set up a reliable and secure hosting environment. So let's get started.
First, let's create a virtual machine on Google Cloud.
To create a virtual machine, you must have a Google account and then log in to the Google Cloud console.
From the main page, navigate to the Compute Engine section and click on VM instances.
Click on Create VM Instance and select the machine type.
You can choose from a variety of machine types depending on your needs. However, for most small to medium websites, the f1-micro instance should suffice.
Next, you'll need to select a boot disk image
You can choose from various images, but we recommend using either an Ubuntu or CentOS image as these are compatible with Plesk.
Once you've selected your boot disk, you'll need to configure your networking settings.
Make sure to assign your VM a public IP address.
This will allow you to access your VM from the internet.
You'll also need to add firewall rules to allow traffic to your VM.
You can do this by clicking on the edit button in the Firewall tab.
Allow HTTP and HTTPS traffic by checking the corresponding boxes.
Finally, click on Create to create your virtual machine.
Once your virtual machine has been created, you can access it via SSH.
To do this, navigate back to the VM instances page and select your VM.
Then click on the SSH button to open a browser-based SSH terminal.
Alternatively, you can connect to your VM using a tool like PuTTY if you're on Windows.
Once you've connected to your VM, you'll need to set up a static IP address.
This will ensure that your website is accessible even if the IP address of your VM changes.
To set up a static IP address, navigate to VPC Network > External IP addresses and reserve a static IP address.
Once you've reserved your static IP address, you'll need to update your VM's network interface to use it.
You can do this by running the following command: sudo ip addr change your_static_IP_address dev your_network_interface.
Next, you'll need to update your system to ensure you have the latest packages installed.
You can do this by running the following command: sudo apt update&& sudo apt upgrade -y.
Now that your system is up to date, you can proceed to install Plesk.
To install Plesk, run the following command: sudo wget http://autoinstall. plesk. com/one-click-installer && sudo chmod +x one-click-installer && sudo . /one-click-installer.
Follow the instructions on the screen to complete the installation process.
This may take a few minutes, so please be patient.
Once the installation is complete, you can access Plesk by opening your web browser
and navigating to http: //your-server-IP: 8880. Log in using the root credentials that you used during the installation process.
Now that you've installed and logged into Plesk, it's time to configure it for web hosting.
The first thing you'll want to do is create a hosting plan.
his will define the resources that your website will have access to, such as disk space and bandwidth.
To create a hosting plan, navigate to the hosting section and click on Hosting Plans.
Click on the Create Hosting Plan button and select the type of plan you want to create.
Plesk offers a variety of plans to choose from, so you should be able to find one that meets your needs.
Once you've created your hosting plan, you'll need to set up a domain or subdomain.
This is the name that people will use to access your website.
To set up a domain or subdomain, navigate to the domains section and click on Add a domain.
Enter your domain name or subdomain name and click on OK.
Now that you've created a hosting plan and set up a domain, you can set up your website.
You can upload your website files using an FTP client like FileZilla or you can use the built-in file manager in Plesk.
To upload your website files using FileZilla, connect to your server and upload your files to the /var/www/vhosts/httpdocs/your_domain_name folder.
f you're using a subdomain, make sure to replace your_domain_name with the subdomain name.
Next, you'll want to set up any databases that your website might need.
To create a database, navigate to the databases section and click on Add a Database.
Enter a name for your database and click on OK.
You'll also need to create a database user and grant them the necessary permissions.
Once you've created your database and user, you can connect your website to it.
The next step is to configure your domain's DNS settings.
In this case, you'll want to add an A record for your domain and a CNAME record for any subdomains.
You 'll need to update your domain 's DNS records to point to your Google Cloud VM 's IP address.
This will ensure that people can access your website by using your domain name.
Most domain registrars will have a section in their control panel where you can manage your domain 's DNS settings
Look for the section that says something like DNS Management or DNS Settings.
Once you find it, click on it to open the DNS settings page.
Now you'll need to add a new DNS record for your domain.
Depending on your domain registrar, this may be done by clicking on a button or link labeled Add Record.
When the new record window opens, select the type of record you want to add.
In this case, you'll want to add an A record for your domain and a CNAME record for any subdomains.
An A record is used to map a domain name to an IP address.
CNAME record is used to map a subdomain to another domain name.
Once you've added your DNS records, you'll need to save them.
This usually involves clicking on a button or link labeled Save or Save Changes. And that's it.
Your domain is now pointing to your Google Cloud VM.
Next, let's set up an SSL certificate for your website.
An SSL certificate is essential for encrypting the connection between your website and your visitors' browsers.
Plesk makes it easy to set up an SSL certificate for your website.
Simply navigate to the SSL/TLS certificates section and click on Add Certificate.
Follow the instructions on the screen to complete the process.
Now that your website is set up and secured, it's time to configure your server.
There are a few important things you 'll want to do to ensure that your server is running smoothly.
First, you'll want to configure a firewall on your server.
A firewall will help protect your server from unauthorized access and attacks.
You can use the built-in firewall on Ubuntu or CentOS to configure your firewall rules.
Next, you'll want to change the SSH port.
This will help prevent brute force attacks on your server.
To change your SSH port, open the SSH configuration file and change the Port directive to a custom port number.
Finally, you'll want to disable root login via SSH. Instead, use a non-root user with sudo privileges.
That's it. You've now successfully set up a web hosting site on a Google Cloud virtual machine using Plesk.
Congratulations.
Finally, let's discuss some tips for maintaining your server.
Regular backups are essential for ensuring that you can recover your data if something goes wrong.
You can set up regular backups in Plesk by navigating to the backups section and selecting the backup type.
You can also choose to store your backups on a remote server for added security.
To monitor your server's performance, you can use the built-in monitoring tools in Plesk or you can use Google Cloud Monitoring.
You'll also want to keep your server software up to date to ensure that you have the latest security patches and features.
0 Comments