Apache Web Server Github



The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in. The Dependency Check is run from a Docker Container containing an Apache Web Server. The run outputs HTML reports. It is reviewed and methods for use of these reports by production monitoring applications. Run the get-webgoat.sh shell script; Run the run-depcheck.sh shell script; Copy the HTML reports produced to the Apache Web Server root.

In the previous tutorial I showed how to install wordpress on Digital Ocean droplet andconfigure it to use Digital Ocean Managed Database service, we used a very simpleand quickly setup, here we will explore more options to run Wordpress usingthe Apache web server.

Apache is a popular Web Server software, it is used to host many web applicationsaround the world. Apache has a unique feature that enables it to run PHP scriptsin its own process without calling an external server such as PHP-FPM, howeverwe will find out that, this feature is not very good at all when it comes to servingmany simultaneous requests as we will see in the next sections.

Here we assume you already have the previous Wordpress site createdin my last tutorial which can be found here.

In this tutorial we will:

  • Create a droplet and install locustio for load testing our Wordpress site.

  • Explore the available modules for serving client requests in Apache server.

  • Run load tests for Wordpress site using different apache configurationsand specify which one is the best for high performance.

At the end of this tutorial you are expected to configure apache web serverfor hosting Wordpress site and achieve the best performance.

Using the Digital Ocean dashboard create a new droplet with the name wp-locustand 4 GB RAM and 2 vCPUs to use it for running load tests on Wordpress site.

locustio is a load testing tool written in Python, it can beused to load test any system as long as you have the right client setup in Python.

locust comes with built-in HTTP client that can be used for load testing web serversand applications, here we will install locustio and run a simple load test using it.

First execute these commands to install locustio on the new droplet

The first two commands updates the package repositories and installs pip3which is used to install python 3 packages on the system.

The third command installs locustio python package on the system so wecan use it to run the load tests.

locust uses python code to define user behavior and runs multiple users tomake requests to the web server, this makes it easier than other tools which useXML files to define user behavior.

We will create a simple locust file named locustfile.py with this content

In the previous file we have two classes, the first one is called WordPressTaskswhich represents tasks performed by locust users, locust uses tasks(methods decorated with @task) in this class to make HTTP requests to the server,here we have two tasks the first one is a request to Wordpress main page and thesecond one is a request to Wordpress login page.

The other class is WordPressUser and represents users in locust, here we specifytask_set class attribute that defines the class used to create tasks, alsothe host class attribute holds the URL to the server and the wait_time specifieshow many seconds users wait before making another request.

Now to run locust testing we use this command

  • –no-web: runs locust without the web interface.
  • -c 500: Simulate 500 users
  • -r 50: This rate specifies how many users are added per second.
  • -t2m: This means run the test for 2 minutes then exit.
  • –only-summary: This means only show summary of tests when they end.
  • –csv=500.50: This option tells locust to store results in CSV files,with names that start with “500.50”

After you execute the command wait two minutes until it exits and check the resultsas shown in this image.

From the summary in the previous image we can see the following:

  • The total average response time is 9528 ms which is 9.5 seconds.
  • The total number of requests is 2626 requests.
  • The number of requests per second is 21.72 req/s
  • There were 16 failed requests, because of Connection Reset by the server.

From the previous summary we can see that the result is not acceptable at all, 9.5seconds to just load the HTML part of the page (CSS and JavaScript files are notloaded yet) is not okay at all and our server will just go down once we havemany users accessing our site, to improve performance we must understand howapache handles new requests in the next section.

Apache uses Multi-Process Modules (MPMs) to handle new requests, each modulespecifies how a new request is served, some modules uses multiple processesto handle requests (prefork module), some others use multi-threading (workermodule) and others use events (event module) to handle new requests.

To tell which MPM module you are currently using issue this command

You will get the result prefork for the Wordpress droplet.

Apache Web Server Github

Apache prefork MPM

This module preforks a number of apache processes to serve client requests, eachrequest is served in its own process, and when more requests arrive than the numberof processes, apache will create new processes to handle incoming requests.

