Apache HTTP Server

Installation

sudo apt install apache2

Commands Run the service

Command

Description

/etc/init.d/apache2 start sudo service apache2 start

Run the service

/etc/init.d/apache2 status sudo service apache2 status

Service status

/etc/init.d/apache2 restart sudo service apache2 restart

Restart the service

1.1.2. Configuration

  • Create the folder for the web root /var/www/yourdomain.xxx

  • Create the file /etc/apache2/sites-available/yourdomain.xxx.conf:

<virtualhost *:80="">  
ServerAdmin webmaster@localhost  
ServerName yourdomain.xxx  
ServerAlias www.yourdomain.com  
DocumentRoot /var/www/yourdomain.com  
ErrorLog ${APACHE_LOG_DIR}/error.log  
CustomLog ${APACHE_LOG_DIR}/access.log combined  
</virtualhost>

HTTPS in Apache

Generation of Certificate from Let’s Encrypt

  • Install certbot

  • Run certbot

or

Configuration of Apache server

  • Enable Mod_ssl and Mod_rewrite Apache module .

  • Append the following lines to /etc/apache2/apache2.conf:

  • Set the following content for /etc/apache2/sites-enabled/000-default.conf or /etc/apache2/sites-enabled/DOMAIN.XXX.conf:

Note that if certbot –apache was used to create the certificates, some of the following configuration parameters are automatically set.

Redirect HTTP to HTTPS (optional)

  • Set the following content for /etc/apache2/sites-enabled/000-default.conf or /etc/apache2/sites-enabled/DOMAIN.XXX.conf:

Apache Benchmark

Installation

Test Apache Web Server

The specified arguments are the following ones:

-n NUMBER

Number of requests to perform for benchmarking session. (default: a single request which leads to non-representative benchmarking results)

-c CONCURRENCY

Number of multiple requests to perform at a time. (default: 1 request at a time)

-g output.data

Save results in output.data file, to perform further analysis.

-k

Use the “HTTP KeepAlive Feature”.

TARGET

URL of the target Apache Server.

Last updated