Kuberty.io
  • blog
Kuberty.io

Ubuntu

Home / Ubuntu
24Jun

How to Install and Use PHP Composer on Ubuntu 20.04?

June 24, 2022 admin Uncategorized

The composer program is a PHP tool for managing project dependencies. Recently, it has become an extremely popular tool, and possibly the most effective as well. Follow this guide for complete instructions on installing and using PHP Composer on Ubuntu.

Before we begin with the step-by-step tutorial, let’s understand more about the basics.

What is PHP Composer?

Composer is a PHP project dependency management tool. It lets you stipulate the libraries your project relies on. It also installs or updates them.

Now, you will be thinking about what PHP is.

PHP is an acronym that stands for Hypertext Preprocessor. It is a prominent open-source scripting language. PHP is free to use, and its script runs on the server. Server-side languages like this are easy to use and are suitable for beginners.

It is efficient enough to be at the heart of the world’s largest blogging platform – WordPress! And it is sharp enough to power the biggest social networking site in the world – Facebook!

PHP files can contain HTML, Text, JavaScript, CSS, and PHP code. PHP files are indicated by the extension “.php.”.

PHP works on multiple systems, including Windows, Linux, Unix, Mac OS X, and is compatible with nearly all modern servers, notably Apache, IIS, and others.

PHP has been criticized previously for lacking a dependency management tool. Before the introduction of Composer, there had been unsuccessful efforts to establish a common PHP dependency management tool, such as PHPPM and Pyrus, which were designed to manage PEAR packages.

And finally, in 2012, PHP Composer was released as a package management tool to install and manage PHP modules. Following that, one can easily incorporate these modules into their project.

It assists users in installing the appropriate version of PHP modules within your app. It also keeps track of all the loaded modules and their versions. All entries are saved in a folder titled composer.json.

What is Ubuntu?

Well, this is an easy one. Ubuntu is a free Linux operating system with community and professional support.

Ubuntu is a community built on principles outlined in the Ubuntu Manifesto: that software should be free, that software tools should be accessible in any language and regardless of disability, and that people should be free to modify and customize their software in any way they like.

This guide will walk you through steps to install and configure PHP composer on Ubuntu 20.04 LTS systems.

Requirements:
  • Shell access to Ubuntu system that is up and running
  • Preinstalled PHP 5.3 or above on Ubuntu 20.04
  • You must have Sudo access and should be logged in as a non-root user.
  • Make sure your server’s firewall is powered on.

Let’s find out how to Install and Use PHP Composer on Ubuntu 20.04

Installing:

  • PHP has to be there on your PC for Composer to work. You might not have PHP installed. In that case, run the commands underneath to refresh your apt-cache and install PHP. Composer requires php-cli to run PHP scripts from the command line, as well as unzip to extract compressed packages.
  • Run the following command in your terminal to update the package manager cache:

$ sudo apt update

  • To install the needed packages use the command below

$ sudo apt install php-cli unzip

  • You’ll also have to install a few extra packages on your system. Use the shell to run the commands listed below.

$ sudo apt install unzip curl

  • After you’ve installed all of the essential packages, run the following command to check the existing PHP command line version:

$ php -v

  • Now, we’ll check to see if the downloaded installation matches the SHA-384 hash for the most recent installer, which can be obtained on the Composer Public Keys / Signatures page.

$ HASH=`curl -sS https://composer.github.io/installer.sig

  • If you prefer to verify the result, run:`

$ echo $HASH

  • Finally, perform the PHP code given on the Composer download page to ensure that the installation script is suitable to run

php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘$HASH’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”

  • Now, apply the next command to download the executable file of the composer to your PC.

$ curl -sS https://getcomposer.org/installer | php

  • Now execute the following commands to make Composer accessible to all users on your system so that all PHP programs on that system may use it.

$ sudo php composer-setup.php –install-dir=/usr/local/bin –filename=composer

  • Following the installation of the Composer on your PC. At the command terminal, type composer. This will give you the composer version as well as the options accessible with the composer command.

$ composer -v

Using:

A composer.json file is required to utilize Composer in any project. Composer uses the composer.json file to determine which dependencies to download for the project, as well as which versions of each package are authorized for installation. This is critical for maintaining the project’s relevance and preventing installation of fragile versions that may cause backwards compatibility issues.

You do not need to construct this file manually; doing so will almost certainly result in syntax errors. The composer provides an interactive mechanism for generating a new composer.json file depending on the user’s data, which is useful if you plan to distribute the project next as an unrestricted package on Packagist.

  • By using the same commands as during installation, you may obtain the latest versions of the Composer. The Composer is also capable of updating itself. To update the Composer, run the below-mentioned command.
  • Existing Project: Drive to the program root directory and administer the following command. It will read composer.json and install the application’s dependencies.

$ Composer install

  • New Project: To begin a new project, navigate the project directory and run the following command to install the necessary modules.

$ mkdir myapp && cd myapp

$ composer require psr/log

The command above will install the psr/log module in the vendor directory. It also adds an entry to composer.json and updates composer.lock.

Upgrading:

The Composer has the ability to upgrade itself. By executing a self-update, Composer will be brought up to date. Otherwise, you can get the most recent version of Composer by running the same commands you used to install it.

$ sudo composer self-update

Conclusion

Composers are becoming more popular as tools for managing project dependencies in PHP.

In PHP development, if norms are followed, better language could be developed. The composer has successfully resolved a critical issue in the PHP community, so there is no reason not to embrace it immediately.

We’ve covered the basics of Composer and how to install and use PHP Composer on Ubuntu.

We are hoping we’ve made your life a little easier!

Read more
16Jun

Methods of Installing Node.js and npm on Ubuntu Server?

June 16, 2022 admin Server, Ubuntu

What can be better than a platform that allows you to run a specific JavaScript code without a web browser? Well, being a reliable JavaScript environment, Node.js does the work decently. This special feature makes Node.js a great choice for JavaScript developers. Besides, the collaboration of Node.js with npm makes JavaScript coding way easier. Needless to say that installing Node.js on Ubuntu offers loads of benefits to Ubuntu users. Especially the latest Ubuntu 18.04 version, which has already been popular among developers and JavaScript writers. Installing Node.js on the latest version of Ubuntu enables the user to utilize the features of the OS in better ways.

However, you need to gather adequate knowledge about Node.js and npm before installing the open-source environment on Ubuntu. Though the process is not that hard, you need to execute the entire process consciously to avoid flaws. Beforehand, let’s discuss Node.js and npm so that you don’t face difficulties while installing these applications as every Ubuntu user is not tech-savvy. So, let’s move on to the next phases of the article.

Introduction to Node.js

At present, no server-side environment has earned as much popularity as Node.js. It is a server-side environment with loads of programming benefits. Being an open-source environment, Node.js gained popularity among developers as this is accessible for all. Moreover, Node.js has shortened the time frame required to write JavaScript programming. Let’s have a glance at why you should go for Node.js over PHP or ASP.

  • Anyone with the basic knowledge of JavaScript can learn using Node.js early.
  • The scalability of Node.js is beyond question. There is no doubt that the environment is way more scalable than other server-side environments.
  • MVP development becomes way more convenient and straightforward as you go for Node.js over other server-side platforms.
  • Node.js is suitable for platforms and operating systems.

As you see, Node.js is beneficial from every aspect in terms of JavaScript programming and development. So, we suggest you start using this convenient server-side environment to run your JavaScript programs on Ubuntu.

npm in a Nutshell

Using Node.js becomes way easier because of its official package manager npm. Being the world’s biggest software registry software, consisting of 8 lakh code packages, npm is the best library to date. npm makes it easier and more convenient to install Node.js on Ubuntu. The package installer is easily accessible and that’s why it got a preference from programmers and developers.

Now, let’s jump into the main procedure of installing Node.js and npm on Ubuntu.

How to Install Node.js and npm on Ubuntu?

Multiple methods are available for installing Node.js and npm on the Ubuntu server. Apart from the simple approach towards installing Node.js and Ubuntu, there are other flexible methods to do so. We are going to discuss all those methods in the following segments.

Prerequisites

If you’re using Ubuntu 18.04, make sure you have the access to a non-root account that already has sudo privileges set up. Generally, this set-up isn’t an in-built feature of the Ubuntu OS and you’re likely to set up your server manually.

Conventional Method to Install the Distro-stable Version on Ubuntu system

Did you know that a version of Node.js comes with the Ubuntu OS as an in-built feature? The version comes as a default depository with Ubuntu systems. The in-built version of Node.js, which comes as an in-built repository, isn’t the latest version of the server-side environment, but it does the job. Generally, the 8.10.0 version turns out to be available in the default repository of Node.js.

You may use the apt package manager to get the latest version of the Node.js repository and you need to refresh your local package index by using the following command:

sudo apt update

Now, input the following command to install Node.js from the local repository:

sudo apt install nodejs

Generally, the package available in the repository turns out to be efficient for writing JavaScript by an individual. However, downloading the npm package manager to manage the Node.js repository is a better way. Doing that becomes easier by entering this command:

sudo apt install npm

To ensure that you have installed the correct version of Node.js, use the command:

nodejs -v

If you’re satisfied with the version of Node.js that you’ve installed from the Ubuntu repository, start using Node.js with the help of the npm package on your Ubuntu server.

How to Use PPA to Install Node.js and npm in the Ubuntu Server?

There’s no reason to use an outdated version of Node.js when you can install the latest version of Node.js using the PPA. NodeSource executes the responsibility of maintaining PPA or personal package archives. This method will allow you to download all the latest and upgraded versions of Node.js.

Let’s have a close look into the entire process:

  • No need to mention separately that you need to download the PPA to access the packages in it. You have to use curl in terms of retrieving your desired version’s installation script. As the installation script appears on the screen, you must replace the 10.x with the string of the version you want to install. Use the following command for that:

cd ~

curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh

  • You have the option to look into all the contents of the script with this command:

nano nodesource_setup.sh

  • Input this command to run the script under sudo:

sudo bash nodesource_setup.sh

  • Congratulations! You have successfully added the PPA to your system. The process also automates the updating of your system’s local package cache.
  • Now, install Node.js and npm in your system as mentioned in the above method. The procedure is the same in this method too.
  • It’s better to verify whether npm is installed in your device by using the following command:

npm -v

Output

6.14.6

  • If you find that the npm package is not functioning as it should, use this command to install the build-essential package:

sudo apt install build-essential

  • That’s all. You’re done.

Method of Installing Node.js and npm with NVM

