Redirect HTTP traffic to HTTPS in Apache

How to use Apache to redirect all traffic from http to https

If your website uses Apache and SSL, there’s not much reason to keep using HTTP with your website. Having both HTTP and HTTPS just creates duplicate content, as now any given page will be accessible through two technically different URLs.

In this guide, we’ll assume you’re already using Apache on a Linux system and want to redirect all HTTP traffic to HTTPS. This will make sure that all your visitors are only connecting through HTTPS by forcing their browser over to the secure protocol if they happen to open an HTTP link. If a user decides to preface a link with http://, your site will be smart enough to still send them to the correct page, rather than showing duplicate content or displaying a 404 error.

There are two ways to set up this redirection in Apache. The better method is to configure Virtual Host, but users with hosted websites may not have access to this configuration. The second method is by making some changes to the .htaccess file. We’ll cover the step by step instructions for both methods below. Let’s get started.

In this tutorial you will learn:

  • How to redirect HTTP to HTTPS with Virtual Host
  • How to redirect HTTP to HTTPS with .htaccess file

Read more

How to restrict access to a resource using Apache on Linux

How to restrict access to a resource using Apache on Linux

Restricting access to a resource is often required when using the web. On complex web applications, this is often implemented using a login system which can be more or less sophisticated. If our requirements our pretty basic, however, we can use the authentication system provided by the Apache web server. In this tutorial we will see how can we do it.

In this tutorial you will learn:

  • How to restrict access to a web page using the Apache web server
  • How to store the user passwords in plain text files
  • How to store the user passwords in a database
  • How to allow access to multiple users

Read more

Apache Hadoop on Ubuntu 20.04 Focal Fossa

Ubuntu 20.04 Hadoop

Apache Hadoop is comprised of multiple open source software packages that work together for distributed storage and distributed processing of big data. There are four main components to Hadoop:

  • Hadoop Common – the various software libraries that Hadoop depends on to run
  • Hadoop Distributed File System (HDFS) – a file system that allows for efficient distribution and storage of big data across a cluster of computers
  • Hadoop MapReduce – used for processing the data
  • Hadoop YARN – an API that manages the allocation of computing resources for the entire cluster

In this tutorial, we will go over the steps to install Hadoop version 3 on Ubuntu 20.04. This will involve installing HDFS (Namenode and Datanode), YARN, and MapReduce on a single node cluster configured in Pseudo Distributed Mode, which is distributed simulation on a single machine. Each component of Hadoop (HDFS, YARN, MapReduce) will run on our node as a separate Java process.

In this tutorial you will learn:

  • How to add users for Hadoop Environment
  • How to install Java prerequisite
  • How to configure passwordless SSH
  • How to install Hadoop and configure necessary related XML files
  • How to start the Hadoop Cluster
  • How to access NameNode and ResourceManager Web UI

Read more

LAMP server setup on Ubuntu 20.04 Focal Fossa

How to setup LAMP server on Ubuntu 20.04 Focal Fossa

LAMP is a conventional model of web service stacks. The components that LAMP is built from are all open-source and include: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system, and the PHP programming language. In this short tutorial we will be configuring a basic LAMP server on Ubuntu 20.04 Focal Fossa.

You may also be interested in our article on creating a docker based LAMP stack on Ubuntu 20.04.

In this tutorial you will learn:

  • How to install LAMP server on Ubuntu 20.04.
  • How to open firewall port to allow HTTP and HTTPS incoming traffic.
  • How to connect to MySQL database using a PHP script.

Read more

Using cookies in PHP

How to enable sessions in PHP with cookies

Cookies are all around in our everyday life while we browse the Internet. Most people wouldn’t know much about them, if not for those “our website uses cookies to be operational” signs that are on mostly any page now since GDPR. Cookies have a long history if sometimes being good, sometimes bad. As it is usual with most aspects of the world, this technology can be used in a good or bad way.

In this tutorial we will explore cookies a bit from the server side programming perspective: we’ll create an example cookie in PHP, and store the visitor’s chosen username in it. The cookie will reside in the browser of the visitor, so on the next visit we can read it and use it to greet the visitor on the username submitted.

