Apache: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Geist (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „ '''$ apt install apache2''' ''List Apache Modules'' '''$ apache2ctl -M''' '''$ apache2ctl -t -D DUMP_MODULES''' '''$ a2enmod phpX.X''' '''$ a2dismod p…“) |
Geist (Diskussion | Beiträge) |
||
| Zeile 6: | Zeile 6: | ||
'''$ apache2ctl -t -D DUMP_MODULES''' | '''$ apache2ctl -t -D DUMP_MODULES''' | ||
| + | ''Install PHP'' | ||
| + | '''$ apt install php libapache2-mod-php php-cli''' | ||
'''$ a2enmod phpX.X''' | '''$ a2enmod phpX.X''' | ||
'''$ a2dismod phpX.X''' | '''$ a2dismod phpX.X''' | ||
| + | '''$ php -v''' | ||
'''$ systemctl restart 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 and ports.conf''' | ||
| + | '''# <VirtualHost *:80> ''' | ||
| + | '''# ServerAdmin webmaster@localhost ''' | ||
| + | '''# DocumentRoot /var/www/html ''' | ||
| + | '''# ErrorLog ${APACHE_LOG_DIR}/error.log ''' | ||
| + | '''# CustomLog ${APACHE_LOG_DIR}/access.log combined ''' | ||
| + | '''# </VirtualHost> ''' | ||
| + | |||
| + | '''# Listen80 ''' | ||
Version vom 15. März 2022, 17:21 Uhr
$ apt install apache2
List Apache Modules
$ apache2ctl -M $ apache2ctl -t -D DUMP_MODULES
Install PHP $ apt install php libapache2-mod-php php-cli $ a2enmod phpX.X $ a2dismod phpX.X $ php -v
$ 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 and ports.conf
# <VirtualHost *:80>
# ServerAdmin webmaster@localhost
# DocumentRoot /var/www/html
# ErrorLog ${APACHE_LOG_DIR}/error.log
# CustomLog ${APACHE_LOG_DIR}/access.log combined
# </VirtualHost>
# Listen80