Installing Node.js using the nvm tool has been very popular recently. The best thing about the nvm tool is that you get the chance to install the latest version of Node.js and retain the older versions in your system simultaneously. Having the nvm tool installed means that you have a separate independent directory under the main home directory. Go through the following to understand the process in a better way.

  • It’s the best choice to use curl for downloading nvm installation scripts from GitHub. You need to input the following code to perform this:

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh -o install_nvm.sh

  • Now, it’s time to verify the installation using nano. Input this:

nano install_nvm.sh

  • In this step, you should bash to run the script. This code will help you do so:

bash install_nvm.sh

  • Don’t look for the nvm package in your home directory, rather check for a subdirectory named ~/.profile. To access the nvm package, log out of the session. After that, login again. Else, you can use the code below to inform your current session about the changes that happened in the system:

source ~/.profile

  • As the installation process has been completed, you have the option to install isolated Node.js versions separately. This command will let you know all the information regarding all the available Node.js versions:

nvm ls-remote

Output

…

v12.18.3 (Latest LTS: Erbium)

v13.0.0

v13.0.1

v13.1.0

v13.2.0

v13.3.0

v13.4.0

v13.5.0

v13.6.0

v13.7.0

v13.8.0

v13.9.0

v13.10.0

v13.10.1

v13.11.0

v13.12.0

v13.13.0

v13.14.0

v14.0.0

v14.1.0

v14.2.0

v14.3.0

v14.4.0

v14.5.0

v14.6.0

v14.7.0

  • You will be able to see the latest LTS version in the output and you can install that version by inputting:

nvm install 12.18.3

  • Typing the following command lets the nvm know about the Node.js version you’re using:

nvm use 12.18.3

  • You can also inspect which version of the node the shell is accessing by inputting this command:

node -v

  • Check all the downloaded node versions with the command:

nvm ls

  • To set one of the nodes as default in your system, use the command:

nvm alias default 12.18.3

Now, let’s come to installing npm using this method.

  • Firstly, you need to use this syntax so that the express module gets installed in your system:

npm install express

  • With the following command, you can install the module globally. That’s how you make the module available for the same Node.js versions.

npm install -g express

  • The package will get installed as:

~/.nvm/versions/node/12.18.3/lib/node_modules/express

  • Type in the following command to get information about all the available options with nvm:

nvm help

Conclusion

So, now you know all about the installation procedure of Node.js and npm on the Ubuntu server. All these methods are vastly used by programmers and developers. Needless to say that Node.js and npm collectively help your Ubuntu system perform different types of programming tasks. Being an excellent server-side environment, Node.js is extremely beneficial and friendly for beginners. If you have stepped into the programming industry recently, there is nothing better than Node.js, and installing this environment on your Ubuntu server makes your user experience way better. So, consider using Node.js and npm on your Ubuntu server following the step-by-step guide mentioned above.

Read more
31May

How to Install TensorFlow GPU on Ubuntu 18.04 LTS?

May 31, 2022 admin Ubuntu

With TensorFlow, you can do a number of important tasks. It supports the urgent execution of the machine-learning model, automatic differentiation, multi-GPU/distributed training, and more. However, the latest and biggest feature of Tensorflow is Keras that works as the deep-learning API tool for the open-source machine-learning platform. TensorFlow GPU was developed by Google for data scientists and researchers to help them implement machine-learning models easily.

TensorFlow can perform multiple numerical computations to help you with machine-learning techniques. Since it works equally great in CPUs, GPUs, and smartphones (Android & iOS both), you won’t have a problem using it. However, in this article, we have shared our guide on installing TensorFlow GPU on Ubuntu 18.04. To install it on an older or later version of Ubuntu, you can check out our other guides. But for now, keep reading this article and follow the quick steps to know How to Install TensorFlow GPU on Ubuntu 18.04 LTS.

But before we begin with the installation process, we want you to know a little bit about the Keras implementation in TensorFlow 2.0. The Keras feature is only available in version 2 of TensorFlow. Keras help you train your deep neural networks as well as fix bugs. The features and implementations of Keras should be inside the tf.keras package.

Now, it’s time to get started with the process for installing TensorFlow GPU on Ubuntu 18.04.

Things to Note Before Starting the Installation Process

Before we start with the installation steps of TensorFlow GPU on Ubuntu, here are some things you must know:

  • This article is for Python users only who are coding with IDE and virtual environments that are not related to Anaconda.
  • If you are using Anaconda, we encourage you to check out our other guides created especially for installing TensorFlow GPU on Anaconda.
  • Though we have highlighted the installation process for Ubuntu 18.04 LTS, the same steps should help you install TensorFlow GPU on other Ubuntu versions.
  • Lastly, sometimes you need to configure your TensorFlow to work. If downloading only all the CUDA/cuDNN packages doesn’t help, you need to configure your TensorFlow.

Prerequisites for Installing TensorFlow GPU on Ubuntu

Before you install TensorFlow on Ubuntu, make sure you fulfill the following requirements:

  • Your machine should have an NVIDIA graphics card.
  • Your system should be running the Ubuntu 18.04 LTS version.
  • Make sure you have established a Python development environment for machine learning on your Ubuntu system.
  • You should access the command line/terminal window.
  • You should have the sudo privileges for your user account.
  • You need pip 19.0 or a later version.

Step-by-Step Guide for Installing TensorFlow GPU on Ubuntu 18.04 LTS

Step 1: Download the Required Packages

We have told you that you need the Python development environment in order to run TensorFlow on your Ubuntu system. So, you should have the Python version 3.4 or later and the pip package manager, which should not be earlier than the 19.0 version, installed on your system. Along with that, you need Virtualenv, which is a software specially designed for isolating Python environments.

To set up the Python package, you can run some simple commands on the terminal. Run, sudo apt update and this command will update the repository.

When the update is completed, run sudo apt install python3-dev python3-pip. This will install the python and pip package on your computer.

To install the Virtualenv software, run the following command:

sudo pip3 install -U virtualenv

Once these packages are installed successfully, it’s time to check out the status of your NVIDIA graphics card driver. Your graphics card should be NVIDIA compute 3.0 otherwise TensorFlow won’t run. You can visit this page to acquire deeper knowledge regarding the compute compatibility for TensorFlow. You can check out if the NVIDIA graphics card is installed or not with the command as follows:

nvidia-smicommand

To install the NVIDIA graphic card driver on your system, run the following command:

$ modinfo nvidia | grep version

You can also update the NVIDIA driver with the following command:

$ ubuntu-drivers devices

Once the installation and update are done, reboot your computer.

Once certain packages have been installed, we will generate a virtual environment for TensorFlow on Ubuntu.

Step 2: Create a Virtual Environment

We have mentioned that installing the Virtualenv software on your Ubuntu system will isolate your Python environments. Also, it will help you create a virtual Python environment the same way. You can create a virtual environment in a /venv directory with the following command:

virtualenv –system-site-packages -p python3 ./venv

And this command will activate the virtual environment and keep it running:

source ./venv/bin/activate

The shell prompt that appears in the output will have the (venv) prefix. When the output appears, it shows that you have successfully initiated the environment. After activating the virtual environment, you will have to install the pip package inside of that isolated environment:

pip install –upgrade pip

To see all the packages that are staying in the virtual environment, use the following command:

pip list

Now an output will appear where you will be able to see all the packages along with their individual versions. After creating the virtual environments, we will install the CUDA Toolkit and cuDNN Library that will help us go ahead further with the TensorFlow installation process.

Step 3: Install CUDA Toolkit and cuDNN Library

Since we already have the latest version of NVIDIA drivers, it’s time to install the CUDA Toolkit that will be compatible with your NVIDIA driver. It can be possible that you have the toolkit already installed on your system. But whether you are running the right version or not, this command will help you know:

$ nvcc –version

$ apt list –installed | grep -i nvcc

If the CUBA version is incompatible or not working out for you, you can uninstall it using the following commands:

$ sudo apt-get — purge remove “*cublas*”

$ sudo apt-get — purge remove “cuda*”

You can install the right version of the CUBA toolkit from here, and this link will tell you how to install the CUBA toolkit that will be compatible with your Tensorflow GPU libraries. In the CUBA Toolkit archive, you will find the respective compatible version of CUBA for different versions of Ubuntu. For example, Ubuntu 18.04 generally supports CUDA Toolkit 10.0. So, you will have to find that option on the archive page and click on the “Download” button.

Once the CUBA toolkit is installed, go ahead and install the cuDNN library.

To check if the cuDNN library is installed or not and compatible with your system, run this command:

$ apt list –installed | grep -i libcudnn

You can remove the existing version of the cuDNN library with this command if it is not compatible with your system:

$ sudo apt-get –purge remove “libcudnn7*”

Then visit here and click on Download cuDNN. First, you will have to sign up or log in to the page. If you have not signed up before, register and agree to the terms to see the cuDNN Download page. On the Download page, you will find your suitable cuDNN version but if it is not there, click on “Archived cuDNN Releases”. The cuDNN version needs to match the CUBA version, for example, cuDNN 7.6.3 with CUDA 10.0.

Once you find the option, click on it and download the three Deb Files for your Ubuntu 18.04 system. Here are the three main files you should download:

  • cuDNN Runtime Library
  • cuDNN Developer Library
  • cuDNN Code Samples and User Guide

You can run these commands to install those downloaded files:

$ sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.0_amd64.deb

$ sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.0_amd64.deb

$ sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.0_amd64.deb

When you are using these commands, make sure to change the names of the files with the ones you have downloaded earlier. However, keep in mind that you should not allow these files to get updated automatically otherwise they would no longer be compatible with your system. To hold the version, use these commands:

$ sudo apt-mark hold libcudnn7 libcudnn7-dev

$ apt-mark showhold

Once all the packages are installed successfully, it’s time to start with the TensorFlow installation.

Step 4: Install TensorFlow GPU and Keras on Ubuntu

The TensorFlow version needs to be supported by the CUDA Toolkit and cuDNN libraries that you have previously installed. Since we have installed CUDA 10.1, it will support any version of TensorFlow. But you can also install a specific version of TensorFlow.

In this section, we will be installing the TensorFlow for GPU 1.14 version with the following command:

$ pip install “tensorflow-gpu==1.14.*”

$ pip install keras

Verify the version with this command:

$ pip list | grep -i tensor

$ pip list | grep -i keras

Now you have successfully installed TF but you will have to check the status of the installation. You need to verify if both the cuDNN and TensorFlow GPU are working or not. To verify the cuDNN installation, run these commands:

$ cp -r /usr/src/cudnn_samples_v7/ $HOME

$ cd $HOME/cudnn_samples_v7/mnistCUDNN

$ make clean && make

$ ./mnistCUDNN

When the cuDNN works properly, they show you the Test passed! Message. You can verify TensorFlow with your command line too. Run these commands on the terminal:

$ python

>>> import tensorflow as tf

>>> print(tf.test.gpu_device_name())

