withdrawal screenshot olymp trade zupee controller hack apk एमपीएल एप्लिकेशन पेटीएम फास्ट गेम common nouns in hindi ludo empire mod apk angry birds go apk gaurav benal ias www.kseeb.kar.nic.in 1xstavka wormate. io new golden day क्विज गेम्स इन हिंदी 2024 bigg boss winner name royal vin my 11 circle brand ambassador राज्य जनसंख्या पंजी प्रबंधन प्रणाली flappy bird gif teenpatti bonus casino netflix mobile slots games rummy wealth app download khelo 24 bet online casino birthday kaka mukh mantri vridha pension deltin casino goa rummy golds 51 bonus b.tech subjects जातिगत जनगणना क्यों जरूरी है गूगल लूडो मिलन के फाइनल अंक kl jakpart master gold plywood rummy wealth apk 51 bonus mpl download karna hai योनो रजिस्ट्रेशन प्रॉब्लम आधार में मोबाइल नंबर लिंक rummynobob जन्म तिथि / dob www. skill clash.com housie tickets online पुरानी विडमेट श्री लक्ष्मी लॉटरी रिजल्ट marvel spider man apk sbin login chhota bheem online games चेन्नई मटका सपने में आलीशान घर देखना सट्टा मटका 220 पत्ती सट्टा मटका 220 पत्ती nivas praman patra kaun jari karta hai Tech Blog https://www.technhit.in Technology for Mankind Sun, 19 Feb 2023 14:09:03 +0000 en-US hourly 1 https://wordpress.org/?v=5.5.3 https://i1.wp.com/www.technhit.in/wp-content/uploads/2020/10/cropped-LOGO-update2.png?fit=32%2C32&ssl=1 Tech Blog https://www.technhit.in 32 32 109949773 Installing and Configuring OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code https://www.technhit.in/installing-and-configuring-openshift-a-step-by-step-guide-for-linux-experts-with-terminal-code/ https://www.technhit.in/installing-and-configuring-openshift-a-step-by-step-guide-for-linux-experts-with-terminal-code/#respond Sat, 18 Feb 2023 20:04:54 +0000 https://www.technhit.in/?p=1579 OpenShift: The Container Application Platform OpenShift is a powerful container application platform developed by Red Hat. It allows you to deploy and manage your applications at scale, with support for multiple languages and frameworks. In this blog post, we will explore the features and benefits of OpenShift, and show you how to get started with […]

The post Installing and Configuring OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code appeared first on Tech Blog.

]]>
OpenShift: The Container Application Platform

OpenShift is a powerful container application platform developed by Red Hat. It allows you to deploy and manage your applications at scale, with support for multiple languages and frameworks. In this blog post, we will explore the features and benefits of OpenShift, and show you how to get started with your own OpenShift deployment.

Features of OpenShift

  1. Docker-based Containers OpenShift is based on Docker containers, which provide a lightweight and portable way to package and distribute applications. Docker containers are fast, reliable, and easy to manage, making them an ideal platform for deploying applications at scale.
  2. Kubernetes Orchestration OpenShift uses Kubernetes to manage the deployment and scaling of containerized applications. Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. With Kubernetes, you can deploy and manage your applications with ease, without worrying about the underlying infrastructure.
  3. Support for Multiple Languages and Frameworks OpenShift supports a wide range of programming languages and frameworks, including Java, Python, Ruby, Node.js, and more. This makes it easy to deploy and manage applications written in your language of choice, without having to worry about compatibility issues or vendor lock-in.
  4. Web Console and Command-Line Tools OpenShift provides a web console and command-line tools for managing your applications and resources. The web console provides a graphical interface for deploying and managing applications, while the command-line tools provide a more flexible and powerful way to manage your OpenShift deployment.

Benefits of OpenShift

  1. Scalability and Flexibility OpenShift is designed to scale to meet the needs of your application, from small development environments to large-scale production deployments. With OpenShift, you can easily scale your applications up or down as needed, without having to worry about the underlying infrastructure.

  2. Security and Compliance OpenShift provides a secure and compliant platform for deploying and managing your applications. With built-in security features and support for compliance standards such as PCI-DSS and HIPAA, OpenShift makes it easy to meet your security and compliance requirements.

  3. Developer Productivity OpenShift provides a streamlined and easy-to-use platform for deploying and managing your applications, which can help increase developer productivity. With OpenShift, developers can focus on writing code and building applications, without having to worry about the underlying infrastructure or deployment process.

Getting Started with OpenShift

To get started with OpenShift, you can deploy it on your own infrastructure using the OpenShift Container Platform or use a managed service like OpenShift Online. Here are the basic steps to deploy OpenShift on your own infrastructure:

  1. Install and Configure OpenShift Container Platform You can download the OpenShift Container Platform from the Red Hat website and follow the installation instructions to set up your own OpenShift deployment.
  2. Deploy Applications Once your OpenShift deployment is up and running, you can start deploying your applications. OpenShift supports a wide range of deployment options, including Dockerfiles, source code, and pre-built images.
  3. Manage Resources OpenShift provides a web console and command-line tools for managing your resources, including pods, services, routes, and more. You can use these tools to monitor and manage your applications, as well as scale up or down as needed.

 

Installing OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code

OpenShift is a powerful container application platform developed by Red Hat that enables you to deploy and manage your applications at scale. If you are a Linux expert looking to install OpenShift on your system, this step-by-step guide with terminal code will help you get started.

Step 1: Choose your Installation Method

There are two primary methods for installing OpenShift:

  1. OpenShift Container Platform: This is the enterprise version of OpenShift, which can be deployed on-premise or on a public or private cloud platform.
  2. OpenShift Origin: This is the upstream version of OpenShift, which is available as open-source software and can be deployed on a variety of platforms.

As a Linux expert, you may prefer to use OpenShift Origin as it gives you more control over the installation process. However, OpenShift Container Platform comes with support and additional features that may be beneficial for your organization.

Step 2: Prepare your System

Before you begin the installation process, make sure your system meets the minimum requirements for OpenShift. These requirements include:

  • A 64-bit x86 processor with at least two cores
  • At least 8GB of RAM
  • At least 20GB of free disk space
  • A supported operating system, such as Red Hat Enterprise Linux, CentOS, or Fedora.

You will also need to install Docker, Kubernetes, and other dependencies on your system. You can refer to the OpenShift documentation for a complete list of prerequisites and installation instructions.