This module is considered bad for performance in modern web applications, usinga separate process for each request is very bad and requires a lot of server’sresources to serve requests, we saw the bad results in the previous section.

We will explore another MPM called worker in the next section.

Apache worker MPM

This module uses a thread to handle each new request, using threadsto handle requests causes little overhead compared to processes butwith this module we cannot use apache’s built-in PHP module to execute PHPscripts because this module requires that each request is served in a separateprocess as executing PHP scripts is not thread-safe which means that thescript may modify data shared by multiple threads without using any methodto synchronize access. To solve this we must use an external PHP serversuch as PHP-FPM. Siri for mac os x download.

Installing PHP-FPM

You can install php-fpm with this command

This will install the package php-fpm and start a PHP server and createa socket in /run/php/php7.2-fpm.sock which can be used to communicatewith the PHP server from apache on the same host.

Use PHP-FPM in apache

In order to make apache use php-fpm to execute PHP scripts instead ofits own php module, we need to execute these commands

The first one enables the proxy_fcgi and setenvif modules which areneeded for apache to communicate with PHP-FPM and the second one enablesPHP-FPM configuration to use php-fpm with php files.

Untill now apache still uses its own php module and the prefork module, touse the worker module we must first disable prefork and then enable worker,with these commands:

The first command disables the prefork MPM, we also disabled php7.2 becauseit relies on prefork to work and we cannot disable prefork and keep php7.2 enabled.

The second command enables the worker MPM and the last one restarts apache serverto make changes take effect.

Apache event MPM

The event MPM was made stable only in apache version 2.4 and it offers significantperformance boost (as we will see in the next section), this new MPM makes useof new kernel features to handle many requests concurrently and with very littleresource consumption, all of this was made available thanks to the poll and epollsystem calls, which enable user space applications to monitor multiple filedescriptors and get notified when they are available for reading or writing.

The event MPM uses threads to serve requests, however it does not use a singlethread per request, it uses a thread that listens to incoming connections and whena new connection is accepted it adds it to the epoll list and other idle threadwill take the new connection from the list and serve it.

The event MPM also needs to use PHP-FPM server to execute PHP scripts, becauseit serves requests in threads not in separate processes.

To enable the event MPM use these commands:

We first disable the worker MPM and then enable event MPM, notice thatonly a single MPM can be enabled at a time so we first must disable the enabledMPM then enable the new one.

Now after we learned about 3 of the most used apache MPMs we will restart the testsusing these three configurations and check which one is better and gives lowerresponse time and less errors.

To do these tests enable the right MPM in apache and execute this command

Web

We described this command previously, the following two images show the resultsfor worker and event MPMs (results for prefork MPM were shown in the first section).

Results for worker MPM (average response time is 8.3 seconds, 7 errors, 22.72 req/s)

Results for event MPM (average response time is 2.1 seconds, 5 errors, 50.94 req/s)

From the previous tests we can clearly see that the event MPM offers a very bigperformance boost compared to prefork and worker MPMs, worker MPM is slightlybetter than prefork MPM.

We can also see that the number of requests per second was a lot higher with eventMPM which means it can handle more simultaneous users.

In this tutorial we learned how to use the right modules in apache to hostWordpress sites, we also used locustio to load tests Wordpress under differentapache MPM modules.

Our tests show that prefork and worker modules are not suitable at all forhigh performance applications, and the use of event MPM improves the performancea lot when hosting Wordpress sites.

In the next tutorials we will compare apache with nginx server and alsodiscover how to host Wordpress sites on multiple Digital Ocean dropletsand load balance them using Digital Ocean load balancer service.

I hope you find the content useful for any comments or questions you can contact meon my email address mohsen47@hotmail.co.uk

Stay tuned for more articles. :) :)

VersionAuthorDateComment
0.1Gang Chen18/09/2018Deployment process for Ubuntu server. Ubuntu is one major OS that unimelb uses.
0.2Gang Chen24/09/2018The next release of this document will cover Heroku server.
0.3Hugh Edwards7/10/2018Convert to Markdown, editing
0.4Nir Lipovetzky1/5/2020editing, github and server migrated

