Apache2 ist ein quelloffener Webserver. von der Apache Foundation. Auf einen Umstieg auf NginX wird geraten. Siehe auch htaccess, PHP und MySQL.
// apache apt-get install apache2 // php und apache mod for php apt-get install php7.0 libapache2-mod-php // mysql server apt-get install mysql-server // secure install mysql_secure_installation
change file mime type: https://stackoverflow.com/questions/3100956/enable-php-to-read-css-and-js-files-while-keeping-their-original-content-type
mod log files: https://httpd.apache.org/docs/current/mod/mod_log_config.html
Options +FollowSymLinks RewriteEngine On RewriteRule ^user/([0-9]*)/([a-z]*)$ ./index.php?user=$1&action=$2
https://stackoverflow.com/questions/10236717/how-to-prevent-a-file-from-direct-url-access
RewriteEngine on
Options -Indexes // disable directory listing
RewriteCond %{HTTP_REFERER} !^http://(www\.)? [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|png)$ - [F]
In der vHost Konfig oder der globalen Apache Konfig (für localhost) Todo
Siehe Certbot
In den Ordnern /etc/apache2/sites-available/ und /etc/apache2/sites-enabled liegen die Konfigurationen.
Mit a2ensite kann man eine bestimmte Seite aktivieren bzw. mit a2dissite deaktivieren. Man kann auch einfach einen Softlink setzen/löschen.
<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot /var/www/html
ServerAlias localhost
# Redirect permanent / https://localhost/
<Directory /var/www/html/>
Options +FollowSymlinks
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/default-error_log
CustomLog /var/log/apache2/default-access_log common
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@localhost
DocumentRoot /var/www/html
ServerAlias localhost
<Directory /var/www/html/>
Options +FollowSymlinks
AllowOverride All
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/localhost.crt
SSLCertificateKeyFile /etc/ssl/private/localhost.key
SSLCertificateChainFile /etc/ssl/ca_bundle.crt
ErrorLog /var/log/apache2/default-ssl-error_log
CustomLog /var/log/apache2/default-ssl-access_log common
</VirtualHost>
a2enmod proxy a2enmod proxy_http systemctl restart apache2
Auf Windows in httpd.conf oder einer .conf-Datei im conf/extra-Verzeichnis folgendes eintragen/auskommentieren
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so
und neu starten!
<VirtualHost *:*> ServerName localhost ProxyPreserveHost On ProxyPass / http://10.0.0.2:8080/ ProxyPassReverse / http://10.0.0.2:8080/ </VirtualHost>
<Proxy balancer://mycluster> # Define back-end servers: # Server 1 BalancerMember http://10.0.0.2:8080/ # Server 2 BalancerMember http://10.0.0.2:8081/ </Proxy> <VirtualHost *:*> ProxyPass / balancer://mycluster </VirtualHost>
In apache/conf/httpd.conf add at the end
AddHandler cgi-script .jail ScriptInterpreterSource Registry-Strict
and in the files add the path to the interpreter and always output content-type at first!
#!C:/jail.exe
print("Content-Type: text/html\n\n");