>>> quit()

If your TensorFlow is working well, it should show you out like this:

/device:GPU:0

If you want to monitor the current CPU usage and temperature of your TensorFlow GPU process, you can run these commands:

$ nvidia-smi

$ watch -n 5 nvidia-smi

It will show you all the information about the TensorFlow GPU on your Ubuntu system.

How to Install TensorFlow for CPU on Ubuntu?

When it comes to installing TensorFlow CPU on Ubuntu, here are the commands:

For installing TensorFlow for CPU 1.14: pip install tensorflow==1.14, and TensorFlow 1.15: pip install tensorflow-gpu==1.15rc2.

That’s all you need to install the TensorFlow on Ubuntu and it’s all an easy process. The command python -c “import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))” will help you verify the installation with ease.

With TensorFlow on Ubuntu 18.04 LTS, you can improve your Deep Learning projects. But for whatever reason you need help with the same, feel free to drop us a command below. Alternatively, you can use Google Colab or Docker for your cloud solutions. Google Colab offers GPU and TPU for free.

Conclusion

That’s all about installing the TensorFlow GPU on Ubuntu 18.04 LTS. However, here, we have only mentioned how to install TensorFlow for GPU 1.14. The installation process of TensorFlow for CPU 1.14 and TensorFlow 1.15 works the same way with different commands. You will have to go through all the steps given above to install the TensorFlow on Ubuntu 18.04 LTS.

Read more
09May

How to Install Rancher on Ubuntu?

May 9, 2022 admin Ubuntu

Since its inception, Kubernetes has resolved innumerable issues regarding effective management tactics for their cloud cluster storage. Due to its huge user base, the Kubernetes market should expand by over 4.3 billion USD by next year. Such an expansion would make it more than 2x as regards to its present value.

These numbers and the growth potential shows how much people are fond of the K8s technology. But sometimes, it becomes tricky to pick the right Kubernetes solution. That’s where Rancher comes in. It is, no doubt, one of the best open-source tools among the leading Kubernetes (K8s) solutions today. This article aims to discuss with you all the essential steps to install Rancher on Ubuntu with relative ease.

What Exactly is Rancher?

Before explaining the steps you have to follow to install Rancher on Ubuntu, let’s first understand what Rancher is. Well, Rancher is a wonderful invention arising out of the rapid growth of technology. Released in 2016, it is a great open-source tool for empowering companies for running containers in production. With Rancher coming to their aid, companies can ditch the need for manually constructing a container services platform. Rancher provides users with the complete software stack that they can utilize for managing their containers in production.

Let us now shift our focus to its four chief components:

1. Infrastructure orchestration

The first of its quartet of the major components is infrastructure orchestration. Rancher grasps raw computing resources from a public/private cloud. These resources come as Linux hosts. Each of such Linux hosts can either be a virtual or a physical apparatus. Plus, Rancher is also not very demanding. All it takes from the hosts is their CPU power, memory, and network connections. For Rancher, virtual machine (VM) instances of cloud service providers and bare-metal servers situated at the colocation sites are self-same.

The software also utilizes a portable infrastructure services layer specifically intended for powering containerized apps. A user gets infrastructure services like storage, DNS, networking, security, and so on from Rancher. These services get deployed as self-sufficient containers themselves, enabling them to run on all Linux hosts, regardless of the cloud.

2. Container orchestration and scheduling

The next component is the mechanism to orchestrate and schedule containers. A shedload of individuals prefers to run containerized apps via a container orchestration and scheduling foundation. For such users, Rancher incorporates an allocation of all the well-known container orchestration and scheduling frameworks out there. These include Mesos and Kubernetes among others. A single user can generate numerous Mesos or Kubernetes clusters. Rancher empowers its users to utilize their native Mesos or Kubernetes tools for managing their containerized apps.

Besides supporting Mesos, Kubernetes, etc., Rancher gives its users the ability to use a homegrown container orchestration and scheduling system known as Cattle. While initially Cattle was intended to be a Docker Swarm extension, today, it has become its own independent entity. It occurred as a result of the rapid development of Swarm and its digression from Cattle in the following years. Cattle helps Rancher immensely to configure, manage, and upgrade Mesos, Kubernetes, and Docker Swarm cultures.

3. App catalog

The third among Rancher components is its app catalog. The application catalog enables Rancher users to deploy any of their multi-container clustered apps with a single click. Just imagine how convenient and effortless that is. Users also become capable of managing the apps they’ve deployed and put them through auto-upgrades whenever a new edition of an app is out. Rancher offers a public catalog comprising all the famed apps the Rancher community has shared. Nonetheless, one is free to make their own private catalog if they want to.

4. Enterprise-grade control

The fourth and last component of Rancher is its enterprise-grade control. The software suits many user-authentication plug-ins. Plus, it has its own inbuilt authentication integration equipped with GitHub, Lightweight Directory Access Protocol, and AD. It also provides support for RBAC at its environment levels, enabling individuals and teams to give/decline ingress to deployment environments such as production and development.

Why Should You Install Rancher on Ubuntu Anyway?

Now you might think about what is the need for installing Rancher. Well, Rancher is known for offering several benefits to its users with some of them mentioned as follows:

  • Rancher’s foremost perk is its cross-host networking. No matter what your environment is, Rancher will construct a relevant private network described by software. This, in turn, leads to a safe interaction between different containers residing on different clouds/hosts.
  • The next benefit that Rancher has to offer is its container load balancing. The Rancher software provides every user with a coalescent and flexible load balancing service that functions on numerous clouds. This service helps them to dispense traffic across services/containers with ease.
  • Service discovery is yet another benefit offered by Rancher. It incorporates an inbuilt DNS-based service discovery feature equipped with a health checkup facility. This function empowers containers for auto-enrolling themselves as services. Plus, it enables those services to find other similar services on the network.
  • Effective resource management is also a stronghold of Rancher. The software provides support for Docker Machine. As some of you might know, Docker Machine is an amazing tool to perform host provisioning from CSP, ditching the need for a go-between. After the completion of the said provisioning, Rancher starts focusing on host resource overseeing and container deployment management.
  • As we said earlier, Rancher supports a plethora of container orchestration engines, including Mesos and Kubernetes. Besides that, it has its own orchestration engine, namely Cattle. The facility of using an engine of choice allows users to pick the popular orchestration engines out there. Plus, it also opens the door for enhancing Rancher features such as storage technologies, app catalog, and many more.
  • The Rancher software offers an effortless upgrade facility for the container services they possess via service cloning permission and service request diversion. Consequently, it helps to ensure the validation of the upgraded services by utilizing their dependencies prior to directing live traffic to those services.

Steps to Install Rancher on Ubuntu

In this section, we will discuss the steps that you need to follow for installing Rancher on your Ubuntu OS machine. But before talking about the steps, let’s take a look at the prerequisites for ensuring the successful installation of Rancher on Ubuntu OS.

Prerequisites

  • Two Ubuntu-installed servers
  • Two valid static IP addresses configured on each of the Rancher server and the client
  • A root password configured on both servers

Step 1: Update both servers

Before proceeding further, you have to update both of your Ubuntu-installed servers to their latest editions. Updating them is easy. Just execute the following command and that’s it:

apt-get update -y

apt-get upgrade -y

Once the update is finished, reboot both servers to implement your modifications.

Step 2: Install Docker CE

Next, you have to install Docker Community Edition (CE) on both of your servers. Typically, you won’t be able to find the latest version of Docker CE in your Ubuntu default repository. That’s why you need to add the necessary repository yourself.

For doing so, you must allow APT for utilizing a repository on HTTPS by installing some packages. Run the following commands in the terminal:

apt-get install apt-transport-https ca-certificates curl

software-properties-common -y

After that, download the GPG key for Docker Community Edition and affix it using the below command:

wget https://download.docker.com/linux/ubuntu/gpg

apt-key add gpg

After completion, join APT and the Docker CE repository together with the following command:

nano /etc/apt/sources.list.d/docker.list

Next, add this:

deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable

Once you’re done adding the above line, save the file and quit.

Now, you got to update your repository using the below command:

apt-get update -y

Upon completion, the repository will receive an update.

Next, install Docker Community Edition/CE:

apt-get install docker-ce -y

After installing Docker CE, you’d be capable of verifying the status of your Docker service using this command:

systemctl status docker

If everything went correctly, you should receive the below output:

docker.service – Docker Application Container Engine

Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)

Active: active (running) since Tue 2019-06-06 21:16:14 IST; 1min 0s ago

Docs: https://docs.docker.com

Main PID: 14498 (dockerd)

CGroup: /system.slice/docker.service

└─14498 /usr/bin/dockerd -H unix://

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=warning msg=”Your kernel does not support swap memory

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=warning msg=”Your kernel does not support cgroup rt pe

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=warning msg=”Your kernel does not support cgroup rt ru

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Loading containers: start.”

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Default bridge (docker0) is assigned with an

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Loading containers: done.”

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Docker daemon” commit=4d60db4 graphdriver(s)

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Daemon has completed initialization”

Jun 06 21:16:14 rancher systemd[1]: Started Docker Application Container Engine.

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”API listen on /var/run/docker.sock”

With your Docker CE now up and running, it’s time to install the Rancher container.

Step 3: Install the Rancher container

This step is all about installing the Rancher container in the right way. First, you have to install the Rancher image. You can obtain this image from the Docker Hub repositories. Download your Rancher container and initialize it using this command:

docker run -d –restart=unless-stopped -p 8080:8080 rancher/server:stable

Upon successful installation, you will receive the following output:

Unable to find image ‘rancher/server:stable’ locally

stable: Pulling from rancher/server

bae382666908: Pull complete

29ede3c02ff2: Pull complete

da4e69f33106: Pull complete

8d43e5f5d27f: Pull complete

b0de1abb17d6: Pull complete

422f47db4517: Pull complete

79d37de643ce: Pull complete

69d13e08a4fe: Pull complete

2ddfd3c6a2b7: Pull complete

bc433fed3823: Pull complete

b82e188df556: Pull complete

dae2802428a4: Pull complete

effdbd93afcb: Pull complete

a4fcc35085ad: Pull complete

e8234323b6c4: Pull complete

d3f751a5d9cc: Pull complete

d4b24e84b43b: Pull complete

da9d7264902d: Pull complete

df2b31306256: Pull complete

c2238fcf71c2: Pull complete

10c7c4a52421: Pull complete

Digest: sha256:290e94536b32665d0ff537c2b947804faeed2768cd8652f0088a0d7e1acced75

Status: Downloaded newer image for rancher/server:stable

d209e25452fecc8c77cb276855bb7875c137c8b5d6ed6ba1c461c44ac877f6c7