Step 3: Download OpenShift

Once your system is prepared, download the OpenShift installation package from the official website or from the OpenShift Origin GitHub repository. The installation package includes all the necessary files and scripts to install and configure OpenShift on your system.

You can use the following command to download the OpenShift Origin installation package:

$ wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz

Step 4: Install OpenShift

To install OpenShift, follow these steps:

  1. Extract the installation package to a directory of your choice.
$ tar -xvf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
$ cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/
  1. Add the OpenShift binary directory to your PATH environment variable.
$ export PATH=$PATH:`pwd`
  1. Run the installation script, which will guide you through the installation process. You may need to provide some configuration settings, such as the installation directory and the administrator credentials.
$ oc cluster up
  1. The installation script will install and configure OpenShift on your system, which may take some time depending on your system configuration and the number of nodes you are deploying.
  2. Once the installation is complete, you can log in to the OpenShift console using the administrator credentials you provided during the installation process.

$ oc login -u system:admin

Step 5: Configure OpenShift

After installing OpenShift, you will need to configure it according to your needs. This may include setting up security settings, creating users and groups, configuring storage and network settings, and more.

You can use the OpenShift console or command-line tools to configure OpenShift. The OpenShift documentation provides detailed instructions for each configuration task.

Step 6: Deploy Applications

Once OpenShift is configured

Conclusion

OpenShift is a powerful container application platform that provides a flexible and scalable way to deploy and manage your applications. With support for multiple languages and frameworks, a secure and compliant platform, and powerful management tools, OpenShift is an ideal choice for organizations of all sizes. So why not give it a try and see how it can help you streamline your application deployment and management process?

The post Installing and Configuring OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code appeared first on Tech Blog.

]]>
https://www.technhit.in/installing-and-configuring-openshift-a-step-by-step-guide-for-linux-experts-with-terminal-code/feed/ 0 1579
Sed Command in Linux with Practical Examples https://www.technhit.in/sed-command-in-linux-with-practical-examples/ https://www.technhit.in/sed-command-in-linux-with-practical-examples/#respond Sat, 18 Feb 2023 19:53:20 +0000 https://www.technhit.in/?p=1567 The “sed” command in Linux is a powerful tool for performing basic text transformations on an input stream or a file. It operates by reading input line by line, and applying a set of commands to each line. These commands can be used to replace, insert, or delete text, making it a versatile tool for […]

The post Sed Command in Linux with Practical Examples appeared first on Tech Blog.

]]>
The “sed” command in Linux is a powerful tool for performing basic text transformations on an input stream or a file. It operates by reading input line by line, and applying a set of commands to each line. These commands can be used to replace, insert, or delete text, making it a versatile tool for editing files.

One of the most common uses of sed is to replace a specific word or phrase in a file. For example, let’s say we have a file called “example.txt” with the following contents:

This is the first line of the file.
This is the second line of the file.
This is the third line of the file.

If we want to replace the word “first” with “second” on the first line of the file, we can use the following sed command:

sed 's/first/second/' example.txt

This command tells sed to perform a substitution, replacing the first occurrence of “first” with “second” on the first line of the file. The output of this command will be:

This is the second line of the file.
This is the second line of the file.
This is the third line of the file.

We can also use sed to make changes to multiple lines. For example, if we want to replace the word “line” with “lines” throughout the entire file, we can use the following command:

sed 's/line/lines/g' example.txt

The “g” at the end of the command tells sed to perform the replacement globally, on all occurrences of the word “line” in the file. The output of this command will be:

This is the first lines of the file.
This is the second lines of the file.
This is the third lines of the file.

Sed can also be used to insert text, or even delete lines. For example, if we want to insert a new line after the second line of the file, we can use the following command:

sed '2a\
This is a new line.' example.txt

This command tells sed to insert the text “This is a new line.” after the second line of the file. The output of this command will be:

This is the first line of the file.
This is the second line of the file.
This is a new line.
This is the third line of the file.

As you can see, the sed command is a powerful tool that can be used to perform a wide variety of text transformations on a file. For more information on using sed, you can refer to the man pages or online resources.

The post Sed Command in Linux with Practical Examples appeared first on Tech Blog.

]]>
https://www.technhit.in/sed-command-in-linux-with-practical-examples/feed/ 0 1567
Rsync Command uses with examples https://www.technhit.in/rsync-command-uses-with-examples/ https://www.technhit.in/rsync-command-uses-with-examples/#respond Sat, 18 Feb 2023 19:41:42 +0000 https://www.technhit.in/?p=1569 The rsync command is a powerful and versatile tool for synchronizing files and directories between different locations in Linux. Whether you’re managing backups, deploying software, or just transferring data between systems, rsync offers a wide range of options and features that make it an indispensable tool for system administrators and power users alike. In this […]

The post Rsync Command uses with examples appeared first on Tech Blog.

]]>
The rsync command is a powerful and versatile tool for synchronizing files and directories between different locations in Linux. Whether you’re managing backups, deploying software, or just transferring data between systems, rsync offers a wide range of options and features that make it an indispensable tool for system administrators and power users alike.

In this blog post, we’ll take a closer look at the rsync command, exploring its various options, use cases, and best practices.

Installing rsync

Before we dive into the details of using rsync, let’s first make sure it’s installed on our system. Most modern Linux distributions should come with rsync pre-installed, but if you’re using an older or more minimalist distribution, you may need to install it manually.

To check if rsync is already installed on your system, you can run the following command:

sudo apt-get install rsync

Once rsync is installed, you’re ready to start using it.

Basic usage

The most basic usage of rsync is to copy files and directories from one location to another. The basic syntax for copying files with rsync is as follows:

rsync source destination
For example, to copy all files in the directory /path/to/source to the directory /path/to/destination, you would run the following command:
rsync /path/to/source /path/to/destination
By default, rsync will only copy files that have changed or been added since the last synchronization. This makes rsync much faster and more efficient than tools like cp or scp, which copy all files regardless of whether they have changed.

Advanced options