Our simple webpage will recognize the visitor as long as the cookie is present in the browser. We do not store any information on the server side: if the visitor first checks in from a PC, and next time from a smartphone, we will not know it is the same individual. This is one of the main point with cookies: we can only identify the given client, and only as long as the data is provided by that particular browser.

In this tutorial you will learn:

  • How to setup the test environment
  • How to write a simple example program that uses cookies
  • How to test the workings of the program
  • How to reset the environment

Read more

How to analyze and interpret Apache Log

How to analyze and interpret Apache Webserver Log

Apache web servers can generate a lot of logs. These logs contain information such as the HTTP requests that Apache has handled and responded to, and other activities that are specific to Apache. Analyzing the logs is an important part of administering Apache and ensuring that it runs as expected.

In this guide, we’ll go over the different logging options present in Apache and how to interpret this log data. You’ll learn how to analyze the logs that Apache produces and how to configure the logging settings to give you the most relevant data about what Apache is doing.

In this tutorial you will learn:

  • Configure and understand Apache webserver logging
  • What are Apache log levels
  • How to interpret Apache log formatting and its meaning
  • What are the most common Apache log configuration files
  • How to extend logging configuration to include forensic data

Read more

How to benchmark Webserver with Apache Bench

How to benchmark Webserver with Apache Bench

Apache Bench is a tool used to measure the performance of a web server. Despite having “Apache” in its name, it can actually be used to test any type of web server. In this tutorial, we’ll go over the steps to use Apache Bench and how to interpret its report about a web server’s performance.

Apache Bench works by sending varying amounts of HTTP requests to the web server and recording the response times. It can tell you how much congestion the server can handle before it gets overwhelmed and performance diminishes.

In this tutorial you will learn:

  • How to install Apache Bench
  • How to use Apache Bench
  • How to interpret Apache Bench Results

Read more

Installation of Apache Web Server on RHEL 8 / CentOS 8 using dnf command

How to install Apache on RHEL 8 / CentOS 8 Linux

The Apache HTTP Server or simply Apache, is free and open-source cross-platform web server software developed and maintained by Apache Software Foundation. Apache is a easy to learn and configure web server providing an ability to host websites mainly via HTTP or HTTPS protocols. Under RHEL 8 / CentOS 8 system Apache webserver is know under name httpd.

In this tutorial you will learn:

  • How to install Apache webserver
  • How to enable and start Apache webserver
  • How to open firewall HTTP port 80
  • How to create basic same website

Read more

HDFS Architecture

How to install Hadoop on RHEL 8 / CentOS 8 Linux

Apache Hadoop is an open source framework used for distributed storage as well as distributed processing of big data on clusters of computers which runs on commodity hardwares. Hadoop stores data in Hadoop Distributed File System (HDFS) and the processing of these data is done using MapReduce. YARN provides API for requesting and allocating resource in the Hadoop cluster.

The Apache Hadoop framework is composed of the following modules:

  • Hadoop Common
  • Hadoop Distributed File System (HDFS)
  • YARN
  • MapReduce

This article explains how to install Hadoop Version 2 on RHEL 8 or CentOS 8. We will install HDFS (Namenode and Datanode), YARN, MapReduce on the single node cluster in Pseudo Distributed Mode which is distributed simulation on a single machine. Each Hadoop daemon such as hdfs, yarn, mapreduce etc. will run as a separate/individual java process.

In this tutorial you will learn:

  • How to add users for Hadoop Environment
  • How to install and configure the Oracle JDK
  • How to configure passwordless SSH
  • How to install Hadoop and configure necessary related xml files
  • How to start the Hadoop Cluster
  • How to access NameNode and ResourceManager Web UI

Read more

Examples page served by Apache Tomcat

How to install apache tomcat on Linux RHEL 8 / CentOS 8

In this tutorial we will learn how to install Apache Tomcat 8 application container to RHEL 8 / CentOS 8. We will be using the zip package available to download from the Apache Tomcat website. As this package will not handle setting up the environment, we will create it from the command line.

In this tutorial you will learn:

  • How to install Apache Tomcat from zip file
  • How to create the environment for the Tomcat server from command line
  • How to add basic service file to systemd
  • How to enable autostart, start and stop the Tomcat server
  • How to verify Tomcat is reachable

Read more