Your Rancher server is currently about to begin and listen on port 8080. Nonetheless, you can freely change the port if you want to.

Next, launch a web browser, navigate to its URL bar, and type http://[your server IP]:[your port number]. Provided that you didn’t modify your port number, enter 8080.

Doing so will open a page. Launch the ‘ADMIN’ menu and then click ‘Access Control’. It will help you set up your Rancher Access Control. Next, navigate to ‘LOCAL’, furnish all the required info, followed by an ‘Enable Local Auth’ button click. Now, you’ve enabled your local authentication.

Step 4: Set up your Rancher client

The last step is to navigate to the Rancher server dashboard and open the ‘INFRASTRUCTURE’ menu, followed by ‘Hosts.’

After that, press the ‘Add Host’ key. This will allow you to view your Host Registration URL. ‘Save’ it. On the next page, enter your Rancher Client IP address and specify your custom host type. Next, you will receive a command that you have to paste in a designated field after signing in to your Rancher client system. The command will look something like this:

docker run -e CATTLE_AGENT_IP=”192.168.0.103″ –rm –privileged -v

/var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher

rancher/agent:v1.2.11 http://192.168.0.100:8080/v1/scripts/A7694D846BE6239EC650:

1546214400000:XOdj1phkwWhDH556B6Jb1Le2E

Once your command gets executed successfully, you will get this output:

Unable to find image ‘rancher/agent:v1.2.11’ locally

v1.2.11: Pulling from rancher/agent

b3e1c725a85f: Pull complete

6a710864a9fc: Pull complete

d0ac3b234321: Pull complete

87f567b5cf58: Pull complete

063e24b217c4: Pull complete

d0a3f58caef0: Pull complete

16914729cfd3: Pull complete

bbad862633b9: Pull complete

3cf9849d7f3c: Pull complete

Digest: sha256:0fba3fb10108f7821596dc5ad4bfa30e93426d034cd3471f6ccd3afb5f87a963

Status: Downloaded newer image for rancher/agent:v1.2.11

INFO: Running Agent Registration Process, CATTLE_URL=http://192.168.0.100:8080/v1

INFO: Attempting to connect to: http://192.168.0.100:8080/v1

INFO: http://192.168.0.100:8080/v1 is accessible

INFO: Configured Host Registration URL info: CATTLE_URL=http://192.168.0.100:8080/v1

ENV_URL=http://192.168.0.100:8080/v1

INFO: Inspecting host capabilities

INFO: Boot2Docker: false

INFO: Host writable: true

INFO: Token: xxxxxxxx

INFO: Running registration

INFO: Printing Environment

INFO: ENV: CATTLE_ACCESS_KEY=C6CB8593B0FDB118728B

INFO: ENV: CATTLE_AGENT_IP=192.168.0.100

INFO: ENV: CATTLE_HOME=/var/lib/cattle

INFO: ENV: CATTLE_REGISTRATION_ACCESS_KEY=registrationToken

INFO: ENV: CATTLE_REGISTRATION_SECRET_KEY=xxxxxxx

INFO: ENV: CATTLE_SECRET_KEY=xxxxxxx

INFO: ENV: CATTLE_URL=http://192.168.0.100:8080/v1

INFO: ENV: DETECTED_CATTLE_AGENT_IP=192.168.0.103

INFO: ENV: RANCHER_AGENT_IMAGE=rancher/agent:v1.2.11

INFO: Launched Rancher Agent: b8816fa492af46e02fb7da53096c829d2b834375fb533f5586c7ebc

6c906ab77

Now, press the ‘close’ button after navigating to your Rancher server dashboard. The following page will display your Rancher client.

And that’s all. You have successfully installed Rancher on your Ubuntu machine.

Conclusion

As you can see, Kubernetes cluster management is a pretty difficult job. Ensuring the safety and security of your containerized apps is difficult as well. However, technology has progressed a great deal since its modest origins. Consequently, handy software/tools like Rancher have arisen as lifesavers to Kubernetes users. By utilizing Rancher, constructing and managing containers and containerized applications become a lot easier.

Through this article, we have discussed with you all the steps required to install Rancher on Ubuntu. The steps are quite limited in number and are easy to comprehend. Each step, right from updating your Ubuntu-installed servers to configuring your Rancher client, has to be followed properly to make sure that Rancher gets installed successfully. All the best!

Read more
30Apr

How to Install Yarn on Ubuntu 20.04?

April 30, 2022 admin Ubuntu

As the most reliable, fast, and secure JavaScript packet manager, yarn is preferred over npm.

It automates the whole process of installing, configuring, updating, and removing npm packages.

In this blog, you will learn about ways to install Yarn on Ubuntu 20.04. But before we get into the technical side of the process, let’s learn more about Yarn and its advantages over other packet managers.

What is Yarn?

As stated in the beginning, Yarn is a packet manager for JavaScript codes which also acts as a project manager. It was released in 2016 by Facebook to overcome shortcomings of performance and security faced while using npm (Node Package Manager).

As soon as Yarn was released, it gave npm a neck-to-neck competition and made its developers make necessary improvements to fix inefficiencies.

In regards to its functionality, it allows easy sharing and use of JavaScript code residing in different parts of the world. Due to the easy accessibility, you can connect to other developers sitting far from you and use their solutions to existing problems arising during software development.

Start Installing the Yarn on Ubuntu

Note: The installation process will need Node.js on your system. Therefore, before you start with anything else, install Node.js first.

Once you have downloaded and installed Node.js, move further with the systematic guide given below. Here, you will get to learn about three different installation processes using PPA, NPM, and Script.

So, without much ado, let’s get started.

1. Method 1 – Using PPA

The method of installing Yarn on Ubuntu 20.04 using PPA

When it comes to its own repository, Yarn doesn’t have one. Instead, it uses several others, including those from its rivals, such as npm. You will learn about that as well, but before that, let’s get started with PPA installation.

You can accurately install Yarn globally on the system with the help of PPA. Hence, every user could get access to Yarn with ease.

Step 1: Import GPG key

This is the first step of this installation process. Before the installation process, first import the GPG key to verify the package.

For this, use the command;

$ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add –

Step 2: Enable repository

After the verification, enable the repository of the package manager by typing the command;

$ echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list

Step 3: Install Yarn

Once the repository is enabled, move forward with Yarn installation by running the command;

$ sudo apt update && sudo apt install yarn

Step 4: Check the current version of the installed Yarn

Your installation will be complete with this step. You have to check the installed version. To do so, use the command;

$ Yarn –version

2. Method 2 – Using NPM

The method of installing Yarn on Ubuntu 20.04 using NPM

In this method of installation, you will use the npm repository to install Yarn. Start the execution with this command;

$ npm install -g yarn

Note: -g here will help you install the Yarn globally on your Linux system. You’ll have access to your systems and projects from anywhere in the world.

3. Method 3 – Using Script

The method of installing Yarn on Ubuntu 20.04 using Script

This method is one of the third options, however, it is not as viable as compared with the other two. Using Script, you will be able to install Yarn, but its access will be limited to the current user only. It will not acquire global access functionality.

To get started with the installation process, use the shell script;

$ sudo apt install curl -y

$ curl -o- -L https://yarnpkg.com/install.sh | bash

This script will download the Yarn archive on your home directory and extract it unthe der .yarn directory.

The script will set the variable for the path environment.

These are the three popular methods for Yarn installation. You can use them according to your usability and system demands.

Once you are done, you will need knowledge of some often-used commands. Let’s do a quick go-through.

Benefits of Yarn Package Manager over npm

As you have chosen to install the Yarn package manager, you already have an idea that it is an indispensable developer tool. It works in the direction of unifying the development process and simplifying it for the greater good.

However, much remains to be understood and known. For a brief period of time, npm remained a leader among other JavaScript managers. In terms of code package management, it is designated as the gold standard. It does, however, have a few shortcomings; those shortcomings led to the development and release of Yarn by Facebook.

Here are the benefits of Yarn over npm;

  • Makes CLI output easy-to-read
  • Enables reinstallation with the help of offline mode in the absence of internet connectivity
  • Helps in retiring failed requests and improving the network resilience
  • Eliminates duplicates by resolving mismatched versions
  • Has an independent and unified structure for installation
  • Enables users to restrict licenses of already installed modules
  • Supports bower and npm workflows; allows mixing of registries

How did Yarn manage to overcome the shortcomings of npm?

Although npm and Yarn perform identical functions, yet one of them is better and the other is not. The efficiency depends upon factors like Security, Reliability, and Speed.

Security

Yarn package manager verifies the integrity of each installed package via checksums before it is executed.

Reliability

Yarn works in the direction of ensuring the baseline installation across all associated systems. It uses a lockfile format for the installation processes.

Speed

As Yarn maximizes concurrent processes and resource utilization, it ensures faster installations. It also creates a cache of every package downloaded so that they can be accessed in need without re-downloading them.

How does Yarn differ from npm with regards to common commands?

Both Yarn and npm perform the same functions and thus have a few common commands. The commands, however, differ a great deal from one another. Let’s find out how;

For installing code packages

  • npm: npm install react
  • Yarn: Yarn add react

For installing dev packages

  • npm: npm install -D
  • Yarn: Yarn add –dev webpack

For installing dependencies

  • npm: npm install
  • Yarn: Yarn

For running npm scripts

  • npm: npm run build
  • Yarn: yarn build

Conclusion

Yarn offers a number of advantages over npm and is highly compatible with code. It has maintained the repo and has been giving neck-to-neck competition to npm. There is no doubt that it is one of the best options for web developers, whether they are working on small or big projects. To reap the benefits of Yarn, follow this guide and install it.

Read more
28Apr

How to Install Deb Files (Packages) On Ubuntu?

April 28, 2022 admin Ubuntu

Users of GUI-based operating systems, such as Windows, often have a hard time adjusting to command-line systems. Linux still remains a popular choice for users, be they beginners, programmers, or developers. The first-time users of Ubuntu will find it different from Windows in several ways.

Although the primary version of Ubuntu employs GNOME, a mixture of GUI and command-line interface, many beginners have several questions regarding the operations. One of those questions is how to install Deb files (packages) on Ubuntu.

Honestly, it is not difficult at all, and there are several ways to do so. The best, quickest, and easiest way is to install the application from the Software Center. But all of the applications are not available in Ubuntu repositories, and you may need to download them manually.

While Software Center allows you to install several applications, some applications are contained in Deb packages with .deb extension. You can consider it as the .exe files in Windows.

This guide contains several ways of installing as well as removing deb files on Ubuntu. The guide answers all your questions concerning how to install Deb files (packages) on Ubuntu.

Installing Deb Files (Packages) on Ubuntu

