Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Magento 2 Cookbook

You're reading from   Magento 2 Cookbook Exploring Magento 2 in the form of recipes

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781785887062
Length 342 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Toc

Table of Contents (10) Chapters Close

Preface 1. Installing Magento 2 on Apache and NGINX FREE CHAPTER 2. Magento 2 System Tools 3. Enabling Performance in Magento 2 4. Creating Catalogs and Categories 5. Managing Your Store 6. Creating a Magento 2 Theme 7. Creating Magento 2 Extensions – the Basics 8. Creating Magento 2 Extensions – Advanced Index

Installing Apache

Throughout the following recipes, we will install the latest Apache 2.4.x version on a Software as a Service (SaaS) platform hosted by DigitalOcean. The current Apache version supports HTTP/2. This recipe will show you how to do this.

Tip

HTTP/2 is an optimized version of the Hypertext Transfer Protocol (HTTP), also known as HTTP version 2 (HTTP/2). Some of the new features of HTTP/2 are a more efficient usage of network resources and network latency. HTTP/2 allows multiple concurrent connections over a single Transmission Control Protocol (TCP) connection at once, which optimizes TCP load. Merging CSS and JS is not necessary anymore. HTTP/2 service also provides the possibility to use server push, which allows a proactive push of resources to the client.

Getting ready

For this recipe, you will need to create an account at DigitalOcean https://www.digitalocean.com/. No other prerequisites are required.

How to do it...

For the purpose of this recipe, let's assume that we need to create an Apache hosting environment. The following steps will guide you through this:

  1. The first step is creating an account at https://cloud.digitalocean.com/registrations. All the steps to create an account are straightforward. Confirm your mail and update your billing profile.
  2. Start creating your first Droplet. Choose your hostname, and select your size (2GB CPU's or 40GB SSD Disk). Next, pick your region (DigitalOcean has many regions available worldwide). Select your image (we will use the latest Ubuntu). Select extra available settings such as Private Networking to run multiple servers including an Internet network or backup and IPv6 options. If you already have an SSH key, you can upload this:
    How to do it...
  3. The Droplet takes approximately 60 seconds to get created. You will get an e-mail right after including all the additional login details such as the hostname, IP address, username, and password.
  4. Configure your domain name, yourdomain.com, to the addressed IP address from the Droplet:
    yourdomain.com    A    123.123.123.123
         www        CNAME   yourdomain.com
  5. Connect your Droplet with SSH using your favorite SSH client (putty or terminal) and change your password:
    sudo ssh yourdomain.com
    
  6. First, we will update your server to the latest updates available:
    apt-get update && apt-get -y upgrade
    
  7. Next, we will install Apache 2 using a third-party package. Currently, Ubuntu doesn't include the latest Apache 2.4.x with HTTP/2 support. The third-party vendor that we will use is https://launchpad.net/~ondrej/+archive/ubuntu/apache2. Run the following command:
    echo "deb http://ppa.launchpad.net/ondrej/apache2/ubuntu wily main" | sudo tee -a /etc/apt/sources.list.d/apache2.list
    echo "deb-src http://ppa.launchpad.net/ondrej/apache2/ubuntu wily main" | sudo tee -a /etc/apt/sources.list.d/apache2.list
    
  8. Before we can install Apache 2, we need to authorize the package by installing a signed key:
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0x4F4EA0AAE5267A6C
    
  9. Now, we will update our Ubuntu system using the latest Apache2 packages:
    apt-get update && apt-get -y install apache2
    
  10. Once every Apache 2 package is installed, we can check whether everything is in order by running the following command on the shell:
    apache2 -v
    

    The output of this command is as follows:

    root@mage2cookbook:~# apache2 -v
    Server version: Apache/2.4.17 (Ubuntu)
    

If you have followed steps 1 to 9, you will be able to see if the web server is running. Go to your favorite browser and search using your yourdomain.com.

Tip

In the DigitalOcean control panel, you can create multiple snapshots at all times during the recipes. This will help you in restoring an old version or just going back in time.

How it works…

Let's recap and find out what we did throughout this recipe. In steps 1 through 3, we create a clean hosting server setup using DigitalOcean. Next, we connect the Droplet IP to your domain name in DNS. After login via SSH, we are able to update the server and continue to the process of installing Apache 2 via a third-party repository. Depending on the Ubuntu setup, we need to change the version name, such as precise, trusty, wily, vivid, or xenial, to install the software.

In step 8, we submit a key that will validate the repository before we can start installing the Apache 2 software. In step 9, we use a simple command to update the repository and start installing.

There's more…

If you want to check whether Apache is running fine, use one of the following commands:

service apache2 status
netstat –anp | grep apache2
You have been reading a chapter from
Magento 2 Cookbook
Published in: Mar 2016
Publisher:
ISBN-13: 9781785887062
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image