Easy Guide for Ubuntu Server Setup on Local Machine and Google Cloud Platform [10 Steps Only]
Easy Guide for Ubuntu Server Setup on Local Machine and Google Cloud Platform [10 Steps Only]
Taken a good step already by choosing Linux for your machine? Now let's have a brief knowledge about the server to use. Also, clear all your doubts related to its setup. Here in this article, we have covered all of which you would need for the Ubuntu server setup.

Before jumping to our main topic, how about having some background knowledge about it? Let us start from the very beginning to keep things clear and easy to get.

The first thing we would discuss during the Ubuntu server setup process is obviously what the server is and how does it actually work.

If still, you haven't decided which OS to use then here is a list of Best Linux OS Distributions to try in 2020.

What is a Server?

What-is-a-Server - ubuntu server setup - SocialMirror

A Server is a computer program that manages the access to various resources in a network. The servers form the core foundation of any IT company, be it a startup or a big business.

Linux systems are considered the best for running servers and Ubuntu among them is one of the best choices.

Why Ubuntu Server?

Coming to the Ubuntu Server - It is an open-source server operating system, developed by Canonical. It does wonders if you see its features. It works with the minimum hardware requirement like a CPU, around 2 GB of hard disk storage, and up to 512MB of RAM.

With these little requirements, Ubuntu can facilitate you as the server platform for a number of things ranging from a website to a development platform, cloud services, and even for the database servers and many more.

It can literally run on almost all major architectures out there. Whether you want it for running a small company or for an enterprise-level one, ubuntu fits in all setups.

Let us know now, how to do the Ubuntu server setup in a very easy and simple way.

Setting up Ubuntu Server on a Local Machine

Initial Setup

We need to do some initial setup before going for our main goal. To start things, we need to have the bootable ISO image in order to load on a USB drive. You can get the latest version of Ubuntu Server from the official Ubuntu download directory.

You can download Ubuntu Server from Ubuntu's Official Website also.

You can choose from a lot of versions depending on your need, but the LTS (Long-Term Support) version of Ubuntu Server is recommended for its stability and reliability.

It may be the case where you are setting up the first server or setting it up with an existing one. The other pre-requisites which you need to complete are-

  • Check the name of the Server Setup, Technician and Date of setting up the server.
  • Check the OS running on the system.

Prepare a Bootable Ubuntu Server USB

After downloading the ISO image, you need to prepare a bootable Ubuntu USB for installation. To prepare a bootable Ubuntu USB, you need to go through the following steps mentioned below-

  • Insert the drive into your computer.
  • Open Dash in there.
  • Enter “Startup Disk Creator” and open it by pressing the "Enter" button.
  • Select the appropriate USB drive.
  • Select the appropriate ISO image file.
  • Now erase all the data from the USB drive.
  • Check the “Discard on Shutdown” option.
  • And select “Make Startup Disk”.

An alternate way to prepare a bootable USB drive is to use Rufus.

Change the Computer’s Boot Order  

After preparing the USB, we need to force the system to load the UBUNTU server installation file. For this, we have to change the default boot entry. Linux doesn’t require any additional tools to be installed for this.