There is no one way of installing Deb files on Ubuntu. You can install it in the following ways-

  1. Using Software Centre
  2. Using dpkg In Command-Line
  3. Using Gdebi Tool
  4. Using apt in Command-Line

Using Software Centre

Of all the ways to install deb files, this one is the easiest.

  1. As the first step, install the deb package for the required application.
  2. Navigate to the folder where the downloaded file is located.
  3. Double-click the file and open up the Software Center. There is the green install button.
  4. Click to start installation.
  5. Authenticate it by entering your password.
  6. Your deb package will be installed.

It is possible that as you double-click the downloaded deb file, it doesn’t take you to the Software Center. In Ubuntu 20.04, it sometimes happens that it guides you to the archive manager. In this case, right-click on the file and click on the “Open With” option. Then click on Software Install to make it your default choice by clicking on “Set as Default” on the bottom-right of the box to finish installation.

Using dpkg in Command Line

The dpkg is a command-line tool that is used under apt command. It is a low-level package manager which uses the (-i) or (–install) option.

You can install the deb file with dpkg with the below-mentioned command.

sudo dpkg -i path_to_deb_file

Instead of path-to-deb-file, use the name of the downloaded deb file.

Dpkg manager does not resolve dependency errors. It would be best if you used apt or gdebi tools for it.

Using Gdebi tool

Often, you choose to install an application in the easiest manner from Software Center, but it shows a dependency error. It happens due to a lack of software which is required for running the application but it is not present on your Ubuntu system. In such a case, you need a tool, which installs the dependencies along with the application.

The tool is the Gdebi tool. It is a GUI tool specially designed to install deb packages. So, when you install a deb package by using the Gdebi tool, it automatically installs all the dependencies required to run that application.

You can install the deb package on Ubuntu in a very simple manner with the given command.

sudo apt install gdebi

That’s it.

Using apt In Command-Line

Apt is a very popular command-line tool and you can use it to install, remove and manage Deb packages. You can use it for installing deb files on Debian, Ubuntu, and other Linux distributions.

Using the command below, you can install deb files on Ubuntu using apt-

sudo apt install path_to_deb_file

Replace path_to_deb_file with the file name of your deb file.

See, it is very easy to get deb files for Ubuntu. Hope, it has answered your question, how to install Deb file (packages) on Ubuntu. But what if you want to remove a deb file?

Removing a Deb File On Ubuntu

If you don’t need an application anymore and want to get rid of it, you can do so. The process is as simple as installing these packages. Once again, by using the Apt and Dpkg command, you can remove deb file packages. Just follow the commands, and remove the Deb files easily. And don’t worry, there is no need for the original deb file to remove the package.

1. Removing deb Files With Apt Command

First of all, if you want to remove a deb file using the Apt command, you need the program name. Now, how to learn the program name is the question? But it is easy to answer. The Grep command will find the exact program name for you.

Say you had installed Teamviewer, and now you want to remove it. You can search its program name by using the grep command in the following manner.

sudo apt list – -installed | grep team

It will return the name of all the packages that have “team” in their name. You can get the program name for the Teamviewer application and then use it in the Apt command to remove the Deb package.

sudo apt remove program_name

2. Removing Deb Files Using Dpkg Command

Once again, you need the program name. Use the grep command as used in the previous method and get the exact program name. Use it in the command given below-

dpkg –r program_name

That’s it.

Final Words

Even the simplest operations can seem impossible when you are just beginning and still in the learning process. If you are used to a GUI-based OS like Windows, switching to a semi-GUI, command-line-based OS like Ubuntu can be challenging. You need the right guide during these times.

Installing deb packages on Ubuntu is easy if you are nimble with the command line. But even if you are not, these simple commands mentioned above will make things easier. This guide will make not only installing but removing the deb package also a cakewalk.

This guide contains different methods using different tools to install and remove Deb files. Using apt, gdebi, dpkg, etc may sound overwhelming at first, but they are popular tools for installing Deb files. You can install your applications in any of the ways mentioned above.

No doubt, this guide has all the answers to your question on how to install deb files (packages) on Ubuntu. So, try these commands, install your application and enjoy Ubuntu.

Read more
18Apr

How to Install Docker on Ubuntu 18.04?

April 18, 2022 admin Docker, Ubuntu

If you’re a part of the ever-growing IT realm, you must have heard words like containerization and Docker. It’s a known fact that many IT personnel have begun opting for Docker today. Docker is an awesome tool for developing, deploying and managing apps with ease. In fact, it makes the bothersome process of container deployment pretty effortless. Many industry biggies like Spotify, ING, The New York Times, PayPal, The Washington Post, and many others, have embraced Docker wholeheartedly because of the increased convenience it offers. You, too, can install Docker on Ubuntu 18.04 for personal use. Fret not if you aren’t informed about the installation steps. This tutorial seeks to handle that aspect. Read on.

Why Install Docker on Ubuntu 18.04?

Now, you might be pondering about the need for installing Docker on your Ubuntu PC. Well, here are some of Docker’s amazingly cool features. Check them out:

  • Return on Investment (ROI) is perhaps its foremost feature. This leads to Docker being capable of cutting costs and efficiently boosting profits. All companies strive to generate steady profits over a long period. Docker can be their solution in this regard.
  • Docker makes its users capable of constructing a container image (CI) and utilizing it anywhere and anytime during the deployment process. Thus, it enables users to isolate non-dependent steps and execute them side by side.
  • Another great feature of Docker is its facility of rapid deployment. It can reduce the deployment time drastically. This happens because Docker tends to generate a spate container for each process and ditches OS boots. Hence, one can build or demolish info without the fear of reintroducing it at a greater cost than what’s considered reasonable.
  • Docker supports multiple platforms. Such multi-platform support leads to increased portability. Users can run Docker containers on Rackspace, Amazon (ECC) Elastic Cloud Computing, DigitalOcean, Google Compute Engine, Microsoft Azure, and many others. So, a container running on one platform can be ported to another. For instance, one could port a container running on Rackspace to Amazon ECC and vice-versa.

Steps to Install Docker on Ubuntu 18.04

Now, let’s focus on our foremost concern, that is, installing Docker on our Ubuntu 18.04 computer. Here we’re taking Docker Community Edition. But first, we need to accomplish a few prerequisites.

Prerequisites

  • A Ubuntu 18.04-installed server
  • A valid Docker Hub account

Step 1. Install Docker CE

While installing the Docker software, many people’s first instinct is to install it from the official Ubuntu repository. But we suggest you ditch that practice. Why? Because most of the time, the Docker installation package you get from there wouldn’t be the latest edition. So to make sure your Docker software is the latest, you have to install it from the Docker repository. For that purpose, you must attach a new package source and verify the validity of downloads by attaching a GPG key from Docker. Only after that should you proceed to install it.

So, first, you got to update your current package list:

sudo apt update

Next, install a few essential packages which will allow apt employ packages on HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Then, you have to attach the GPG key we talked about earlier to the Docker repository:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

Now, attach the Docker repository to apt sources:

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable”

After doing so, you need to update the package DB from the repository you just attached:

sudo apt update

Like we said earlier, ensure the successful installation of packages from the Docker repository instead of the official Ubuntu repository:

apt-cache policy docker-ce

Once finished, you should see an output as given below:

docker-ce:

Installed: (none)

Candidate: 18.03.1~ce~3-0~ubuntu

Version table:

18.03.1~ce~3-0~ubuntu 500

500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages

Here, you’d find the Docker CE file isn’t installed yet. It’s a confirmation of the fact that the installation contender comes from the Docker repository.

Now, you got to install the Docker CE file:

sudo apt install docker-ce

It will install Docker CE on your local machine with daemon enabled. Also, the service will now start with each reboot. You may verify its status by executing this command:

sudo systemctl status docker

If everything is fine, you will receive this output stating that the service is up and running:

docker.service – Docker Application Container Engine

Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2018-07-05 15:08:39 UTC; 2min 55s ago

Docs: https://docs.docker.com

Main PID: 10096 (dockerd)

Tasks: 16

CGroup: /system.slice/docker.service

├─10096 /usr/bin/dockerd -H fd://

└─10113 docker-containerd –config /var/run/docker/containerd/container.to ml

Now that you’ve installed Docker, you get both the daemon as well as the Docker client. Later in this tutorial, we will teach you about utilizing this command. For now, proceed to the next step.

Step 2 (optional). Execute the Docker Command Minus the sudo

Typically, one can run the docker command only if they possess root access or are a part of the docker group. This group gets constructed while you’re installing the Docker tool. Now, in case you try to run this docker command without fulfilling either of these two conditions, you’re bound to receive an output like this:

docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.

See ‘docker run –help’.

So what to do? Well, to ditch the need of typing sudo every time you attempt at running the docker command, execute the below-given command to specify your username to your docker group:

sudo usermod -aG docker ${USER}

To finalize your group initiation process, you got to sign out of your server and run this command:

su – ${USER}

After doing that, you’d be asked to provide your user password before you can proceed further.

You need to authenticate the addition of your user to the docker group. For doing so, use this command:

id -nG

Suppose you plan on adding a user to your Docker group that’s not a part of it. Then, you got to define the concerned username using the below command:

sudo usermod -aG docker username

We will proceed, presuming that you’re running the docker command as a Docker group member from now on.

So, that being said, let us now delve deep into the docker command.

Step 3. Utilize the Docker Command

The docker command utilization comprises a series of commands, options, and arguments. The syntax could usually be found in the following form:

sudo usermod -aG docker username

By utilizing the command below, you can see all your accessible subcommands:

docker

As of now, the list of available subcommands is as follows:

attach Attach local standard input, output, and error streams to a running container

build Build an image from a Dockerfile

commit Create a new image from a container’s changes

cp Copy files/folders between a container and the local filesystem

create Create a new container

diff Inspect changes to files or directories on a container’s filesystem

events Get real time events from the server

exec Run a command in a running container

export Export a container’s filesystem as a tar archive

history Show the history of an image

images List images

import Import the contents from a tarball to create a filesystem image

info Display system-wide information

inspect Return low-level information on Docker objects

kill Kill one or more running containers

load Load an image from a tar archive or STDIN

login Log in to a Docker registry

logout Log out from a Docker registry

logs Fetch the logs of a container

pause Pause all processes within one or more containers

port List port mappings or a specific mapping for the container

ps List containers

pull Pull an image or a repository from a registry

push Push an image or a repository to a registry

rename Rename a container

restart Restart one or more containers

rm Remove one or more containers

rmi Remove one or more images

run Run a command in a new container

save Save one or more images to a tar archive (streamed to STDOUT by default)

search Search the Docker Hub for images

start Start one or more stopped containers

stats Display a live stream of container(s) resource usage statistics

stop Stop one or more running containers

tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

top Display the running processes of a container