In addition to the basic usage described above, rsync offers a wide range of advanced options and features. Here are some of the most commonly used options:

    • -a: This option stands for “archive” and is a shorthand for several other options that are commonly used when synchronizing files, including -r (recursive), -l (copy symlinks as symlinks), -p (preserve permissions), and -t (preserve modification times). This is typically the most useful option to use when synchronizing files.
    • -v: This option stands for “verbose” and causes rsync to output more detailed information about what it’s doing. This can be useful for debugging or just getting a better sense of what rsync is doing.
    • -z: This option stands for “compress” and causes rsync to compress data before sending it over the network. This can significantly speed up transfers over slow or congested networks.
    • --delete: This option causes rsync to delete files from the destination that do not exist in the source. This can be useful for keeping the destination in sync with the source.
    • --exclude: This option allows you to specify files or directories that should be excluded from the synchronization. You can use this option multiple times to exclude multiple files or directories.
    • --progress: This option causes rsync to output progress information during the transfer, including the percentage completed and the transfer speed.

Examples

Let’s take a look at some real-world examples of how to use rsync.

Synchronizing a local directory with a remote server

Suppose you have a directory /path/to/local on your local machine that you want to synchronize with a directory `/path

Example 1: Syncing two local directories

Suppose you have two directories on the same machine that you want to keep in sync, /path/to/source and /path/to/destination. To synchronize these directories, you can run the following command:

rsync -av /path/to/source/ /path/to/destination/

The -a option ensures that rsync preserves all file attributes, including permissions, ownership, timestamps, and symlinks. The -v option enables verbose output, so you can see which files are being transferred. The trailing slashes after the directory paths ensure that rsync copies the contents of the directories, rather than the directories themselves.

Example 2: Syncing a local directory with a remote server

Suppose you have a directory on your local machine that you want to synchronize with a directory on a remote server. To do this, you can use the following command:

rsync -av /path/to/local user@remote:/path/to/remote

In this example, /path/to/local is the source directory on your local machine, user is the username for the remote server, remote is the hostname or IP address of the remote server, and /path/to/remote is the destination directory on the remote server. You’ll be prompted to enter the password for the remote user account.

Example 3: Syncing a remote directory with a local directory

Suppose you have a directory on a remote server that you want to synchronize with a directory on your local machine. To do this, you can use the following command:

rsync -av user@remote:/path/to/remote /path/to/local

In this example, user is the username for the remote server, remote is the hostname or IP address of the remote server, /path/to/remote is the source directory on the remote server, and /path/to/local is the destination directory on your local machine. You’ll be prompted to enter the password for the remote user account.

Example 4: Syncing a directory and excluding certain files

Suppose you want to synchronize a directory, but exclude certain files or directories from the transfer. To do this, you can use the --exclude option. For example, to synchronize a directory /path/to/source, but exclude all files with the extension .log, you can use the following command:

rsync -av --exclude '*.log' /path/to/source/ /path/to/destination/

In this example, *.log is a wildcard pattern that matches all files with the extension .log. The --exclude option tells rsync to exclude any files that match this pattern.

Example 5: Dry run mode

Before you perform an actual synchronization, it’s often a good idea to run a dry run to see what changes will be made. To do this, you can use the --dry-run option, like this:

rsync -av --dry-run /path/to/source/ /path/to/destination/

This will show you a list of all the files that would be copied, deleted, or modified, without actually performing any changes.

Rsync Bash Script for Weekly Backup:

#!/bin/bash

# Set the source and destination directories
src_dir="/path/to/source"
dest_dir="/path/to/backup"

# Set the name of the backup file
backup_name="backup_$(date +%Y-%m-%d_%H-%M-%S)"

# Use rsync to take an incremental backup of the source directory
rsync -avz --delete --backup --backup-dir="$dest_dir/$backup_name" "$src_dir/" "$dest_dir/latest/"

# Remove any old backups
find "$dest_dir" -maxdepth 1 -type d -name "backup_*" -mtime +7 -exec rm -rf {} \;

 

To set up a weekly cron job to run this script automatically, follow these steps:

  1. Open the crontab configuration file by running crontab -e in the terminal.
  2. Add the following line at the end of the file to schedule the script to run every Sunday at 3 AM:
0 3 * * 0 /bin/bash /path/to/backup_script.sh
  1. Save and close the file.

This cron job will run the backup script every Sunday at 3 AM. You can modify the cron schedule by changing the values in the cron expression (0 3 * * 0), which represents the minute, hour, day of the month, month, and day of the week when the job will run. For example, to run the job every day at 3 AM, you could change the cron expression to 0 3 * * *.

Note that you may need to modify the permissions of the backup script to make it executable using chmod +x backup_script.sh.

These are just a few examples of how you can use rsync to synchronize files and directories. With its wide range of options and features, rsync is a versatile tool that can be used in many different scenarios.

The post Rsync Command uses with examples appeared first on Tech Blog.

]]>
https://www.technhit.in/rsync-command-uses-with-examples/feed/ 0 1569
How to Install WordPress with Nginx on Ubuntu 22.04 https://www.technhit.in/how-to-install-wordpress-with-nginx-on-ubuntu-22-04/ https://www.technhit.in/how-to-install-wordpress-with-nginx-on-ubuntu-22-04/#respond Fri, 12 Aug 2022 11:51:50 +0000 https://www.technhit.in/?p=1549 Install WordPress on Ubuntu 22.04 LTS In this tutorial, we will install WordPress on Ubuntu 22.04 LTS version with the Nginx web server. That gives you a feeling like a production environment while developing in the local environment. WordPress is a free and open-source content management system mainly used to publish blogs on the internet. […]

The post How to Install WordPress with Nginx on Ubuntu 22.04 appeared first on Tech Blog.

]]>
Install WordPress on Ubuntu 22.04 LTSInstall WordPress

In this tutorial, we will install WordPress on Ubuntu 22.04 LTS version with the Nginx web server. That gives you a feeling like a production environment while developing in the local environment.

WordPress is a free and open-source content management system mainly used to publish blogs on the internet. It is designed for those who don’t know how to code. WordPress makes it simple to create and maintain websites and blogs. Due to its popularity, over a third of websites, today are powered by WordPress. It is written in PHP and uses MariaDB and MySQL as a database backend

Prerequisites:

  • A server running Ubuntu 22.04.
  • Sudo or root access on the server.

Steps to Follow:

  1. Install Nginx, MariaDB, and PHP
  2. Create a Database for WordPress
  3. Install WordPress on Ubuntu 22.04
  4. Create an Nginx Virtual Host for WordPress
  5. Complete WordPress Web Installation
  6. Conclusion

Video:

This tutorial has a video view here:

Setp1: Install Nginx, MariaDB, and PHP-


Before starting, the LEMP server must be installed on your server. If not installed, you can install it by running the following command:

apt install nginx mariadb-server php php-fpm php-curl php-mysql php-gd php-mbstring php-xml php-imagick php-zip php-xmlrpc

 

Once the LEMP server is installed, verify the PHP version using the following command:

php -v

You will get the PHP version in the following output:

PHP Version

nano /etc/php/8.1/fpm/php.ini

Change the following lines:

cgi.fix_pathinfo=0
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 512M
max_execution_time = 120

Save and close the file when you are finished.

Step2: Create a Database for WordPress-


WordPress uses a database to store its content. So you will need to create a database and user for WordPress.

First, log in to the MariaDB shell with the following command:

mysql

Once you are logged in, create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE wpdb;
MariaDB [(none)]> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your password';

Next, grant all the privileges to the WordPress database using the following command:

MariaDB [(none)]> GRANT ALL ON wpdb.* TO 'wpuser'@'localhost';

Next, flush the privileges and exit from the MariaDB with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Once you are finished, you can proceed to the next step.

Step3: Install WordPress on Ubuntu 22.04-


First, navigate to the Nginx web root directory and download the latest version of WordPress using the following command:

cd /var/www/html
wget https://wordpress.org/latest.tar.gz

Once the WordPress is downloaded, extract the downloaded file with the following command:

tar -zxvf latest.tar.gz

Save and close the file when you are finished. Next, set proper permission and ownership to the WordPress directory:

chown -R www-data:www-data /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress

Step4: Create an Nginx Virtual Host for WordPress-


Next, you will need to create an Nginx virtual host configuration file to serve WordPress over the internet.

nano /etc/nginx/conf.d/wordpress.conf

Add the following configuration:

server {
    listen 80;
    root /var/www/html/wordpress;
    index  index.php index.html index.htm;
    server_name  wordpress.example.com;

    client_max_body_size 500M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
	
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }	

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }	

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }
}

Save and close the file then verify the Nginx configuration using the following command:

nginx -t

You will get the following output:

nginx Syntax

After getting the output that your syntax is ok one more thing you need to do. Create a local domain resolver by editing your hosts file:

sudo nano /etc/hosts

Add the following record at the end of the file:

127.0.0.1 wordpress.example.com

 host resolver

Next, restart the Nginx and PHP-FPM services to apply the changes.

systemctl restart nginx
systemctl restart php8.1-fpm

Step5: Complete WordPress Web Installation-


Now, open your web browser and access the WordPress installation wizard using the URL http://wordpress.example.com. You will be redirected to the following page:

WordPress web Installer

Hit on lets Go Button:

Web installer Fill Credential

Fill in all credentials and necessary info and hit on submit button.

run installer

Click on the run installation button.

site setup

Conclusion


Congratulations! you have successfully installed WordPress with Nginx on Ubuntu 22.04. You can now install your preferred themes, and plugins and start building your own website and start blogging.

The post How to Install WordPress with Nginx on Ubuntu 22.04 appeared first on Tech Blog.

]]>
https://www.technhit.in/how-to-install-wordpress-with-nginx-on-ubuntu-22-04/feed/ 0 1549
Install React JS on Ubuntu 22.04 LTS https://www.technhit.in/install-react-js-on-ubuntu-22-04-lts/ https://www.technhit.in/install-react-js-on-ubuntu-22-04-lts/#respond Mon, 01 Aug 2022 16:39:39 +0000 https://www.technhit.in/?p=1537 React. js is an open-source JavaScript library that is used for creating web frontend and UI components specifically for single-page applications. It’s used for handling the view layer for web and mobile apps. It is developed and maintained by Facebook and a large community of developers. History of React JS React was created by Jordan […]

The post Install React JS on Ubuntu 22.04 LTS appeared first on Tech Blog.

]]>
React. js is an open-source JavaScript library that is used for creating web frontend and UI components specifically for single-page applications. It’s used for handling the view layer for web and mobile apps. It is developed and maintained by Facebook and a large community of developers.

History of React JS

React was created by Jordan Walke, a software engineer at Facebook, who released an early prototype of React called “FaxJS”. It was first deployed on Facebook’s News Feed in 2011 and later on Instagram in 2012. And finally, it was open-sourced at JS Conference US in May 2013. And as a result, the Reacts first release was published in 2013.

In this tutorial, you will learn to install and create React Application on a Ubuntu Linux system.

View on Youtube:

Here are the major steps that you have to follow:

  1. Install a few utility packages
  2. –Add Node Repository 
  3. –Install Node JS
  4. –Create React App Utility
  5. –Finally Creating React App with Utility

Step 1 – Install Some Utility Packages and Update Repo:

install some necessary utility packages so  Install the following dependencies required by this tutorial like software-properties-common ca-certificates lsb-release apt-transport-https etc.

React JS

Step 2 – Add Node Repository:

Well, by default Node. js version comes with Ubuntu 22.04 LTS is 12.22.9, but we currently want the latest version 16.15. So, we need to add PPA sources which are required to be able to install NodeJS 16 on your Ubuntu 22.04 LTS.
Add the Node.js 16 (current stable version) PPA to your Ubuntu system

curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -

sudo apt update 

Step 3 – Install Node JS:

Node.js is required to create and run a React.js application. The following steps will install Node.js 16 on your Ubuntu system. or click here to choose your desired version. Next, run the following command to install the Node.js to your system:

sudo apt install -y nodejs

Check the currently active version of Node.js

node --version 

Also, you can check npm version using.

npm --version

Also, you can check npx version using.

npx --version

React JS1

Step 3–Create React App Installer Utility Package:

You need to install create-react-app  a utility package in your system.

sudo npm -g install create-react-app 

React JS2

Step 4 – Create A New React Application

create-react-app myapp 

On successful application creation, you will see a long result on the screen. In the end, you will find the result like below with some useful commands.

React JS3

Step 5 – Start React Application

Once you have created your React application. This will create a folder in the current directory with the project name. Switch to that project and run yarn start to start the application.

cd myapp  npm start 

The default reacts application starts on port 3000. Access your React application using 3000 port with the system IP address. For local machines use “localhost” followed by port.

reactjs

Let’s create an awesome user interface with React.

Conclusion

In this tutorial, you have learned, how to set up the React.js development environment and access the application in a web browser. Additionally, you found instructions to create a production build of your React application.

The post Install React JS on Ubuntu 22.04 LTS appeared first on Tech Blog.

]]>
https://www.technhit.in/install-react-js-on-ubuntu-22-04-lts/feed/ 0 1537
How to Install Django on Ubuntu 22.04 LTS https://www.technhit.in/how-to-install-django-on-ubuntu-22-04-lts/ https://www.technhit.in/how-to-install-django-on-ubuntu-22-04-lts/#respond Sat, 28 May 2022 16:58:04 +0000 https://www.technhit.in/?p=1530 Hello, world! Welcome to “TechNHIT ”  In this tutorial, we are going to install Django on Ubuntu 22.04 LTS server.  Let’s Know about Django Django is a full-featured Python web framework for developing dynamic websites and applications. Using Django, you can quickly create Python web applications. In this guide, you will get Django up and […]

The post How to Install Django on Ubuntu 22.04 LTS appeared first on Tech Blog.

]]>
Hello, world! Welcome to “TechNHIT ”  In this tutorial, we are going to install Django on Ubuntu 22.04 LTS server. 

Let’s Know about Django

Django is a full-featured Python web framework for developing dynamic websites and applications. Using Django, you can quickly create Python web applications.

In this guide, you will get Django up and running on an Ubuntu 22.04 server. After installation, you will start a new project to use as the basis for your site.

So, there are different ways to install Django, depending upon your needs and how you want to configure your development environment.

Here we are going to install Django in a self-contained environment using tools like venv and virtualenv. A virtual environment allows you to install Django in a project directory without affecting the larger system. You can therefore select Python packages on a per-project basis, regardless of conflicts with other projects’ requirements. This is typically the most practical and recommended approach to working with Django.

Prerequisites

Before you begin, you should have a non-root user with sudo privileges available on your Ubuntu 22.04 server.

Let’s begin by refreshing the local package index: let’s open a terminal and type

sudo apt update

Before instal Django, let’s check for the python installed in your system. Actually, ubuntu Jammy Jellyfish by default comes with python version 3.10. 

python3 -V

Next, let’s install pip and venv from the Ubuntu repositories: use the following command.

sudo apt install python3-pip python3-venv

Now, whenever you start a new project, you can create a virtual environment for it. Start by creating and moving into my new project directory: My Django Project.

mkdir ~/myDjangoproject
cd ~/myDjangoproject

Next, create a virtual environment within the project directory using the python command compatible with your Python version.

python3 -m venv my_env

We will call our virtual environment is my_env, you can name it something descriptive related to your project:

This will install standalone versions of Python and pip into an isolated directory structure within your project directory. A directory will be created with the name you select, which will hold the file hierarchy where your packages will be installed.

To install packages into the isolated environment, you must activate it by typing: 

source my_env/bin/activate

Your prompt should change to reflect that you are now in your virtual environment.

Note: To leave your virtual environment, you need to issue the deactivate command from anywhere on the system.

deactivate

Now it’s time to install Django. Type command pip install Django.

pip install django

Let’s check my Django admin version so type:

django-admin --version

To build your project, you can use Django-admin with the star project command. We will call our project djangoproject, but you can replace this with a different name. 

django-admin startproject djangoproject .

To avoid having too many nested directories, let’s tell Django to place the management script and inner directory in the current directory using the ending dot.

startproject will create a directory within your current working directory that includes: A management script manage dot py. And A directory that includes the actual project code.

Now its time to migrate the database. let’s use the migrate command with manage.py. 

python manage.py migrate

Finally, create an administrative user so that you can use the Djano admin interface. Let’s do this with the create super user command:

python manage.py createsuperuser

This will prompt for user name, if you left it blank then it will grab the ubuntu default username as you can see here my username is techblog. Lets set my user name admin.

Putting an email and password for my admin account.

Once you have a user, you can start up the Django development server using forllowng command:

python manage.py runserver localhost:8000
or
python manage.py runserver 0.0.0.0:8000

Now open up a web browser and here we go it working. And here you see the log reflection while accessing the server.

http://your_server_ip:8000

Now open admin dashboard using slash admin followed by our ip or localhost. Login using your credential and here is your admin panel.

http://your_server_ip:8000/admin

So, guys finally we deployed Django in Ubuntu 22.04 LTS server, hope this article is helpful to you Thank you.

The post How to Install Django on Ubuntu 22.04 LTS appeared first on Tech Blog.

]]>
https://www.technhit.in/how-to-install-django-on-ubuntu-22-04-lts/feed/ 0 1530
Laravel Mongodb Integration https://www.technhit.in/laravel-mongodb-integration/ https://www.technhit.in/laravel-mongodb-integration/#respond Sat, 11 Dec 2021 14:23:03 +0000 https://www.technhit.in/?p=1517 In this tech article we are going to integrate Laravel 8 with MongoDB and perform Auth and Basic CURD functionality. Laravel is a popular web development framework for PHP. It offers many defaults and provides a code structure that is easy to understand and quick to use for implementing web applications and APIs. MongoDB’s document […]

The post Laravel Mongodb Integration appeared first on Tech Blog.

]]>
In this tech article we are going to integrate Laravel 8 with MongoDB and perform Auth and Basic CURD functionality. Laravel is a popular web development framework for PHP. It offers many defaults and provides a code structure that is easy to understand and quick to use for implementing web applications and APIs.

MongoDB’s document model makes it a great database choice for web applications because its flexible schema structure will easily evolve to meet your growing needs.

Prerequisites

  1. PHP 7.2 or PHP8 installed into your system.
  2. composer
  3. node JS

Steps To Follow:

  1. Install MongoDB
  2. Install MongoDB PHP Extension
  3. Create Fresh Laravel Application
  4. Config Laravel for MongoDB connection
  5. Creating Laravel Auth Functionality
  6. Creating basic CURD controller and view
  7. Conclusion

Show Video Tutorial On Youtube:

Step 1– Install Mongo DB

curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
sudo apt update
sudo apt install mongodb

Step 2– Install the Laravel MongoDB PHP Extension

Before we can install the MongoDB libraries for Laravel, we need to install the PHP extension for MongoDB. Run the following command:

sudo pecl install mongodb

You will also need to ensure that the MongoDB extension is enabled in your php.ini file. The location of your php.ini file will vary depending on your operating system. Add the following line to your php.ini file:

extension="mongodb.so"

Now check your MongoDB status whether it’s running or not?

service mongodb status

Step 3– Install the Laravel Project

Once you have PHP and Composer installed, you can install Laravel. From a terminal window, enter the following command:

composer create-project laravel/laravel mongodb
cd mongodb/
php artisan serve --host=0.0.0.0 --port=8000

Step 4–Configuring Your Laravel Project to Use MongoDB

Open .env file from your laravel application directory and Configure MongoDB Database

DB_CONNECTION=mongodb
DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=myappdb
DB_USERNAME=
DB_PASSWORD=

 

In order for Laravel to communicate with your MongoDB database, you will need to add your database connection information to the config\database.php file under the “connections” object in your Laravel project as shown in this example:

'connections' => [.....
.......
'mongodb' => [
            'driver' => 'mongodb',
           'host' => env('DB_HOST', '127.0.0.1'),
           'port' => env('DB_PORT', 27017),
           'database' => env('DB_DATABASE', 'myappdb'),
           'username' => env('DB_USERNAME', ''),
           'password' => env('DB_PASSWORD', '')
         ],
........

 

Make sure to include the correct authentication information.

Set the default database connection name in config\database.php at top section

/*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mongodb'),

Define Providers:

In order to make connections with MongoDB you need Jenssegers Library:

composer require jenssegers/mongodb

If your Laravel project does not load dependencies automatically, you may also need to add the following to the provider’s section in your app.php file:

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
         


         Jenssegers\Mongodb\MongodbServiceProvider::class,       


Step 5– Creating Laravel Auth Functionality

Now install auth functionality to your application, here I am going to use vue js framework for front end. So you can choose angular, react also

composer require laravel/ui
php artisan ui vue --auth

You can see that authentication scaffolding generated. Also, you need to run the npm install and run dev in order to make it fully functional with compiling all js and CSS files. Npm stands for Node package manager It puts modules in place so that node can find them, and manages dependency conflicts intelligently. If npm not installed in your system then first install npm:

sudo apt install npm

Just go ahead and type npm install. It will install all required dependency script automatically.

npm install

After that use npm run dev command to compile all js and css file for your application.

npm run dev

Now finaly migurate your table to database

php artisan migrate

Change user model default authentication to Jenssegers MongoDB Authentication class at App\Models\User:

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Jenssegers\Mongodb\Auth\User as Authenticatable;     //<--- Add This Line
//use Illuminate\Foundation\Auth\User as Authenticatable; //--> Commentout this line
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

Step 6– Creating basic CURD controller and view

Crate model post with model and migration

php artisan make:model Post -mc

Creating Web Routs at Routs\web.php

Route::get('/post/{slug}', 'PostController@show');
Route::post('/post', 'PostController@store');
Route::get('/displayform', 'PostController@displayForm');

Edit Post Model as below:

use Jenssegers\Mongodb\Eloquent\Model;

class Post extends Model
{
    protected $connection = 'mongodb';
}

Add following function at Post Controller:

public function displayForm(){
        return view('form');
    }

public function show($slug){
        return view('post',['post'=>Post::where('slug','=', $slug)->first()]);
    }

public function store(Request $request){
        $post = new Post;
       $post->title = $request->title;
       $post->body = $request->body;
       $post->slug = $request->slug;

       $post->save();
       return response()->json(["result" => "ok"], 201);
    }
public function destroy($postId)
 {
     $post = Post::find($postId);
     $post->delete();

      return response()->json(["result" => "ok"], 201);     
 }

public function update(Request $request, $postId)
   {
       $post = Post::find($postId);
       $post->title = $request->title;
       $post->body = $request->body;
       $post->slug = $request->slug;
       $post->save();

       return response()->json(["result" => "ok"], 201);       
   }

Add views form and post inside resourse directory:

resource\view\form.blade.php

<!DOCTYPE html>
<html>
<body>

<h2>HTML Forms to test mongodb</h2>

{!! Form::open(['route' => 'post', 'id' => 'action_form']) !!}
  <label for="fname">Title:</label><br>
  <input type="text" id="title" name="title" ><br>
  <label for="lname">body:</label><br>
  <input type="text" id="body" name="body" ><br><br>
  <label for="lname">slug:</label><br>
  <input type="text" id="slug" name="slug" ><br><br>
  <input type="submit" value="Submit">
{!! Form::close() !!}
<p>If you click the "Submit" button, the form-data will be sent to mongodb".</p>

</body>
</html>

resource\view\post.blade.php

<!DOCTYPE html>
<html>
<head>
   <title>MyBlog</title>
</head>
<body>
   <h1>{{$post->title}}</h1>
   <div>{{$post->body}}</div>
</body>
</html>

Conclusion:

In this tutorial, we were able to connect a Laravel website to a MongoDB server. As we saw, the integration is simple and seamless.

Unlike relational databases like MySQL, you don’t need to worry about creating and maintaining database migrations. You can use the same Eloquent model functionality that you may already be familiar with. You can also take advantage of the additional querying capabilities that MongoDB provides.

The post Laravel Mongodb Integration appeared first on Tech Blog.

]]>
https://www.technhit.in/laravel-mongodb-integration/feed/ 0 1517
How to Install PHP 8 on Ubuntu 20.04 LTS Server https://www.technhit.in/how-to-install-php-8-on-ubuntu-20-04-lts-server/ https://www.technhit.in/how-to-install-php-8-on-ubuntu-20-04-lts-server/#comments Sat, 20 Nov 2021 14:55:53 +0000 https://www.technhit.in/?p=1507 PHP is one of the most widely used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are written in PHP. At the time of writing this guide, the latest version of PHP is PHP 8.0. It was released on November 26, 2020. It boasts of new features and optimizations such as […]

The post How to Install PHP 8 on Ubuntu 20.04 LTS Server appeared first on Tech Blog.

]]>
PHP is one of the most widely used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are written in PHP.

At the time of writing this guide, the latest version of PHP is PHP 8.0. It was released on November 26, 2020. It boasts of new features and optimizations such as union types, named arguments, null safe operator, match expression, JIT, and improvements in error handling and consistency.

By default, Ubuntu 20.04 Lts does not come with PHP 8.0 version in its default repository So, you need to add from the ondrej/php PPA repository. This tutorial is also applicable to Ubuntu 18.04.

Following steps we are goining to execute:

  • Step 1)–Enable PHP Repository
  • Step 2)– Install PHP 8
  • Step 3) – Installing PHP Extensions
  • Step 4.1) – Install PHP 8 with Apache
  • Step 4.2) – Install PHP 8 with Nginx
  • Step 5) – Switch Default PHP Version (If your Server Running Multiple PHP Version)
  • Step 6)Testing PHP

Note: If you are going to upgrading your existing live server, Before upgrading to or installing PHP 8, make sure that your applications support it and make complete backup your existing environment to avoid any data losses.

Step 1)–Enable PHP Repository

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Step 2)– Install PHP 8

Execute the following command to install PHP 8

sudo apt install php8.0

After the installation has been completed, you can confirm the installation using the following command

php -v

Step 3) – Installing PHP Extensions

Now, install the required PHP modules for your application. Use the following command to search all available PHP 8.0 modules.

sudo apt search php8.0-*

Then install the required PHP modules. The following command will install some frequently used PHP modules on your system.

sudo apt install php8.0-common php8.0-mysql php8.0-xml php8.0-curl php8.0-gd php8.0-imagick php8.0-cli php8.0-dev php8.0-imap php8.0-mbstring php8.0-opcache php8.0-soap php8.0-zip -y

You can choose exact extensions as per your requirement from the search list.

Step 4.1) – Install PHP 8 with Apache

Apache is a popular web server widely used for deploying PHP web applications. On Debian-based systems, this is available with the name “apache2”.

An Apache module is available to integrate PHP. For PHP 8.0 install the following Apache module

sudo apt install libapache2-mod-php8.0 

Then enable PHP 8 module

sudo a2enmod php8.0 

Step 4.2) – Install PHP 8 with Nginx

There is no official PHP module for the Nginx server. In that case, we will use PHP-FPM to deploy PHP applications over Nginx web servers.

So, first, install PHP fpm on your system.

sudo apt install php8.0-fpm 

Once the installation is finished, enable and start the service.

sudo systemctl enable php8.0-fpm
sudo systemctl start php8.0-fpm  

Next, update the Nginx server block configuration with the following code.

server {

   # server block code ...

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    }
}

The above code instructs the Nginx server to process all files with the “.php” extension using PHP-fpm.

Finally, restart the Nginx webserver to apply the changes.

sudo systemctl restart nginx 

Step 5) – Switch Default PHP Version (If your Server Running Multiple PHP Version)

You can easily switch between multiple PHP versions installed on any system. Execute the following command on the terminal:

sudo update-alternatives --config php  

This system has PHP 8.0 and PHP 7.4 installed. Select a PHP version on our choice.

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.0   80        auto mode
  1            /usr/bin/php7.4   74        manual mode
  2            /usr/bin/php8.0   80        manual mode

Press  to keep the current choice[*], or type selection number: [ENTER CHOICE HERE]

Step 6)Testing PHP

To test whether the web server is configured properly for PHP processing, create a new file named info.php inside the /var/www/html directory with the following code:

/var/www/html/info.php
<?php

phpinfo();

Save the file, open your browser, and visit: http://your_server_ip/info.php.

You’ll see information about your PHP configuration similar to the following:

Hope this tech article is helpfull for you while you want to install PHP 8.0 and comfortably integrate it with either Apache or Nginx web servers. Awaited your feedback because it makes us more perfect.

The post How to Install PHP 8 on Ubuntu 20.04 LTS Server appeared first on Tech Blog.

]]>
https://www.technhit.in/how-to-install-php-8-on-ubuntu-20-04-lts-server/feed/ 1 1507
Screen Command in Linux https://www.technhit.in/screen-command-in-linux/ https://www.technhit.in/screen-command-in-linux/#respond Fri, 12 Nov 2021 15:02:53 +0000 https://www.technhit.in/?p=1489 Hello, world! Welcome to “TechBlog” In this Tech Article, we are going to learn about Screen command and its utility. Introduction: Have you ever faced a situation where you perform a long-running task on a remote machine, and suddenly your connection drops, the SSH session is terminated, and your work is lost. Well, it has […]

The post Screen Command in Linux appeared first on Tech Blog.

]]>
Hello, world! Welcome to “TechBlog” In this Tech Article, we are going to learn about Screen command and its utility.

Introduction:

Have you ever faced a situation where you perform a long-running task on a remote machine, and suddenly your connection drops, the SSH session is terminated, and your work is lost. Well, it has happened to all of us at some point, hasn’t it? Luckily, there is a utility called screen that allows us to resume the sessions.

Screen Intro and Why Screen

More specifically we are going to discuss the following topic:

  • What is Screen Command
  • Install screen into Linux system
  • Command Flags, arguments, and Shortcuts
  • Practical use cases

What is Screen Command:

Screen or GNU Screen is a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session. Processes running in Screen will continue to run when their window is not visible even if you get disconnected.

What is screen

Install screen into Linux system

it’s easy to install like anything else. It’s in the repos of every linux, so you have to do nothing special, you know, just type apt install screen. If you logged in with sudo user then use sudo before the command.

Installation of screen command: To install the screen command simply go to the terminal and type the following command:

sudo apt install screen

Install Screen

I have installed a screen in my system.

Command Flags, arguments, and Shortcuts:

Syntax:

screen [-opts] [cmd [args]]

Options:

    • -a: It force all capabilities into each window’s termcap.
    • -A -[r|R]: It adapt all windows to the new display width & height.
    • -c file: It read configuration file instead of ‘.screenrc’.
    • -d (-r): It detach the elsewhere running screen (and reattach here).
    • -dmS name: It start as daemon: Screen session in detached mode.
    • -D (-r): It detach and logout remote (and reattach here).
    • -D -RR: It do whatever is needed to get a screen session.
    • -e xy: It change the command characters.
    • -f: It make the flow control on, -fn = off, -fa = auto.
    • -h lines: It set the size of the scroll back history buffer.
    • -i: It interrupt output sooner when flow control is on.
    • -l: It make the login mode on (update /var/run/utmp), -ln = off.
    • -ls [match]: It display all the attached screens.
    • -L: It turn on output logging.
    • -m: It ignore $STY variable, do create a new screen session.
    • -O: It choose optimal output rather than exact vt100 emulation.
    • -p window: It preselect the named window if it exists.
    • -q: It quiet startup. Exits with non-zero return code if unsuccessful.
    • -Q: It commands will send the response to the stdout of the querying process.
    • -r [session]: It reattach to a detached screen process.
    • -R: It reattach if possible, otherwise start a new session.
    • -S sockname: It name this session .sockname instead of …
    • -t title: It set title. (window’s name).
    • -T term: It use term as $TERM for windows, rather than “screen”.
    • -U: It tell screen to use UTF-8 encoding.
    • -v: It print “Screen version 4.06.02 (GNU) 23-Oct-17”.
    • -x: It attach to a not detached screen. (Multi display mode).
    • -X: It execute as a screen command in the specified session.

Shortcut keys Options:

    • Ctrl-a + c: It create a new windows.
    • Ctrl-a + w: It display the list of all the windows currently opened.
    • Ctrl-a + A: It rename the current windows. The name will appear when you will list the list of windows opened with Ctrl-a + w.
    • Ctrl-a + n: It go to the next windows.
    • Ctrl-a + p: It go to the previous windows.
    • Ctrl-a + Ctrl-a: It back to the last windows used.
    • Ctrl-a + k: It close the current windows (kill).
    • Ctrl-a + S: It split the current windows horizontally. To switch between the windows, do Ctrl-a + Tab.
    • Ctrl-a + |: It split the current windows vertically.
    • Ctrl-a + d: It detach a screen session without stopping it.
    • Ctrl-a + r: It reattach a detached screen session.
    • Ctrl-a + [: It start the copy mode.
    • Ctrl-a + ]: It paste the copied text.

How to start a screen in Linux:

Generally, to start a screen session you can simply type the screen on the terminal it will start a screen session for you. Here you can see their screen starting with some information like its version license details etc.

start screen

you can continue reading documentation by pressing the space bar or pressing the enter key to start the screen.

How to list running screen:

If you do screen -ls then it will display all available screen sessions running in your system.

screen list

How to specify screen name:

Actually screen has an option dash S. Using this you can name a screen session as you wish. For example, I am going to give it my session name “config”. ie. screen -S config

screen specific name

How to reattach running screen:

Now we reattach our running screen. So, the command is screen -R <screen ID>. this will bring you your running screen. So every time you just need to put Screen ID after flag R.

screen reattach

Practical use cases:

Let’s assume that you are in a situation where you need to monitor the running process in your system while at the same time you need to keep eye on your network traffic. and the other hand you need to install some script.

use of screen

 

View on Youtube:

And you can detach the entire screen any time and if you left the system still the process is running as usual in the background. You can resume screen any time as I earlier mentioned.  And this way the screen becomes a very useful tool in Linux. So, guys hope this article is helpful to you, Thank you.

 

The post Screen Command in Linux appeared first on Tech Blog.

]]>
https://www.technhit.in/screen-command-in-linux/feed/ 0 1489
Install and config Brotli Compression with Apache https://www.technhit.in/install-and-config-brotli-compression-with-apache/ https://www.technhit.in/install-and-config-brotli-compression-with-apache/#respond Mon, 09 Aug 2021 06:51:55 +0000 https://www.technhit.in/?p=1481 Today’s world is growing very fast and everyone is in a hurry! According to a Google study, 40% of people abandon a website that takes more than 3 seconds to load and a 1-second delay in page response can result in a 7% reduction in conversions. Yes, every second matters! hence Brotli comes into effect […]

The post Install and config Brotli Compression with Apache appeared first on Tech Blog.

]]>
Today’s world is growing very fast and everyone is in a hurry! According to a Google study, 40% of people abandon a website that takes more than 3 seconds to load and a 1-second delay in page response can result in a 7% reduction in conversions. Yes, every second matters! hence Brotli comes into effect to speed up your website.

Just like Gzip, Brotli is also a generic-purpose compression algorithm developed by Google. It compresses data using a combination of modern technologies and algorithms. It is similar in speed to deflate but provides higher compression. Brotli compression is supported by all the major browsers like Chrome, Firefox, Safari, Edge.

In this Article we are going to configure Brotli Compressor Mechanism with Apache Web Server.

See on Youtube:

Prerequisites

  1. Need sudo  privileged account.
  2. Assumed that you have Apache webserver running with a Virtual host which serving web content.

Well, at this point we understand that Brotli can help you to speed up your heavy website, and save your bandwidth also. And eventually, it helps optimization on SEO ranking in the competition market.

We assume that you have an existing web server with Apache in order to do the experiment, and if you are in a production environment then I strongly recommend to make a backup your files before that. You can also check out this video how to setup Apache Vhost above here.

Go ahead and open terminal type :

sudo apt install brotli 

So, after install Brotli, enable the module in Apache.

sudo a2enmod brotli 

Now You need to restart Apache2 in order to make module effective.

sudo systemctl restart apache2 

Now, open up Apache Vhost config file. go ahead and type nano /etc/apache2/site-available/<your config file>.

Inside your config file place cursor after directory tag and put an If Module.

<VirtualHost *:80>
    ServerName myapp1.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/html/wordpress/

    <Directory /var/www/html/wordpress>
        Options Indexes MultiViews
        AllowOverride All
        Require all granted
    </Directory>
/////////////////////////////// Add this config to your Vhost file ////////////////////////////
    <IfModule mod_brotli.c>
        AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript
    </IfModule>
///////////////////////////////////////////////////////////////////////////////////////////////

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

 

Inside If Module add output filter type Brotli Compress, and then put your file type you want to compress. So, here is put html, css, Js etc.

After that save the configuration and exit. And again, restart the Apache service in order to make effect in your website.

sudo systemctl restart apache2 

Now open up the browser and load the page in another tab, it will be bit faster than previous. You could check whether your Brotli Compressor work or not, using Curl command. So, open a local terminal and type the following command.

curl -I -H 'Accept-Encoding: br' http://myapp1.com 

You can see the output that content encoding Brotli is working fine for me.

HTTP/1.1 200 OK
Date: Mon, 09 Aug 2021 06:50:56 GMT
Server: Apache/2.4.41 (Ubuntu)
Link: <http://myapp1.com/index.php?rest_route=/>; rel="https://api.w.org/"
Vary: Accept-Encoding
Content-Encoding: br
Content-Length: 1
Content-Type: text/html; charset=UTF-8

So, guys hope this article helpful to you, Thank you.

The post Install and config Brotli Compression with Apache appeared first on Tech Blog.

]]>
https://www.technhit.in/install-and-config-brotli-compression-with-apache/feed/ 0 1481