Apache HTTP with Tomcat | Apache HTTP SSL#

Install Apache HTTP Server#

For Debian use package apache2, see https://help.ubuntu.com/lts/serverguide/httpd.html

sudo apt-get install apache2 

Install Log#

	Holen:1 http://security.debian.org/debian-security stretch/updates/main amd64 apache2-bin amd64 2.4.25-3+deb9u4 [1.183 kB]
	Holen:2 http://ftp.de.debian.org/debian stretch/main amd64 libapr1 amd64 1.5.2-5 [96,6 kB]
	Holen:3 http://security.debian.org/debian-security stretch/updates/main amd64 apache2-utils amd64 2.4.25-3+deb9u4 [217 kB]
	Holen:4 http://ftp.de.debian.org/debian stretch/main amd64 libaprutil1 amd64 1.5.4-3 [85,8 kB]
	Holen:5 http://ftp.de.debian.org/debian stretch/main amd64 libaprutil1-dbd-sqlite3 amd64 1.5.4-3 [19,3 kB]
	Holen:6 http://ftp.de.debian.org/debian stretch/main amd64 libaprutil1-ldap amd64 1.5.4-3 [17,4 kB]
	Holen:7 http://security.debian.org/debian-security stretch/updates/main amd64 apache2-data all 2.4.25-3+deb9u4 [162 kB]
	Holen:8 http://security.debian.org/debian-security stretch/updates/main amd64 apache2 amd64 2.4.25-3+deb9u4 [236 kB]
	Holen:9 http://ftp.de.debian.org/debian stretch/main amd64 liblua5.2-0 amd64 5.2.4-1.1+b2 [110 kB]
	Holen:10 http://ftp.de.debian.org/debian stretch/main amd64 ssl-cert all 1.0.39 [20,8 kB]
	Vormals nicht ausgewähltes Paket libapr1:amd64 wird gewählt.
	libapr1:amd64 (1.5.2-5) wird eingerichtet ...
	apache2-data (2.4.25-3+deb9u4) wird eingerichtet ...
	ssl-cert (1.0.39) wird eingerichtet ...
	Trigger für libc-bin (2.24-11+deb9u3) werden verarbeitet ...
	libaprutil1:amd64 (1.5.4-3) wird eingerichtet ...
	Trigger für systemd (232-25+deb9u2) werden verarbeitet ...
	Trigger für man-db (2.7.6.1-2) werden verarbeitet ...
	liblua5.2-0:amd64 (5.2.4-1.1+b2) wird eingerichtet ...
	libaprutil1-ldap:amd64 (1.5.4-3) wird eingerichtet ...
	libaprutil1-dbd-sqlite3:amd64 (1.5.4-3) wird eingerichtet ...
	apache2-utils (2.4.25-3+deb9u4) wird eingerichtet ...
	apache2-bin (2.4.25-3+deb9u4) wird eingerichtet ...
	apache2 (2.4.25-3+deb9u4) wird eingerichtet ...
	Enabling module mpm_event.
	Enabling module authz_core.
	Enabling module authz_host.
	Enabling module authn_core.
	Enabling module auth_basic.
	Enabling module access_compat.
	Enabling module authn_file.
	Enabling module authz_user.
	Enabling module alias.
	Enabling module dir.
	Enabling module autoindex.
	Enabling module env.
	Enabling module mime.
	Enabling module negotiation.
	Enabling module setenvif.
	Enabling module filter.
	Enabling module deflate.
	Enabling module status.
	Enabling module reqtimeout.
	Enabling conf charset.
	Enabling conf localized-error-pages.
	Enabling conf other-vhosts-access-log.
	Enabling conf security.
	Enabling conf serve-cgi-bin.
	Enabling site 000-default.
	Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
	Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
	Job for apache2.service failed because the control process exited with error code.
	See "systemctl status apache2.service" and "journalctl -xe" for details.

Default-Page#

Default page at /var/www/html/index.html

If you are a normal user of this web site and don't know what this page is about, this probably means that the site is currently unavailable due to maintenance. If the problem persists, please contact the site's administrator.

Configuration Overview
Debian's Apache2 default configuration is different from the upstream default configuration, and split into several files optimized for interaction with Debian tools. The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full documentation. Documentation for the web server itself can be found by accessing the manual if the apache2-doc package was installed on this server.