unpause Unpause all processes within one or more containers

update Update configuration of one or more containers

version Show the Docker version information

wait Block until one or more containers stop, then print their exit codes

Now, if you wish to see the options obtainable on a particular subcommand, utilize this:

docker docker-subcommand –help

You are also capable of viewing your Docker’s system info by simply typing this command:

docker info

Let us focus on some of these subcommands. We will utilize Docker images first.

Step 4. Begin Working with Docker Images

Docker images are essential for constructing Docker containers. Typically, Docker gathers all these images from the cloud-based repository Docker Hub, which is managed by Docker. Everybody is capable of hosting their images on this repository. Therefore, the chance is always high that you’d find the images of all your necessary apps and Linux distributions on Docker Hub.

To ensure your eligibility to navigate to Docker Hub and download your required images, utilize this command below:

docker run hello-world

If your eligibility status is positive, you will get an output like this:

Unable to find image ‘hello-world:latest’ locally

latest: Pulling from library/hello-world

9bb5a5d4561a: Pull complete

Digest: sha256:3e1764d0f546ceac4565547df2ac4907fe46f007ea229fd7ef2718514bcec35d

Status: Downloaded newer image for hello-world:latest

Hello from Docker!

This message shows that your installation appears to be working correctly.

Originally, Docker couldn’t find the hello-world image in your local storage. Therefore, it downloaded that image. After the completion of the download, Docker built a new container utilizing the newly downloaded image. It also constructed the app inside that container. Hence, the message.

You can look for the images you need utilizing the docker command + search subcommand. For instance, execute the following command if you’re trying to find the Ubuntu image:

docker search ubuntu

Doing so will take the script to Docker Hub and show all the available image names matching the search string. So, you will receive the below output:

NAME DESCRIPTION STARS OFFICIAL AUTOMATED

ubuntu Ubuntu is a Debian-based Linux operating sys… 7917 [OK]

dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC 193 [OK]

rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 156 [OK]

ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 93 [OK]

ubuntu-upstart Upstart is an event-based replacement for th… 87 [OK]

neurodebian NeuroDebian provides neuroscience research s… 50 [OK]

ubuntu-debootstrap debootstrap –variant=minbase –components=m… 38 [OK]

1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 36 [OK]

nuagebec/ubuntu Simple always updated Ubuntu docker images w… 23 [OK]

tutum/ubuntu Simple Ubuntu docker images with SSH access 18

i386/ubuntu Ubuntu is a Debian-based Linux operating sys… 13

ppc64le/ubuntu Ubuntu is a Debian-based Linux operating sys… 12

1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 10 [OK]

1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10 ubuntu-16-nginx-php-phpmyadmin-mariadb-10 6 [OK]

eclipse/ubuntu_jdk8 Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, … 6 [OK]

codenvy/ubuntu_jdk8 Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, … 4 [OK]

darksheer/ubuntu Base Ubuntu Image — Updated hourly 4 [OK]

1and1internet/ubuntu-16-apache ubuntu-16-apache 3 [OK]

1and1internet/ubuntu-16-nginx-php-5.6-wordpress-4 ubuntu-16-nginx-php-5.6-wordpress-4 3 [OK]

1and1internet/ubuntu-16-sshd ubuntu-16-sshd 1 [OK]

pivotaldata/ubuntu A quick freshening-up of the base Ubuntu doc… 1

1and1internet/ubuntu-16-healthcheck ubuntu-16-healthcheck 0 [OK]

pivotaldata/ubuntu-gpdb-dev Ubuntu images for GPDB development 0

smartentry/ubuntu ubuntu with smartentry 0 [OK]

ossobv/ubuntu

…

Notice the output carefully. The “[OK]”s in the “OFFICIAL” section of the output signifies images that the organization behind the project made and endorsed. Once you’re finished picking the image of your preference, utilize the pull subcommand for downloading it to your PC.

Thus, you can run the following command for downloading the Ubuntu image:

docker pull ubuntu

Once downloaded, you will get the following output:

Using default tag: latest

latest: Pulling from library/ubuntu

6b98dfc16071: Pull complete

4001a1209541: Pull complete

6319fc68c576: Pull complete

b24603670dc3: Pull complete

97f170c87c6f: Pull complete

Digest: sha256:5f4bdc3467537cbbe563e80db2c3ec95d548a9145d64453b06939c4592d67b6d

Status: Downloaded newer image for ubuntu:latest

After downloading an image, you are free to execute the run subcommand for creating a container from your downloaded image. As the hello-world instance might’ve made you comprehend, if an image download fails to occur even after executing the docker command + run subcommand, the Docker client will initially download that image. And, after that, it will create a container utilizing the same.

Your downloaded images could be viewed by executing this simple command:

docker images

The output you will get should something like this:

REPOSITORY TAG IMAGE ID CREATED SIZE

ubuntu latest 113a43faa138 4 weeks ago 81.2MB

hello-world latest e38bc07ac18e 2 months ago 1.85kB

In case you didn’t know, you can modify the images you utilize for the container running. Also, it’s possible to use them for constructing new images, capable of being uploaded to Docker Hub or other similar repositories whenever you please.

So, the next step will dig deeper into this container running matter.

Step 5. Run a Docker Container

Remember the hello-world container you executed earlier? That was a perfect instance of a container that is capable of running and exiting after releasing a demo text. Containers, as you may know, have many other usages. Such a fact shouldn’t come as a surprise as they’re pretty much like VMs, albeit with increased resource-friendliness.

For instance, run a container utilizing the newest Ubuntu image. The below command could give you interactive shell access:

docker run -it ubuntu

Next, try to reflect in your command the fact that your work is occurring within that container. Therefore, make it look something like this:

root@d9b100f2f636:/#

Notice the container ID here. Remember it because we will need it later for container identification provided that you’ve decided to delete it.

With that, you’ve now become capable of running any command you wish to within your container. Let us take the task of package DB update inside the container as an instance. As you are a root user within your container, you don’t have to type sudo before your command:

root@d9b100f2f636:/#

After that, install any app of your preference inside it. For now, we will be installing Node.js:

root@d9b100f2f636:/#

Doing so will help install Node.js in your container. After the installation process is over, you got to verify Node.js’s installation with this command:

root@d9b100f2f636:/#

The output you will get from here will state the version of your newly installed Node.js:

v8.10.0

Remember that anything you modify inside the container applies to that container only.

Now enter exit in the command-line to exit your container.

Step 6: Manage Docker Containers

This step is about the container management aspect. After you install Docker on Ubuntu 18.04 and use it for a while, you’ll find tons of both active and inactive containers stowed on your PC. You can view the active containers list using the command given below:

docker ps

After doing so, you will get the below output:

CONTAINER ID IMAGE COMMAND CREATED

You have begun two containers till now from the hello-world and Ubuntu images. While they are in an active state at present, they still occupy some space in your PC.

You can also view both the active and inactive container list at once by executing the following command:

docker ps -a

You will ten to one receive the below output:

d9b100f2f636 ubuntu “/bin/bash” About an hour ago Exited (0) 8 minutes ago sharp_volhard

01c950718166 hello-world “/hello” About an hour ago Exited (0) About an hour ago festive_williams

Executing the below command will permit you to view your most recent container:

docker ps -l

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

d9b100f2f636 ubuntu “/bin/bash” About an hour ago Exited (0) 10 minutes ago sharp_volhard

You can restart a container that has stopped by implementing docker start and then, your docker ID. Here we will use a Ubuntu-based container:

docker start d9b100f2f636

Once the container gets started, you can check its status by using docker ps:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

d9b100f2f636 ubuntu “/bin/bash” About an hour ago Up 8 seconds sharp_volhard

Now, if you want to stop a container from running, you have to implement docker stop and then, the container ID. Here, we will opt for the Docker-provided container name, that is, sharp_volhard:

docker stop sharp_volhard

If you ever feel that you no longer need any particular container, you can eliminate its existence simply by utilizing the docker rm + container ID combo. Suppose you don’t know the hello-world-related container name, you can use docker ps. This command will aid you in finding the container ID you’re looking for:

docker rm festive_williams

The –name switch can be utilized in initializing and naming a container. Also, there is the –rm switch for generating a self-removing container upon stoppage. For further info regarding these options and facilities, you may run the docker run help command.

You can turn your containers into images. These images can then be utilized for creating new containers.

Step 7. Make Modifications in a Container to a Docker image

While dealing with a Docker machine, you are capable of generating, changing, or removing files exactly like a VM. Any modification you make will only be confined to that container. You are free to initialize or eliminate it. But if you utilize the docker rm command, you won’t be able to recover them.

Once you install Node.js within your Ubuntu container, you possess a running container using an image. However, the created container and the source image are different. But you can base new images on this Node.js container afterward.

Next, modify a new Docker image using the following command:

docker commit -m “What you did to the image” -a “Author Name” container_id repository/new_image_name

The command specifies both the changes you committed as well as the ID of the author. Do you remember the Container ID you came across during the initial stages of your Docker session? Unless you made extra repositories to the Docker Hub, your username is your repository. Here’s how the command will be like:

docker commit -m “added Node.js” -a “sammy” d9b100f2f636 sammy/ubuntu-nodejs

Once you implement an image, that image gets stowed in your local machine.

Using the below command again to list images will help you view both the latest image as well as the source it came from:

docker images

The output you receive would be like this:

REPOSITORY TAG IMAGE ID CREATED SIZE

sammy/ubuntu-nodejs latest 7c1f35226ca6 7 seconds ago 179MB

ubuntu latest 113a43faa138 4 weeks ago 81.2MB

hello-world latest e38bc07ac18e 2 months ago 1.85kB

In the above instance, the latest image is labeled as “ubuntu-nodejs” that came from the source Ubuntu image. There is also a noticeable difference between their size that is a sure shot indicator of the modifications. This instance reflects the addition of Node.js installation as a change.

You can also construct an image from the Docker file. It allows you to auto-install software in a new image. However, it isn’t really our focus here.

Step 8. Route Docker Images to a Docker Repository

The last thing you have to get done is to create an unhackneyed image from an already extant one and share it with others. These include a select few of your buddies, on Docker Hub, or some other Docker repository accessible to you.

Utilize the below command to sign in to your Docker Hub account:

docker login -u docker-registry-username

Next, enter your Docker Hub when asked. If entered right, your sign-in would be triumphant.

In case your Docker repository username and the name you utilized while generating the image differ, make things right by tagging your repository username with your image. Execute this command:

docker tag sammy/ubuntu-nodejs docker-registry-username/ubuntu-nodejs

After doing so, you may start routing your image:

docker push docker-registry-username/docker-image-name

For routing the ubuntu-nodejs to your repository, type:

docker push sammy/ubuntu-nodejs

