Friday, November 9, 2018

Install Apache and PHP on Mac OSX Sierra 10.13.6

Apache comes already installed, below steps to make sure it is running and also have PHP enabled:

1. Get in as root
sudo su

2. 
apachectl start

3. Navigate to http://localhost and confirm it works:
 

4. Let's do some tweaks for optimized usage of Apache and PHP:
Configure User Level Root:

Add  a "user.conf" file under:
/etc/apache2/users/

where user is your OS X user.
cd /etc/apache2/users
touch user.conf 

5. Add the below content to the newly created file - replace user with your real username:

<Directory "/Users/user/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
 
6. Permissions on the file should be:
 
 

7. Edit httpd.conf file

vi /etc/apache2/httpd.conf
 
8. Make sure following modules are loaded - lines are not commented:
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so 
LoadModule php7_module libexec/apache2/libphp7.so
 
Uncomment also following line:
Include /private/etc/apache2/extra/httpd-userdir.conf 

9. Uncomment following line:
Include /private/etc/apache2/users/*.conf
 
from the following file: 
/etc/apache2/extra/httpd-userdir.conf
 
10. Being still root, restart Apache:
apachectl restart
 
11. User document root is displayed at:
http://localhost/~user/ 

12. Test PHP by adding a file phptest.php under /Users/user/Sites/ folder with the following text:

 <?php phpinfo(); ?>
 
13. Navigate to this PHP page - Now Apache and PHP works well together
 

Friday, October 19, 2018

Empty S3 bucket, Synch from another and watch live progress

Very simple :) Below the commands:

1. Empty destination bucket:
aws s3 rm s3://destinationbucket --recursive


2. Copy from source to destination bucket
aws s3 sync s3://sourcebucket s3://destinationbucket--region eu-central-1


3. Best part of all, watch live progress:
while sleep 10; do aws s3 ls s3://destinationbucket --recursive --human-readable --summarize | tail -n 3; done


Total Objects: 1382938
   Total Size: 1.8 TiB

Total Objects: 1217651
   Total Size: 1.6 TiB

How to generate a CSR certificate request

1. Generate private key:
openssl genrsa -out private.key 2048

2. Have cnf file in place - file.cnf:
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
[req_distinguished_name]
countryName = XX
countryName_default = XX
stateOrProvinceName = xx xx
stateOrProvinceName_default = xxxxx
localityName = xxxxx
localityName_default = xxxxx
organizationName = XXXX
organizationName_default = XXXX
organizationalUnitName = XX
organizationalUnitName_default = XX
commonName = domain.com
commonName_default = domain.com
commonName_max = 64
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = domain1.com
DNS.2 = domain2.com

...

3. Generate the CSR:
openssl req -new -key private.key -out certrequest.csr -config file.cnf

Saturday, September 8, 2018

Lock Screen MAC OS X Sierra

This is great! Finally a key combination to lock screen of Mac OS X - Sierra:

Command + Control + Q

Wednesday, July 4, 2018

Apache HTTPD Log Time to serve request in seconds

You just need to add %T

An example of Log Format below:

LogFormat "%h %l %u %t \"%r\" %>s %b %T \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Forwarded-For}i\" \"%{SN-Akamai-IP}i\" %{Host}i \"%{JSESSIONID}C\" \"%{AWSELB}C\"" combined

Monday, April 2, 2018

Apache HTTPD: logging response header

You just need to add following string to the LogFormat directive from inder httpd.conf:

\"%{HEADER_NAME}o\"