PurposeLink

This document describes how to build and deploy the Planning Visualisation standalone software.

Document OverviewLink

This document is organised in the following sections:

Web
  1. Requirements: Requirements for deployment
  2. Project Repository: Contains information on how the repository is organised.
  3. Pre-deployment Process: Details how to build the software from the source code and how to build the other project artefacts. Additional information on the various steps of the build process is also provided as well as a list of all required libraries.
  4. Deployment: How to install and run the software, and the system requirements.
  5. Post-deployment: Details how to display the final product.
  6. Heroku-deployment: Details how to deploy the final product on Heroku.

1. RequirementsLink

Build Agent RequirementLink

Your build agent will need to meeting the following minimum requirements. GPU is a must as you will need a valid graphic card and graphic card drive to activate Unity:

ComponentsMinimum Requirement
Operating SystemOS: Windows 7 SP1+, 8, 10, 64-bit versions only; macOS 10.11+. Server versions of Windows & OS X are not tested.
CPUCPU: SSE2 instruction set support.
GPUGPU: Graphics card with DX10 (shader model 4.0) capabilities.
Aditional Platform Development RequirementsiOS: Mac computer running minimum macOS 10.12.6 and Xcode 9.0 or higher. Android: Android SDK and Java Development Kit (JDK); IL2CPP scripting backend requires Android NDK. Universal Windows Platform: Windows 10 (64-bit), Visual Studio 2015 with C++ Tools component or later and Windows 10 SDK

Deployment Server RequirementLink

The deployment server used in developnet is a Linux OS family member - Ubuntu. This section covers the minimum hardware requirements for these deployment servers.

Ubuntu Desktop EditionLink

Processor: 2 GHz dual core processorRAM: 2 GiB RAM (system memory)Storage: 25 GB of hard-drive space (or USB stick, memory card or external drive but see LiveCD for an alternative approach)Display: VGA capable of 1024x768 screen resolution (Optional)Accessories: Internet accessPort Selection:

  • 22/tcp open ssh
  • 80/tcp open http
  • 631/tcp open ipp
  • 3306/tcp open mysql
  • 8000/tcp open http-alt

Ubuntu Server EditionLink

Processor: 300 MHz x86 processorRAM: 256 MiB of system memory (RAM)Storage: 1.5 GB of disk spaceDisplay: Graphics card and monitor capable of 640x480 (Optional)Accessories: Internet accessPort Selection:

  • 22/tcp open ssh
  • 80/tcp open http
  • 631/tcp open ipp
  • 3306/tcp open mysql
  • 8000/tcp open http-alt

2 Get SourcesLink

The source code and related artefacts are hosted in Github, the backend and frontend repositories can be cloned through the following command:

All the code is available in https://github.com/planimation/ Finchtv sequence analysis download for mac.

3 Pre-deployment ProcessLink

Planning Visualisation’s presentation layer is based on WebGL and Unity, the contents of which can be generated from the Unity part of the repository. This section covers how and what to generate:

3.1 Install Unity DependenciesLink

Install the Version 2018.2.1f1 from https://unity3d.com/, when installing, select 'Include WebGL”.

Additionally, download the followings for building Unity files (This requires roughly 50MB storage space).

3.2 Build Unity ProjectLink

The build process is designed to be cross-platform and self-contained. What all this means is that you can run the various build tasks on any machine where a validated Unity is available, without having to worry about resolving other library dependencies.

The Unity project can either be built from the Unity command line, or from the Unity GUI.

Apache Web Server Download

3.2.1 Building from command lineLink

To build from the command line, enter the following command. We illustrate the idea with Ubuntu build agent. However, the idea can apply to any OS.

Move to the /PlanningVisualise directory in the repository that you’ve just checked out from Section 1 and from there type, at the command prompt:

  • You will need to replace the “ProjectPath” with the absolute path of your cloned copy of the repository. E.g. “/home/$USER/planimation-frontend
  • You will need to replace “/home/$USER/Editor/Unity” with the absolute path of Unity executable on your build agent.
  • Compilation progress can be found in “stdout.log”.

