Chapter 24

Common Web Server Stacks

A web server stack is a set of software installed and configured to work together to serve content over a network. There are many stacks of software that are common enough to be referred to using acronyms. This chapter describes some of the most popular. Before diving deeply into each of the related technologies, this chapter introduces some of the most popular types of web server stacks in use today.

All the stacks in this chapter can be assembled and run on Ubuntu or any Linux distribution and are common enough to be worth knowing something about. The pieces being used to assemble the stacks described in this chapter can often be replaced with different software that serves the same purpose, as is illustrated in the discussion of the LAMP stack.

There is a lot to think about, regardless of which stack you choose. This chapter is intended to give a high-level overview of a few popular options. Large books have been written and are available for the various stacks, for each of the underlying layers in the stacks, and so on. The goal of this chapter is to help you begin to think about how to accomplish a much larger goal, not to outline all the necessary steps and configurations.

LAMP

LAMP was one of the first stacks to become popular. It is composed of Linux, the Apache web server, the MySQL database, and either PHP, Python, or Perl. (See the bonus online chapters for more information about these languages.) Because all the technologies comprising LAMP are free and open source, LAMP is inexpensive to set up and use, making it much more affordable than other options for setting up a web server or even selling web hosting to others.

LAMP became popular during the initial rise of Linux as an operating system for web hosting, both in large enterprise corporations looking to save money and in small startup companies selling server space and web hosting to mom-and-pop stores wanting to join the Internet craze. With its careful concern for stability and security, inherited from the creator’s love of UNIX, coupled with being free to install and use and update, Linux was from the start an ideal platform for most hosting needs.

LAMP is still popular and in wide use today. Many large sites use LAMP applications, and LAMP is not going away anytime soon.

Running on top of Linux is the Apache web server. (See Chapter 25, “Apache Web Server Management,” for detailed information about Apache.) Apache takes care of listening to an open communication port for requests and responding to those requests by serving the requested information.

Working in conjunction with Apache is a database that stores the information to be served. This is typically a relational database such as MySQL. (See Chapter 28, “Administering Relational Database Services,” for detailed information about MySQL.) These days, it could be MySQL or MariaDB or PostgreSQL or another similar product.

Off-the-shelf commodity as well as custom content management software has been written using PHP, Python, or Perl. For example, WordPress uses PHP, django CMS uses Python, and Movable Type uses Perl. Which language you install and use depends on the framework or software you are using or which you prefer to use to write your software.

Of the web stacks discussed in this chapter, the LAMP stack is the easiest to install quickly. If you install Ubuntu Server, you are given an option of setting up the machine as a LAMP server during installation. You can even set the root password for MySQL during installation. The upside is that you can have a complete LAMP server up and running in 15 minutes or so. The downside to this method is that you are limited in your configuration. You will install Ubuntu (Linux), Apache, MySQL, and PHP. That is great if you simply want to install a product such as WordPress next or do some simple web development. For anything more unique, however, we suggest that you install the server first and then install and configure each component, one at a time.

To install LAMP on your own, you need to first install Ubuntu—which can be standard Ubuntu if you are going to use a local laptop or desktop machine for development or Ubuntu Server on a remote machine. Then you can install each of the following components, setting up and configuring each one before moving to the next:

  1. Install OpenSSH and configure the machine for SSH access. This is vital if you intend to eventually serve content via HTTPS, which is becoming a necessity as major browsers like Google Chrome intend to mark as insecure any websites that do not use HTTPS.

  2. Install Apache 2 and set it up for the sites you intend to host, including HTTPS configuration. Later, you will also configure your firewall to allow traffic via the ports specific to HTTP and HTTPS (80 and 443).

    As a side note, unless you are a large corporation, you do not need to pay for web certificates from an expensive Certificate Authority anymore. Check out Let’s Encrypt at https://letsencrypt.org/.

  3. Install MySQL, MariaDB, or your relational database of choice, making sure to set a secure root password. You are strongly urged to create a web server–specific user in the database that will interact with the database rather than use the root account in your software.

  4. Install PHP, Python, or Perl as appropriate for the software you intend to run/write that will display your content.

Alternatively, you can install and set up a basic LAMP stack much more easily using a couple commands, as follows:

