Apache: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Geist (Diskussion | Beiträge) |
Geist (Diskussion | Beiträge) |
||
| Zeile 63: | Zeile 63: | ||
''' </Files>''' | ''' </Files>''' | ||
''' </IfModule>''' | ''' </IfModule>''' | ||
| + | |||
| + | ==== ''' ALLOW/STRICT/REQUIRE IP/LOCAL ''' ==== | ||
| + | ''' <VirtualHost *:80> ''' | ||
| + | ''' <Location />''' | ||
| + | ''' Require ip X.X.X.X''' | ||
| + | ''' Require local''' | ||
| + | ''' </Location>''' | ||
| + | ''' </VirtualHost> ''' | ||
| + | |||
| + | ==== ''' ALLOW/STRICT/REQUIRE CLIENT-USER-AGENT ''' ==== | ||
Aktuelle Version vom 18. März 2022, 11:09 Uhr
Inhaltsverzeichnis
- 1 Install apache2 Debian
- 2 List Apache Modules
- 3 Install PHP
- 4 Enable/disable apache2 php module
- 5 Show php version
- 6 Start|stop|restart apache2
- 7 SSL APACHE
- 8 REDIRECT HTTP
- 9 DISABLE HTTP
- 10 DISABLE/PREVENT from showing/download *.php files if module not loaded
- 11 ALLOW/STRICT/REQUIRE IP/LOCAL
- 12 ALLOW/STRICT/REQUIRE CLIENT-USER-AGENT
Install apache2 Debian
$ apt install apache2
List Apache Modules
$ apache2ctl -M $ apache2ctl -t -D DUMP_MODULES
Install PHP
$ apt install php libapache2-mod-php php-cli
Enable/disable apache2 php module
$ /sbin/a2enmod phpX.X $ /sbin/a2dismod phpX.X
Show php version
$ php -v
Start|stop|restart apache2
$ systemctl start apache2 $ systemctl stop apache2 $ systemctl restart apache2
SSL APACHE
$ a2enmod ssl
$ openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out apache-certificate.crt -keyout apache.key
/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/certificate/apache-certificate.crt
SSLCertificateKeyFile /etc/apache2/certificate/apache.key
</VirtualHost>
REDIRECT HTTP
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
</virtualhost>
DISABLE HTTP
UNCOMMENT IN 000-default.conf
# <VirtualHost *:80>
# ServerAdmin webmaster@localhost
# DocumentRoot /var/www/html
# ErrorLog ${APACHE_LOG_DIR}/error.log
# CustomLog ${APACHE_LOG_DIR}/access.log combined
# </VirtualHost>
UNCOMMENT IN ports.conf # Listen80
DISABLE/PREVENT from showing/download *.php files if module not loaded
<IfModule !"php[VERSION]_module">
<Files "*.php">
order allow,deny
Require all denied
</Files>
</IfModule>
ALLOW/STRICT/REQUIRE IP/LOCAL
<VirtualHost *:80>
<Location />
Require ip X.X.X.X
Require local
</Location>
</VirtualHost>