Apache
Version vom 18. März 2022, 11:49 Uhr von Geist (Diskussion | Beiträge)
Inhaltsverzeichnis
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>