APACHE2๐
Count visitors:๐
Per day๐
awk '{print $4}' access.log | cut -d: -f1 | uniq -c
Per hour๐
grep "08/Nov" access.log | cut -d[ -f2|cut -d] -f1 | awk -F: '{print $2":00"}'|sort -n | uniq -c
Per minute๐
grep "08/Nov/2022:14" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort -nk1 -nk2 | uniq -c | awk '{ if ($1 > 10) print $0}'
If Apache fails after adding certificate to VHost, add this to the VHost:๐
SSLEngine on
OR
a2enmod ssl
Apachectl commands:๐
apachectl -S # veit ikki
apachectl -M # Listi av modulum
Permanent and temporary redirect๐
The codes to keep in mind are 301 and 302:
301
is the permanent redirect302
is the temporary redirect
When creating redirects, I would recommend to create temporary redirects first, just in case you somehow made a mistake. Just in case.
When you've tested the temporary redirect, and it works, you can create a permanent redirect thereafter.
Permanent:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.eksempel\.dk [NC]
RewriteRule ^(.*)$ http://eksempel.dk/$1 [L,R=301] # Permanent redirect
Temporary:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.eksempel\.dk [NC]
RewriteRule ^(.*)$ http://eksempel.dk/$1 [L,R=302] # Temporary redirect
The above is great if you want to redirect multiple versions of a domain to a single domain and you want to explicitly define each site.
If you want to redirect all aliases and domains to a specific domain/alias, you cando like so:
Permanent
Redirect permanent www.eksempel.dk http://eksempel.dk/
OR
Redirect 301 www.eksempel.dk http://eksempel.dk/
Temporary
Redirect www.eksempel.dk http://eksempel.dk/
NOTE: Keep in mind the last forward slash must exist if your redirections should work unless your redirect is about a certain path in the current domain/s like so:
Redirect /oldpath http://eksempel.dk/newpath
To get apache to use a private key with a passphrase๐
- Create a file with something like this in it; call it something along the lines of "passphrase" or "example.com-passphrase":
#!/bin/sh
echo "passphrase"
- make it executable:
chmod +x passphrase
- Put this in
apache.conf
/httpd.conf
/ vhost:
SSLPassPhraseDialog exec:/rรกs/til/passphrase
- Restart apache
systemctl restart apache2