If successful, an output would state that clearly:

The push refers to a repository [docker.io/sammy/ubuntu-nodejs]

e3fbbfb44187: Pushed

5f70bf18a086: Pushed

a3b5c80a4eba: Pushed

7f18b442972b: Pushed

3ce512daaf78: Pushed

7aae4540b42d: Pushed

Also, you would be able to see that image name on your dashboard.

Nonetheless, if the received output looks like the following one, maybe you didn’t sign in:

The push refers to a repository [docker.io/sammy/ubuntu-nodejs]

e3fbbfb44187: Preparing

5f70bf18a086: Preparing

a3b5c80a4eba: Preparing

7f18b442972b: Preparing

3ce512daaf78: Preparing

7aae4540b42d: Waiting

unauthorized: authentication required

In that case, utilize docker login and perform the procedure again. Then, navigate to your Docker Hub registry page’s dashboard and see whether the image name appears there or not.

And that’s all. Your quest to install Docker on Ubuntu 18.04 is over.

Conclusion

To conclude, the Docker tool is capable of resolving a very common issue of deploying containers or containerized apps that is rampant among almost all IT people. Docker could be a great lifesaver to you if you struggle with a container or containerized app deployment too. Being pretty much a VM, you can run any image you please using this wonderful software. The best thing about Docker is perhaps its open-source facilities that make way for continual updates and constant improvements by an amazingly dedicated community.

Also, as you can see from the entire article, you can install Docker on Ubuntu 18.04 with ease. The procedure is pretty simple. However, losing track of the to-be-followed steps mentioned above could ball things up badly. That’s why it’s crucial to go through the tutorial religiously and then, execute each step with utmost care. From installing the Docker Community Edition software to routing Docker images to a Docker repository – only the proper execution of every step could guarantee the success of their Docker installation. Now that you comprehend what to do and how to do so, you can install Docker on your Ubuntu-installed PC with ease. All the best for testing your knowledge.

Read more
08Apr

How to Install XAMPP in Ubuntu 18.04?

April 8, 2022 admin Ubuntu

When you are hosting a website on your Ubuntu system, you will require different software packages. These software programs work together to make browsing more efficient for the viewers. Developers often use PHP to gather content from a certain database so that those resources can be viewed by the users easily.

The most common components of web-hosting in Linux servers are PHP, Apache, MariaDB, etc. The XAMPP tool helps you run these components together on your Linux system so that they can be easily manageable when it comes to web hosting. XAMPP combines these components into a single installation package so that the installation becomes simple and easy. Within the XAMPP tool, there is a Bitnami feature that facilitates managing WordPress and other content management systems.

Therefore, installing XAMPP on your Ubuntu system makes hosting a website easier. Here in this article, we will discuss in detail how to install XAMPP on Ubuntu 18.04. So, since you are already here, let’s get started.

Prerequisites

XAMPP stack is an Apache distribution, and it is related to the PHP development environment. This open-source platform helps developers to test the software packages and web pages through a single installation of the Apache (A), MariaDB (M), PHP (P), and Perl (P) cross-platform software. It tests the software and the web pages and then transfers the data to an online server remotely. To install this tool on your Ubuntu system, you will have to meet the following requirements:

  • Your system should have Ubuntu 18.04 Bionic Beaver installed.
  • Sudo privileges on a user account.
  • You should have access to the terminal or command line.
  • You should have the apt tool installed in Ubuntu.

If you have taken care of these requirements, then go ahead and get on with the installation process of XAMPP on Ubuntu.

Step 1: Download and Install XAMPP on Ubuntu

To install XAMPP on your computer, visit the official Apache Friends webpage and download the package from there. When you click on that link, the page that appears is where you will find the download button of XAMPP on Windows, Linux, and OS X. Click on the Linux link since you are trying to get it on your Ubuntu computer.

The download will take a few minutes as per the speed of the internet and system. When the download is completed, you can find the downloaded package of XAMPP in your Downloads directory in Ubuntu. You can run a simple command to execute that file and make the installation possible.

You can run the installation, but you will have to modify the file permissions for XAMPP because you are executing the program. And you need to execute the file first for the same. You can open your terminal window and then follow the instructions mentioned below.

Step 1: Go to the folder where you have downloaded the XAMPP installation package, possibly in the Downloads folder. Alternatively, you can run the cd /home/[username]/Downloads command to visit the Downloads folder from the terminal.

Step 2: Execute the file by running the chmod command: sudo chmod 755 [package_name]. When you go to the Downloads folder, you will find the complete package name in there, and you will copy and paste that name to replace [package_name] in the command above. Once you run the command, the file will be executable.

Step 3: Run the sudo chmod 755 xampp-Linux-x64-7.3.5.1-installer.run command to execute the XAMPP installation package.

Step 4: Since the terminal does not confirm if you have successfully executed the installation or not, run this command to verify the installation: ls –l xampp-Linux-x64-7.3.5.1-installer.run

In the output, you may see <strong>rwxr –xr –x 1</strong> before the user name who has the access to execute the file. You can now set up and install XAMPP on your Ubuntu system.

Step 2: Set Up and Install XAMPP

Since you have installed the XAMPP installer, you can run it on your system and the setup wizard with a simple command: sudo ./[package_name]. We have used the sudo ./xampp-Linux-x64-7.3.5.1-installer.run command to run the graphical setup wizard. The graphical wizard will open a new window at the top of the terminal window from where you can install XAMPP. It will have two available options — Next and Cancel. Observe the instructions here to complete the installation process:

Step 1: In the setup wizard, click on Next.

Step 2: A ‘Select Components’ dialogue box will appear where you will have to click on Next once again after selecting the components you need to equip.

Step 3: The wizard will show you the location of the installed XAMPP software. Click on Next.

Step 4: Another prompt will appear that will allow you to install sponsored applications on top of your main XAMPP app. These sponsored apps will contain WordPress. You don’t have to install those apps if you don’t want to. And for that, try to uncheck the ‘Learn more about Bitnami for the XAMPP’ option.

Step 5: The wizard will tell you if it is ready to install XAMPP, and you will have to click Next.

Step 6: The installation will begin and will take some time. You can track the progress in the next prompt.

Step 7: Another prompt will appear that will tell you that the installation has been finished. You can click on Finish to perform the installation.

Step 8: XAMPP will be launched and appear on your screen. From the main dashboard, look at the upper bar, where you will find the Manage Servers option. Click on it.

Step 9: In this tab, you will see the available services of XAMPP and their status. You can change between Start or Stop.

Step 10: Now visit http://localhost/dashboard from the web browser. If you can see the localhost dashboard on your browser, the installation of XAMPP was successful.

To check if the MariaDB service is working on your XAMPP tool, you can go to http://localhost/phpmyadmin. The result will show you a service database with every service in it, including variables, SQL, etc., so that you verify if it is working or not.

Conclusion

That’s how you can install and configure XAMPP on Ubuntu, but you could also uninstall it easily with a few commands. If an uninstall of the XAMPP on Ubuntu is needed, you can go to the <strong>opt/lampp</strong> directory using cd /opt/lampp. In the directory, you can use the sudo ./uninstall command to uninstall the XAMPP tool. A command box will appear where it will ask you again if you want to uninstall it or not. To confirm uninstallation, select Yes. You can also remove the directory of the XAMPP installation using sudo rm –r /opt/lamp to remove any trace of XAMPP from your computer.

The installation of XAMPP is free localhost set up for your Ubuntu computer, but you can replace XAMPP with LAMP stack or the MEAN stack. To know more about the other two, check out our other articles. If you need any further help with how to install XAMPP on Ubuntu, drop a comment below.

Read more
07Apr

How to Install Ruby on Ubuntu 18.04?

April 7, 2022 admin Uncategorized

Ruby is one of the most popular programming languages among web developers since it is mainly used to create web applications.

Ruby is a general-purpose language with several other applications like prototyping, data analysis, and many more.

The main reason why people prefer Ruby on Ubuntu is that most of the code is written on a Linux server. Ubuntu is the most accessible Linux distribution.

We will show you how to install Ruby on Ubuntu 18.04 in three different ways in this article. They are from Ubuntu Repository and two other third-party tools or websites – RVM and rbenv.

All these methods of installation of Ruby have their own sets of advantages, although nowadays, people prefer using rbenv for installing Ruby.

1. Installing Ruby from Ubuntu Repository

It is pretty easy to install Ruby from the Ubuntu Repository. To install Ruby from Ubuntu Repository, follow these simple steps given below:-

  • Before you install the newest version of Ruby on Ubuntu 18.04, make sure that the package repository cache has been cleared. You can do so by typing in the following command:-

sudo apt update

  • We need to open the Terminal. So, for that, we can either click ctrl + alt + t, keyboard shortcut, or by searching “terminal” in Ubuntu dash, and finally selecting the terminal icon that appeared on the screen.
  • Once the above steps are done, one can proceed with the installation of Ruby on Ubuntu 18.04 by typing in the following command:-

sudo apt install ruby-full

After typing the above command, type y and click the “Enter” button for verifying the installation.

  • To finally verify whether the installation was successful or not, you can type the command:-

ruby –v

  • You will receive an output that will show us the version of the Ruby installed.

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu] So the version downloaded in Ruby 2.5.1

2. Installing Ruby with RVM

Also known as Ruby Version Manager, RVM is a command-line tool for managing, installing, and using Ruby versions when performing work. Firstly, we have to install GPG before installing Ruby from RVM. Then we proceed as follows:-

a. Installing GPG

  • To install GPG, one first needs to run the following command:-

sudo apt install GnuPG

  • Then, we need to install keys using the following code:-

gpg –keyserver hkp://pool.sks-keyservers.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BD

b. Installing Software Prerequisites

  • Enter the following command to install software prerequisites:-

sudo apt install software-properties-common

  • After this, one also needs to add a PPA repository for running Ruby on Ubuntu:-

sudo apt-add-repository -y ppa:rael-gc/rvm

iii. Finally, to install RVM using the following two codes:-

sudo apt update

sudo apt install rpm

  • After doing the above steps, it is advisable to restart your device for the smooth working of Ruby.

c. Installing Ruby

Once the command line – RVM is successfully installed, one can install Ruby by a single code.

rvm install 2.5.1

One can download any version by changing the performance in the above code. For this instance, after installing Ruby version 2.5.1, use the below given command to check the installed version of the Ruby:-

ruby –v

You will receive an output that will show us the version of the Ruby installed.

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

So the version downloaded in Ruby 2.5.1

3. Installing Ruby with the help of rbenv

Ruby Version Management or simply rbenv is a third-party tool that allows us to switch between various versions of Ruby quickly and simply. It is not possible to directly install Ruby from the default rbenv, so one needs to install ruby-build. Simply put, Ruby is a plugin that works with rbenv build, a tool that helps us install any version of Ruby. To install Ruby using the following steps:-