Let us see the steps for this-

  • Use the command - “sudo cp /etc/default/grub /etc/default/grub.bak” and press enter.
    It will help you make a backup of /etc/default/grub to ensure the safe reverting back to the previous one in case needed.
  • Use the command - “sudo gedit /etc/default/grub”.
    It helps to edit the file or the text editor to be used.
  • Use the command - "GRUB_DEFAULT = 0" to find the parameter and change it to "GRUB_DEFAULT= Index number" (of the grub menu item to be booted by default, starting with 0)
  • Use the command- “menuentry ‘Ubuntu Server 16.8’ [option] {”  to know the order of the items at "/boot/grub/grub.cfg", in case you forget it.
  • Finally, use the command- “sudo updadte-grub” to build the updated grub menu.

After booting the drive, we need to install Ubuntu Server. Before that make sure everything has been set up correctly.

Install Ubuntu Server

  • Check for the “Download updates while installing”.
  • Check for the “Install third-party software”
  • Erase everything else from there and install Ubuntu
  • Enter the user details

And it's done. The installation process will start now.

Ubuntu Server Setup

Now comes the main work of the Ubuntu server setup. The first thing which you need to do is, creating a new account at Ubuntu.

But due to the security measures, the root account is disabled in Ubuntu, by default. So you need to log in to the system with the account "User with root privileges"  and then create a new account. Let us see how-

Create a New User Account

We can provide the root powers privileges to the new account, via "sudo" command to perform administrative tasks in our system. Setup the user details and password through "adduser prompt" as the next stage of the Ubuntu server setup .

  • Run the command “sudo adduser ubuntu_user”.
    The new user won’t have administrative privileges yet. To grant the administrative privileges, add the user to the sudo system group.
  • For that, run the command “sudo usermod –a –G sudo ubuntu_user”.
    All the users from Sudo group execute the commands with root privileges via Sudo utility. So we must run a sudo command, before writing the execution commands.
  • Run “sudo apt install package_name” for that purpose.
    After this, check if the user has root privileges granted. Log in and run the below mentioned apt update command, prefixed with sudo.
  • Run the command “su – ubuntu_user”. It will ask you to change the password.
  • Run the command “sudo apt update”
  • Give the new account root privileges by using the command “# gpasswd –a username sudo
    This will help you to perform administrative commands without having to log back into the root user account. (It is an optional step.)

That's all.

After setting up the server, we may need to install some important Web server Softwares to use. Here we are mentioning some of the important software which you may need. They come as a package called "LAMP" i.e. Linux, Apache, MySQL, PHP.

Let's see how to install them one by one.

Apache Installation

Use the below-mentioned steps to install Apache on your server-

  • Run the command "sudo apt-getupdate"
  • Run the command "sudo apt-get install apache2"
  • Now verify your account by entering the user's password in the prompt.
    Check if your installation succeeded or not.
  • Enter the following in your browser - "http://your_server_IP_address"
    If you see the default Ubuntu Apache web page, that means your installation is complete.

MySQL Installation

Next, you require MySQL, to set up your server with a database management system. Let us see how it is done.

  • Run "Sudo apt-get install mysql-server php5-mysql" to start the installation.
  • Select and confirm a password to be used for the MySQL root user.
    Make sure it doesn't match with the server's root user password.
  • To set up a secure MySQL environment, create a database directory structure for storing the information using "sudo mysql_install_db".
  • Run a security script to strengthen access.
    Type the command "sudo mysql_secure_installation" and run it.
  • Enter the password of your MySQL account.
  • Select "n" to decline the offer to change it.
  • Complete all other prompts by pressing "Enter".

PHP Installation

This is the last phase of the LAMP installation where we need to install PHP. This helps in a number of tasks like processing the code and transferring it to the Web Server etc.

Let's see the installation process here.

  • Run the command “sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
    PHP must be integrated into the Apache server to prioritize PHP files.
  • Open "dir.conf" in your text editor using the command “sudo nano/etc/apache2/mods-enabled/dir.conf
  • Edit the text there to make "index.php" file as the first in the queue.
  • Save the changes and exit. (Confirm the save, once the document is closed).
    After the PHP configuration with the Apache server, restart the server to ensure that the changes took place.
  • Run the command “sudo service apache2 restart”.

You can install the additional PHP Modules if you need some.

Setting up Ubuntu Server on Google Cloud Platform

Ubuntu-Server-on-Google-Cloud-Platform - ubuntu server setup - SocialMirror

GCP - Google Cloud Platform. Who does not know about it? Still, those who don't know, it is a platform provided by Google which consists of a range of services like hosting for applications, websites, storage and much more. It provides a dedicated network connection to its users so that they can deploy their apps, websites publicly.

At present, if you go to the official website of Google Cloud Platform, you can register here for a free trial of 1 Year. On Signing Up, you will be provided with a 300$ budget which you can utilise on Cloud Resources for one year without paying anything from your end. What you will get in that free trial is listed below:

  • Google Compute Engine.
  • Google App Engine.
  • Google Container Engine.
  • Google Cloud Storage.

Google Compute Engine provides virtual machine instances that host various things - OS Servers like Windows, Ubuntu etc., CMS like Wordpress, Drupal etc.

Google App Engine allows us to deploy our developed applications on the cloud and provides and it also provides SDKs (Software Development Kit) to develop apps or software that can run on the App Engine.

Google Container Engine basically is an orchestration system which manages the Docker containers running on Google Cloud. The Container Engine relies on the Google Kubernetes Container Orchestration Engine.

Google Cloud Storage can be used to store huge and unstructured data sets. To get all features of Google Cloud Platform in detail, you can refer to the official Google Cloud Platform Overview.

Steps to Setup Ubuntu Server on Google Cloud Platform

Many users find it difficult to set up a cloud server for their websites, applications or other tasks. We have written as easy as possible steps for you to understand the things better and proceed to ubuntu server setup flawlessly. So let's begin!

Step 1 - Sign up on Google Cloud Platform. You can start your Free Trial for 1 year here - Google Cloud Platform - Free Trial!

gcp-free-account - ubuntu server setup - SocialMirror

Step 2 - Now once you Sign Up,  create a Project and go to the main Dashboard and in the Search Bar type "Compute engine". The Compute Engine will come in results, open it. You will see Compute Engine dashboard there with several options on the left-hand side.

project - ubuntu server setup - SocialMirror

Step 3 - Once you are in the Compute Engine, click on VM Instances, then click on Create to create an Instance for your Ubuntu Server.

Step 4 - After clicking on the Create button, you will be provided with a page to fill some details and requirements of your Virtual Machine Instance. There type the Name of your instance, Region and Zone where the Instance will be hosted, Memory and CPU details. (All these will cost you differently, for more Memory and better CPU, it will charge you accordingly - of course, it will be deducted from the 300$ of your free trial).

name-and-zone - ubuntu server setup - SocialMirror

Step 5 - After giving a name to your Instance and selecting the Zones and CPU, Memory etc, there will be an option to select Boot Disk for the Instance. Boot Disk will contain the image of the OS Server that you will install on the Virtual Machine. As you are installing Ubuntu Server, select Ubuntu Image from the list by clicking on the Change button. There will be many Ubuntu Images available, choose any which you want to install.

boot-disk - ubuntu server setup - SocialMirror

Step 6 - After selecting the Ubuntu image, below there you can set Boot Disk Type i.e HDD or SSD (SSD is faster but also Expensive). Also, you can mention how much Size you want for the boot disk. After doing so, click on the Select button.

Step 7 - For API Access Scopes, you can keep it default i.e Allow Default Access. For the Firewall, if you want to host HTTP or HTTPS server then you need to check both Allow HTTP traffic as well as Allow HTTPS traffic.

Step 8 - Click on the Create button in the end and your Ubuntu Virtual Machine will be installed and get live in a few moments.

Step 9 - The Ubuntu VM is live. What else is needed? There are still some things left that you need to configure. Go to your Compute Engine dashboard and there you will see the VM Instance you just created. There you can see the External IP of the Instance which is accessible by the public.
By default, you will see that the External IP is ephemeral, which will not suit you if you are using external domain name servers pointing to this address. So you need to make it static.

nic - ubuntu server setup - SocialMirror

To make it static, click on VM Instance name and then click Edit to edit the VM Instance and then move down to the Network Interface section. There will be a dropdown for External IP, select Create IP Address.
A dialog box will appear asking you for the Name of the IP and Description about it. After giving name, click on Reserve.

reserve-static-ip - ubuntu server setup - SocialMirror

After this step, your IP will change but will become Static now. And now you can easily point your external domain names to this static IP.

Step 10 - Now you have setup Ubuntu Server on Google Cloud Platform. You can access it from SSH (Secure Shell) from the Compute Engine dashboard.

An alternate way to Setup Ubuntu Server on Google Cloud Platform without Boot Disk Image:

If you do not want to go with the general flow of creating a Virtual Instance in the Compute Engine, you can directly install a pre-customized Instance from the Google Cloud Marketplace.

To do this, follow these steps:

Step 1 - Go to Compute Engine and click on Create Instance.

Step 2 - On the left-hand side, there will be a panel with various options. Select Marketplace from there and you will see a lot of pre-customized Instances ready to be installed on the Compute Engine.

marketplace-side - ubuntu server setup - SocialMirror

Step 3 - Filter the Marketplace Solutions by selecting Operating Systems from the sidebar and select Ubuntu (Whichever version you want). You can also search it from the search bar and install it on the Compute Engine.

ubuntu-marketplace - ubuntu server setup - SocialMirror

Step 4 - Follow the same steps as mentioned above (Steps to Setup Ubuntu Server on Google Cloud Platform) to customize Memory, CPU etc for the Instance.

And Finally, you have your own hosted Ubuntu Server on the Google Cloud Platform. Now do whatever you want i.e from automating the things on the server to deploying custom solutions onto it, all depends on you.

Conclusion:

Here in the article, we have discussed how to do the Ubuntu server setup on your Local Machine as well as Google Cloud Platform. We covered the server definition, why we should choose the Ubuntu server setup, the pre-requisites, and the steps for the set up in full detail.

We also tried to cover various web server software such as "LAMP" which one would need with the Ubuntu server setup. The LAMP includes three software on Linux- Apache, MySQL, and PHP overall.

Some other additional PHP applications are also there which can be installed according to the need. We have tried to cover everything which you would need.

On Google Cloud Platform, here is a quick revision on Ubuntu Server Setup:

  • Create a Google Cloud Platform Account.
  • Initiate a Project there and Activate Compute Engine in it.
  • Add a Virtual Machine Instance into Compute Engine using Ubuntu Boot Disk Image or just take a Marketplace Solution.
  • Change External IP to Static if you are using external Domain Name Services.
  • Access your Ubuntu Server Instance using Secured Shell (SSH).

If you have any query regarding Ubuntu Server Setup either on Local Machine or Google Cloud Platform, feel free to comment below and we will address your query.

For more such interesting articles, checkout at SocialMirror.

 

YOUR REACTION?