Apache: Unterschied zwischen den Versionen

Aus robopagex.com
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „ '''$ apt install apache2''' ''List Apache Modules'' '''$ apache2ctl -M''' '''$ apache2ctl -t -D DUMP_MODULES''' '''$ a2enmod phpX.X''' '''$ a2dismod p…“)
 
 
(7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
==== ''' Install apache2 Debian ''' ====
 
  '''$ apt install apache2'''
 
  '''$ apt install apache2'''
  
''List Apache Modules''
+
==== ''' List Apache Modules ''' ====
 
 
 
  '''$ apache2ctl -M'''
 
  '''$ apache2ctl -M'''
 
  '''$ apache2ctl -t -D DUMP_MODULES'''
 
  '''$ apache2ctl -t -D DUMP_MODULES'''
  
  '''$ a2enmod phpX.X'''
+
==== ''' Install PHP ''' ====
  '''$ a2dismod phpX.X'''
+
  '''$ 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 '''
 
  '''$ 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> '''
 +
 +
==== ''' ALLOW/STRICT/REQUIRE CLIENT-USER-AGENT ''' ====

Aktuelle Version vom 18. März 2022, 12:09 Uhr

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>  

ALLOW/STRICT/REQUIRE CLIENT-USER-AGENT