a. So, first of all, we need to install and update specific packages that are essential for the proper functioning of the ruby-build tool: –

sudo apt update

sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

b. To install rbenv and ruby-build, one has to type the following command:-

curl -sL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash –

The above code helps to create a copy of both rbenv and ruby-build repositories from Github.

c. After this, we need to add the following code to the user Path

$HOME/.rbenv/bin

d. Depending upon which shell or command language interpreter you use, you need to type the following codes:-

  • If your shell or command language interpreter is BASH, then type in:-

echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.bashrc

echo ‘eval “$(rbenv init -)”‘ >> ~/.bashrc

source ~/.bashrc

  • If your shell or command language interpreter is Zsh, then type in:-

echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.zshrc

echo ‘eval “$(rbenv init -)”‘ >> ~/.zshrc

source ~/.zshrc

e. To install the latest version of Ruby and to make it the default version type the following code:-

rbenv install 2.5.1

rbenv global 2.5.1

Now, you need to verify whether you have appropriately installed Ruby by checking the version of Ruby installed:-

ruby –v

You will receive an output that will show us the version of the Ruby installed.

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

So the version downloaded in Ruby 2.5.1

Update Ruby Gems Package Manager

Ruby libraries can be installed and managed with Ruby Gems package manager. Ruby Gems contain Ruby code that can be shared. Ruby Gems are primarily used as libraries, which help us install any package of our choice. For that, one should update Ruby using the following code:-

gem update –system

Installing Ruby on Rails

One may want to install a complete Ruby on Rails stack. App development stacks are the most widely used. Rails is the development framework for Ruby program language, which facilitates app development the quickest way possible.

gem install rails -v 6.1.3.2

If you’re using rbenv, you’ll need to run the following command to make the rails executable available:

rbenv rehash

Now that you’ve installed Rails, you can run the rails -v command to make sure you have everything installed correctly:

rails -v

# Rails 6.1.3.2

There are three different ways by which you can install Ruby on your Ubuntu 18.04 server, with each having its pros and cons. So, installing Ruby using any of the above methods depends entirely on you.

You might have understood that installing Ruby from the Ubuntu repository is comparatively easy. On the other hand, using third-party tools like rbenv and RVM helps install and uninstall the various versions of Ruby quite efficiently and quickly.

To enjoy all the features of Ruby efficiently, it is recommended to use the newest version and updates of the same. As many new updates and technology are coming up daily, it’s crucial to update rbenv so that Ruby runs efficiently.

One can do this by simply using the git pull command:

cd ~/.rbenv

git pull

If you are using a third-party tool then simply install the tool and make the required settings using the code. Then install Ruby and check whether you have successfully installed Ruby on Ubuntu 18.04 server.

Conclusion

There are three different ways by which you can install Ruby on Ubuntu 18.04 server, with each having its pros and cons. Ruby being a popular programming language for web development and other uses is very important to download. Therefore, you can install Ruby on Ubuntu using any of the methods described above. The method you choose to use to install Ruby is entirely up to you.

Ruby can be easily installed in Ubuntu using the repository, but third-party tools such as rbenv and RVM can be used to efficiently and reliably install and uninstall the various Ruby versions. If you prefer to use all the available features of Ruby, it would be a good idea to download the latest version of it. If the above steps are followed properly, installing Ruby on Ubuntu 18.04 server is very easy.

Read more
07Apr

How to Install Pip on Ubuntu 18.04?

April 7, 2022 admin Ubuntu

All the Ubuntu 18.04 version users have been searching for ways to install PIP lately. It’s because this Ubuntu version comes with Python 2 and Python 3 pre-installed. That’s why installing and maintaining Python software packages on Ubuntu requires a package manager tool like PIP.

PIP is a command-line software management system that simplifies the way you install and run any application written in the Python language on Ubuntu. Generally, PIP refers to the Python 2 version, and PIP3 denotes Python 3. Since Ubuntu contains both Python 2 and 3, there are two possible variants of PIP available to install on Ubuntu 18.04.

We have provided a comprehensive guide here for installing, managing, and upgrading PIP and PIP3 on Ubuntu 18.04. Follow the below steps to install using the Ubuntu ‘apt’ package manager. Let’s get started!

Prerequisites:

  • A user account with sudo privileges
  • Access to a terminal window or command line
  • Of course, Ubuntu 18.04 system

Note: If you already have a ‘sudo’ account, skip the next section and move to the installation process directly.

How to Create a New User Account with ‘sudo’ Privileges on Ubuntu?

You might already know that a ‘sudo’ account allows you to run any program with the same security privileges a root user has. If you don’t have an account yet, first add a new user account to run the ‘sudo’ command line. This will create a group and home directory too for the new user. Here is how to do so,

Step 1: At first, log into your system with the ‘sudo’ privileged root user account

Step 2: Next, open a terminal window by pressing Ctrl+Alt+T at the same time

Step 3: Now, create a new user account with the below command (Replace the “newuser” with your one)

adduser newuser

Note: Some non-root users have noticed an error message after entering the above command. Bypass it by entering the below command-

sudo adduser newuser

Step 4: After that, your system will prompt you to enter a password and additional information (Optional)

Step 5: Once you’re done with the password, press Enter to skip the optional step

How to Add an Existing User to ‘sudo’ Group on Ubuntu?

In case you want to add an existing user to ‘sudo’ group in order to give him the root-user privileges, perform the below steps:

Step 1: Open a terminal window first with Ctrl+Alt+T

Step 2: Enter the below command next (Replace the “newuser” with your username)

usermod -aG sudo newuser

Note: If an error message pops up, enter –

sudo usermod -aG sudo newuser

Step 3: Verify the groups the new user belongs to by entering the below command next:

groups new-user

Note: If the new user’s name is not displayed under the ‘sudo’ privilege listing, perform step 4.

Step 4: Finally, switch the users by entering the following command (Replace the “newuser” with the one in Step 2)

su – newuser

Note: When you try to alter the /root directory list, it may show an error. In that case, enter the command- ‘sudo ls /root’.

How to Install PIP for Python 3 on Ubuntu 18.04?

As we’ve already mentioned, Ubuntu 18.04 comes with Python 3 pre-installed but not PIP3. Since you’ve already created a ’sudo’ account, let’s learn the steps to install PIP now.

Step 1: Open the terminal window first by pressing Ctrl+Alt+T together

Note: You can also right-click on the desktop and choose the Open Terminal option

Step 2: Next, you need to update the package list present on the repository, type in the below command for that-

sudo apt update

Step 3: Now, run the following command to install PIP3 and all the other dependencies required for building Python modules-

sudo apt install python3-PIP

Note: Once the installation process is done, you’ll be prompted to confirm it. Type Y and press Enter to confirm the same.

Step 4: Then you need to verify the install, enter the below command to do that-

PIP3 –version

Step 5: Finally, upgrade the PIP3 to its latest version by running the below-mentioned command,

sudo PIP3 install –upgrade PIP

Once done, you’re all set to smoothly run applications written in Python on your Ubuntu 18.04. If you’re using Python 2, then follow the below process to do the same on Ubuntu.

How to Install PIP for Python 2 on Ubuntu 18.04?

To install PIP for Python 2, you’ll follow more or less the same ‘sudo’ command line as shown for the PIP3. But this time, the PIP version will be different. However, first, open a terminal window and then keep performing the below mentioned step-by-step process to install PIP on Ubuntu.

Step 1: First, you have to update the package list present on the repository by entering this command-

sudo apt update

Step 2: Next, run the below command to install PIP and its dependencies to build Python modules

sudo apt install python-PIP

Step 3: You’ll be prompted to confirm the installation. Next, type Y and hit Enter in that case

Step 4: Now you have to verify the install; run the below command for that-

PIP –-version

Step 5: Finally, download the latest version of PIP for Python 2 by running the below command-

sudo PIP install –upgrade PIP

That’s all you need to do to install PIP for Python 2 on Ubuntu 18.04. Knowing only the installation process won’t help you complete your job flawlessly. It is necessary to know how to use PIP properly in order to make the most of it. Learn everything you need to know in the following section.

How to Use PIP on Ubuntu?

Before knowing the usage, let’s address a question: do you install Python modules globally on your Ubuntu system?

If so, then it is recommended to install the Python modules provided by the distribution/package manager.

Yes, when you use PIP inside a virtual environment only, it ensures a completely isolated location for the project and does not affect other Python projects.

Nevertheless, here you will learn a few basic yet effective PIP commands, with which you can easily install packages from the Python Package Index, local projects, version control, and distribution files. Take a look.

Install Packages using PIP:

Run the below command to install the latest version of a particular package:

PIP3 install Enter_Package_Name

To install a specific version of a package, run the following command

PIP3 install Enter_Package_Name==1.5

Install Packages using PIP Requirement Files:

If you want to install packages directly from its ‘requirement.txt’ file, which contains the list of PIP packages and their required versions to run a specific Python project, run the below command-

PIP3 install -r requirements.txt

Upgrade a Package using PIP:

Enter the below command to upgrade a package to its latest version with PIP-

PIP3 install –upgrade package_name

List Installed Packages using PIP:

To list all the installed packages using PIP, follow the below command line-

PIP3 list

Search for a Package using PIP:

If you need to search for a particular package installed on your Ubuntu system, type in this command-

PIP3 search Enter_Search_Term

Get a List of Outdated Packages with PIP:

To get all the outdated packages listed with PIP, enter this command-

PIP3 list –outdated

Uninstall Packages with PIP:

If you want to uninstall a package using PIP, follow the below command-

PIP3 uninstall package_name

Note: If you want to run all these basic commands on Python 2, just replace ‘PIP3’ with ‘PIP’ to get the result.

Apart from this list of basic PIP commands, if you need to know any specific one, you can type in ‘PIP3 –help’ to view the list of all commands and corresponding options.

EndNote

Now, you’ve got the complete overview of how to install PIP on Ubuntu 18.04. Hopefully, it will now be easier for you to run any Python-based application smoothly on your system. However, always remember that PIP is designed to install Python packages from Python Package Index (PyPI). So instead of installing a package globally, it’s better to install a package from the package manager while using PIP. If you’ve further queries, drop a comment in the box below. Stay connected for more tech guides.

Read more
    12
corporate-one-light
+1 800 622 22 02
info@scapeindustries.com

Company

Working hours

Mon-Tue

9:00 – 18:00

Friday

9:00 – 18:00

Sat-Sun

Closed

Contacts

3 New Orchard Road
Armonk, New York 10504-1522
United States
915-599-1900

© 2021 Kuberty.io by Kuberty.io