For more information on each of the components in the command, please visithttps://docs.unity3d.com/Manual/CommandLineArguments.html

Should you wish to update the User Interface of this application, you need to include all your customised Unity scenes in the buildscript prior to compilation, buildscript can be found:

With having the command executed, a folder called “build” should appear under the /planimation-frontend directory and this will be the final animation contents for the deployment process in Section 4.

3.2.1 Building from Unity GUILink

  • Open Unity
  • Click File -> Build Settings
  • Choose 'WebGL'
  • Make sure all the selected scenes are those under the 'Visualisation' folder
  • Click 'Player Settings'
  • Click 'Publishing Settings'
  • Tick 'WebAssembly' checkbox
  • Click 'Build'
  • Create 'buildweb' folder

3.3 Install Python3 Dependencies for the BackendLink

Should you wish to change the server side of the repository, you will need to install the following libraries in order to compile the python files with Python3 Interpreter, Python3 Interpreter can be downloaded with :

Addition libraries include:

4 Ubuntu Deployment ProcessLink

Free download indesign cs6 for mac. Installing and running Planning Visualisation is very easy: drop the distribution directory somewhere on your filesystem and run your servers! This section details all this more precisely. An obvious set of pre-requisites is Apache server and Django Server.

4.1 Apache Web Server InstallationLink

For Ubuntu server, run the following commands to install Apache server:

After having successfully installed the Apache server, you can run the server with the following command:

4.2 Apache Web Server DeploymentLink

With the command provided in section 2, you should be able to get a folder called “buildweb” under “./planimation-frontend/”. The remaining is easy: drop the distribution directory to the designated Apache source folder and restart your apache server:

  • Move all the files and subdirectories under “build” to “/var/www/html/“
  • Restart the apache server with “sudo service apache2 restart”

4.3 Django Server InstallationLink

For Ubuntu server, run the following commands to install Django server:

4.4 Django Server DeploymentLink

Once the installation is done and the Django server is ready, move to the /planimation-backend/server directory and from there type, at the command prompt:

After all, the server should be reachable from external network and your project should be ready.

5 Post-deploymentLink

Planning Visualisation can then be accessed within any web browser that is compatible with WebGL by typing the IP address of you deployment server.

6 Heroku DeploymentLink

6.1 Pre-deployment ProcessLink

Please make sure your setup has met the following conditions:

  • a free Heroku account.
  • Python version 3.6 installed locally - see the installation guides for OS X, Windows, and Linux.
  • Pipenv installed locally. Accomplish this by running pip install pipenv.
  • Postgres installed locally, if running the app locally.

6.2 Deployment ProcessLink

Heroku Command Line Interface (CLI) - Once installed, you can use the HEROKU command from your command shell. To log in with your Heroku account:

Enter your Heroku credentials.

To clone your project with:

Next, create an app on Heroku, which prepares Heroku to receive your source code:

Apache Web Server Github Tutorial

When you create an app, a git remote (called heroku) is also created and associated with your local git repository. Heroku generates a random name (in this case lit-bastion-5032) for your app, or you can pass a parameter to specify your own app name. Now deploy your code:

Use a Procfile to explicitly declare what command should be executed to start your app.

Apache Web Server Tutorial

The Procfile in the example app you deployed looks like this:

This declares a single process type, web, and the command needed to run it. The name web is important here. It declares that this process type will be attached to the HTTP routing stack of Heroku, and receive web traffic when deployed. Procfiles can contain additional process types. For example, you might declare one for a background worker process that processes items off of a queue.

6.3 Unity with Heroku DeploymentLink

When deploying the Django server with Heroku, you will also need to make sure to redirect the traffic for your local server to Heroku within Unity, this can be done by simply enabling and changing the settings in ScenesCoordinator.cs:

As shown above in the picture, the current setting is pointing to local machine. Enabling the line below will redirect the data stream to your Heroku server. You should replace “https://immense-bastion-42146.herokuapp.com/upload/pddl” with your Heroku application.

Last update: August 11, 2020