The configuration layout for an Apache2 web server installation on Debian systems is as follows:

/etc/apache2/
|-- apache2.conf
|       `--  ports.conf
|-- mods-enabled
|       |-- *.load
|       `-- *.conf
|-- conf-enabled
|       `-- *.conf
|-- sites-enabled
|       `-- *.conf
          
apache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.
ports.conf is always included from the main configuration file. It is used to determine the listening ports for incoming connections, and this file can be customized anytime.
Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations, respectively.
They are activated by symlinking available configuration files from their respective *-available/ counterparts. These should be managed by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and a2enconf, a2disconf . See their respective man pages for detailed information.
The binary is called apache2. Due to the use of environment variables, in the default configuration, apache2 needs to be started/stopped with /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not work with the default configuration.
Document Roots
By default, Debian does not allow access through the web browser to any file apart of those located in /var/www, public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as in /srv) you may need to whitelist your document root directory in /etc/apache2/apache2.conf.

The default Debian document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.

Reporting Problems
Please use the reportbug tool to report bugs in the Apache2 package with Debian. However, check existing bug reports before reporting a new bug.

Please report bugs specific to modules (such as PHP and others) to respective packages, not to the web server itself.

Documentation#

see /usr/share/doc/apache2/README.Debian.gz]
use "manual" on "apache2-doc" package

Start/Stop#

Note: do not use /usr/sbin/apache2 directly
/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 restart
	 
/usr/sbin/apachectl start
/usr/sbin/apachectl stop	
Note: apachectl calls >systemctl start apache2<

Folders#

/usr/share/ - apache2 program
/var/www/html/ - default public content, all files & subfolders accessible by default
/var/www/html/index.html - Access Websites	
/etc/apache2/ - configuration
/var/log/apache2/ - logs

Configuration#

Main conf file is /etc/apache2/apache2.conf
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Folder /etc/apache2/conf-available/
charset.conf
localized-error-pages.conf
other-vhosts-access-log.conf
security.conf
serve-cgi-bin.conf		

Activate/Deactivate conf with

a2enmod, a2dismod, a2ensite, a2dissite, a2enconf, a2disconf	
More config
/etc/apache2/sites-enabled
/etc/apache2/mods-enabled
ports.conf
envvars

Site configuration#

/etc/apache2/sites-enabled/000-default.conf -> ../sites-available/000-default.conf
/etc/apache2/sites-enabled/000-default-le-ssl.conf -> /etc/apache2/sites-available/000-default-le-ssl.conf
Apache VirtualHost Examples | How to Multiple Sites @liquidweb.com

Redirects #

Use mod_rewrite (see docu) only as last ressort, e.g. use simpler options if you have control over config files.
mod_alias provides the Redirect and RedirectMatch directives at <VirtualHost>.
Note: the server name is derived from the IP address. So if have multiple sites based on the same IP the wrong VirtualHost may be taken.
See docu:
When a request is received, the server first maps it to the best matching <VirtualHost> based on the local IP address and port combination only. Non-wildcards have a higher precedence. If no match based on IP and port occurs at all, the "main" server configuration is used.

If multiple virtual hosts contain the best matching IP address and port, the server selects from these virtual hosts the best match based on the requested hostname. If no matching name-based virtual host is found, then the first listed virtual host that matched the IP address will be used. As a consequence, the first listed virtual host for a given IP address and port combination is the default virtual host for that IP and port combination.

Deploying Angular#

Angular needs to map to the index.html for its own routing always. You need to add
<Directory "/var/www/html/angularIndexFileFolder">
  AllowOverride All
</Directory>

mod_rewrite (nevertheless)#

Apache Docu | Activate
sudo a2enmod rewrite
sudo a2enmod actions 
/usr/sbin/apachectl start
You can configure via .htaccess file, but you should not, see docu:
You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.
So use <Directory> in main configuration at /etc/apache2/apache2.conf or
in the site configuration under <VirtualHost ...>.
<VirtualHost *>
  ServerName www.example.com
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^www.example.com
  RewriteRule ^/(.*)$ http://example.com/$1 [L,R=301]
</VirtualHost>

Mods#

Enable SSL

	
a2enmod ssl
List enabled mods
apache2ctl -M | sort

Logs#

Stored at /var/log/apache2/* You can use
journalctl -xe

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-) was last changed on 17-Mai-2020 14:51 by Administrator