$ sudo apt install tasksel
$ sudo tasksel install lamp-server

This will install everything mentioned previously interactively, giving you a chance to set your MySQL root password and so on during the process. Using tasksel is much more convenient, but with a generic and simple configuration.

At this point, regardless of which method you use, the entire stack is installed. You can now proceed to install open source software such as Drupal or develop your own.

LEMP

The main difference between LAMP and LEMP is the web server that is used. Whereas LAMP uses Apache, LEMP uses Nginx. (See Chapter 26, “Nginx Web Server Management,” for detailed information about Nginx.)

Note

It seems that whoever created the acronym LEMP decided a vowel was needed, so the E stands for Nginx—but the server name is pronounced as though it starts with an E, so it actually makes sense.

Beyond the obvious differences between Apache and Nginx as mature web servers with different use cases, the only other difference is that there is currently not a LEMP option in the Ubuntu Server installation. That does not make much difference, though, as we recommend that you install Ubuntu first and then install and configure each component individually rather than using the shortcut during Ubuntu installation.

Note

We could probably write a similar section for nearly every HTTP server listed in Chapter 27, “Other HTTP Servers.” If someone wants to install an LLMP stack (Linux, lighttpd, MySQL, PHP), for example, it is certainly possible.

MEAN

As the web moved forward with more and more dynamic websites and applications, it became vital for web developers to know JavaScript. Then someone had the idea of writing applications that could run both on the client and server sides in the same language. The foundational reasoning for doing this was speed. It takes time to develop for the Web. If you use multiple programming languages, you have to either learn multiple languages or hire people who know the languages you use. Further, as more and more websites have become fully interactive experiences, learning JavaScript is already a necessity for more developers. Therefore, JavaScript is now the language of choice for both the client and server sides—and it is an important component in the MEAN web stack.

You do not have to be running Linux to serve content with MEAN. You can also run a MEAN stack on Windows or on macOS. In addition, everything for this stack is written in JavaScript. The database used is one of the NoSQL options, MongoDB, which works very well with the JSON data format used in a MEAN stack.

A MEAN stack consists of four main components, regardless of the operating system being used as a platform:

MongoDB—One of the NoSQL databases discussed in Chapter 29, “NoSQL Databases,” MongoDB is used to store data in JSON format for an application.

Express.js—This back-end web application framework runs on Node.js.

AngularJS or Angular—These are both JavaScript MVC (model–view–controller) frameworks. Angular is newer and is a complete rewrite of AngularJS, with some intentional changes along the way. Angular provides the front-end web application framework that allows you to run code in a user’s browser.

Node.js—Node.js is an execution environment for event-driven server-side applications.

Regardless of your operating system, most MEAN stack users recommend downloading and installing components from the respective websites rather than by using a package manager provided by your operating system. Websites for each are listed here; download and install the software in this order, following the provider’s instructions:

  1. Install MongoDB from www.mongodb.com/download-center.

  2. Install Node.js from https://nodejs.org/en/. When you do, you also install the npm package manager, which you will use next.

  3. Use the command npm install express to install Express.js.

  4. Follow the Getting Started guide at https://angular.io to install Angular.

What is really different in a MEAN application than in a LAMP or other traditional application is the flexibility. You can run application code on your server. You can run code in the user’s browser. You can even run some application logic in the database, which is especially nice for some types of analytics.

Note

You can replace Angular (originally from Google) with React (from Facebook), which serves a similar purpose. You can also replace it with other frameworks, such as Ember.js or Backbone.js, and still do all your development in JavaScript. Some love this flexibility, but to others it is overwhelming. In any case way, MEAN development is here and is not likely to disappear anytime soon.

References

https://help.ubuntu.com/lts/serverguide/lamp-overview.htmlLAMP in the Ubuntu Server Guide

www.mongodb.comThe official site of MongoDB

https://nodejs.orgThe official site of Node.js

www.npmjs.comHome of the npm package manager

https://expressjs.comThe official site of Express.js

https://angular.ioThe official site of Angular

https://emberjs.comThe official site of Ember.js

http://backbonejs.orgThe official site of Backbone.js

https://reactjs.orgReact, a JavaScript library for building user interfaces

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.33.235