{"id":997,"date":"2012-08-14T11:18:01","date_gmt":"2012-08-14T03:18:01","guid":{"rendered":"http:\/\/rmohan.com\/?p=997"},"modified":"2012-08-14T11:18:01","modified_gmt":"2012-08-14T03:18:01","slug":"apache-commands-2","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=997","title":{"rendered":"Apache commands"},"content":{"rendered":"<p># apachectl \u00ad-k graceful<br \/>\nIn a server environment, should use the command apachectl instead of \/etc\/init.d\/httpd. apachectl command is used to control the apache httpd daemon.<\/p>\n<p># apachectl -\u00adk restart<br \/>\ndifference between apachectl -k graceful and apachectl -k restart is that in case of the former current requests are not aborted but in the latter case current requests are aborted.<\/p>\n<p># ps \u00ad-ef | grep httpd<br \/>\nThis command lists the httpd processes. -f option lists in full format. -e option lists all system processes. By using this command we can detect the processes that is causing trouble and those processes can be killed using the kill command.<\/p>\n<p># kill \u00adterm &#8216;pid&#8217;<br \/>\nAt a time there cannot be more than 50-60 child apache processes. If that is the case then it could probably be an attack. If we notice an apache attack then at once stop the apache service using the command.<\/p>\n<div># apachectl -\u00adk stop<br \/>\nIf we notice that it is a server attack, ie attacks like denial of service, flooding then at once disconnect the network cable.<\/div>\n<div><\/div>\n<div>\u00a0# locate httpd.pid<\/div>\n<div># cat \/var\/run\/httpd.pid<\/div>\n<div>This command lists the running apache process id. ie the id of the parent apache.<\/div>\n<div><\/div>\n<div># ps -\u00adauxf | grep httpd<\/div>\n<p>This command lists all httpd processes in full format.<\/p>\n<p># vi \/etc\/init.d\/httpd<br \/>\nThis file is a sript used to run apache services.<\/p>\n<p># ps \u00adef \u00ad\u00ad&#8211;forest | grep httpd<br \/>\nThis command lists the httpd processes. ie the parent apache and the childs in full format (-f option). Each child can have their children and so on.<\/p>\n<p># netstat -\u00adtn<br \/>\nPrints the foreign connections to the server and the ports through which they are connected.<\/p>\n<p># netstat | grep 35296<br \/>\nLists the details about this paricular port.<\/p>\n<p># lsof \u00ad-i tcp:80<br \/>\nThis command lists open files (lsof).<\/p>\n<p># lsof -\u00adi tcp:80 | wc \u00adl<br \/>\nlists the number of files that listens to the tcp port 80.<\/p>\n<p># cat \/etc\/httpd\/conf\/httpd.conf | grep User<br \/>\nLists the user\/group who run httpd.<\/p>\n<p># top \u00ad-u apache<br \/>\nLists all processes run by user apache<\/p>\n<p># httpd -\u00adl<br \/>\nList compiled in modules.<\/p>\n<p># httpd \u00ad-M<br \/>\nShow all loaded modules.<\/p>\n<p># httpd \u00ad-L<br \/>\nList available configuration directives.<\/p>\n<p># httpd \u00ad-v<br \/>\nShow apache version.<\/p>\n","protected":false},"excerpt":{"rendered":"<p># apachectl \u00ad-k graceful In a server environment, should use the command apachectl instead of \/etc\/init.d\/httpd. apachectl command is used to control the apache httpd daemon.<\/p>\n<p># apachectl -\u00adk restart difference between apachectl -k graceful and apachectl -k restart is that in case of the former current requests are not aborted but in the latter [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/997"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=997"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/997\/revisions"}],"predecessor-version":[{"id":999,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/997\/revisions\/999"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}