Saturday, March 8, 2014

Httpd or Apache on MAC os

Let say i want to run my php or html or txt page on my local machine
Choose a path, let say /etc/test  Now you need to set this path in httpd.conf

$ vim /etc/apache2/httpd.conf
Find "DocumentRoot" , it might be  #DocumentRoot "/Library/WebServer/Documents"
uncomment it and make a change like
DocumentRoot "/etc/test"

now save the file and restart the httpd service. run
$ apachectl restart

Create a html file inside /etc/test directory
$echo "It works" > /etc/test/index.html

$ cd /etc/test python -m SimpleHTTPServer 8000

 and open your browser and type localhost



To browse or file manager or Index all the files and folders in http directory 

enable 'Indexes'
like below in httpd.conf


    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Order deny,allow
    Allow from all


and do apache restart

Index of /img

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory -
[IMG]logo.png 14-Feb-2015 00:17 9.5K
[IMG]logo_big.png 14-Feb-2015 00:17 69K
[IMG]logo_med.png 14-Feb-2015 00:17 22K



You'll get below error when there is no indexes enabled. 

Forbidden

You don't have permission to access /img/ on this server.

Friday, March 7, 2014

Grep command in linux

Grep search with multiple strings

search two words in a single line  
grep -in "word1.*word2" /var/log/messages

-i to ignore case

search multiple words in a log file front and back
grep -A 2 -B 2 "word1 \| word2 \| word 3"

-A, bring 2 lines above
-B, bring 2 lines below
Eg:
tailf /var/log/messages | grep -A 5 -B 5 "Service Unav\|DENIED\|Temporarily\|conges\|Too many\|Time-out"

you can use tail command to monitor the logs. tailf and tail -f both are same

CSS tricks

Mixed paint in background: background: linear-gradient(to right, #b6e358, #38b143) Grid view: display: grid; grid-template-columns: a...