Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Thursday, 5 December 2013

could not bind to address no listening sockets available, shutting downUnable to open logs

Yesterday i tried to restart my apache service ( httpd) in my server but i got following error

[root@server ~]# service httpd restart
Stopping httpd:                                            [  FAILED  ]
httpd not running,
trying to start(98)Address already in use: make_sock: could not bind to address x.x.x.x:80 no
listening sockets available, shutting downUnable to open logs
                                                           [  FAILED  ]
[root@server ~]#


After i checked my server http established connection using following command

[root@st-web ~]# netstat -n | grep :80 |wc -l
1800

[root@server ~]# pgrep httpd | wc -l
1800

Then i killed all the http established connection and restart the httpd service

[root@server ~]# killall httpd

[root@server ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                             [  OK  ]



My issue resolved...

Monday, 18 November 2013

tail: cannot watch `/var/log/httpd/access_log': No space left on device

Yesterday  suddenly I checked my apache log using following command 

[root@localhost ~]# tailf /var/log/httpd/access_log

but above command was showing error. It is like below

tail: cannot watch `/var/log/httpd/access_log': No space left on device

 After i searched google and found solution.


Solution: 


             I need to increase inotify value. I checked my default inotify value in below path
" /proc/sys/fs/inotify/max_user_watches " after that i changed that value 8192 to 16384.
This above value depends upon your needs.

         [root@localhost ~]# cat /proc/sys/fs/inotify/max_user_watches 
         8192

         [root@localhost ~]# echo 16384 > /proc/sys/fs/inotify/max_user_watches
 

Issue resolved....

Monday, 21 October 2013

Apache (internal dummy connection)

Today i checked my apache log file in my server and  found lot of  "internal dummy connection". That is like below

          [root@server ~]# cat /var/log/httpd/access_log


 - - [21/Oct/2013:23:21:14 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:22:21 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:22:49 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:23:51 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:24:53 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:25:10 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:32:32 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:32:34 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:34:05 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:34:06 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"
 - - [21/Oct/2013:23:34:32 +0530] "OPTIONS * HTTP/1.0" 200 - "-" "Apache (internal dummy connection)"


I want to ignore above log from access.log file . So i searched and found solution for "internal dummy connection"

Solution :


    I added below lines in "httpd.conf" file

             [root@server ~]# vim /etc/httpd/conf/httpd.conf

                          SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
                          SetEnvIf Remote_Addr "::1" loopback
                          SetEnvIf User-Agent ".*internal dummy connection.*" loopback
                          CustomLog logs/access_log combined env=!loopback

              :wq

     After i restarted  the httpd service

            [root@server ~]# /etc/init.d/httpd restart

My issue resolved.....


Sunday, 24 March 2013

Name Based Virtual Domain in Apache on Centos

If you want to run multiple Website in Single IP Address. This is achieved using DNS Server. In DNS Server we will point manivel.com and manivel-test.com to same IP Address.Then you can configure Name Based Virtual Domain in Apache Web Server.

How to Configure Name Based Virtual Domain

First you need to install HTTPD  then open apache configuration file you need to Add ,command and uncommand some line


[root@iitb-st ~]# vim /etc/httpd/conf/httpd.conf

          #Listen 12.34.56.78:80
           Listen  80

         #ServerAdmin root@localhost
    
         DocumentRoot "/var/www/html"

         # Use name-based virtual hosting.
         #

          NameVirtualHost 10.107.91.51:80

        ##### Virtual domain    #################
  
     <VirtualHost 10.107.91.51:80>
          ServerAdmin  manivel@manivel.com
          DocumentRoot  /var/www/html/site1
          ServerName  manivel.com
          ServerAlias   www.manivel.com
          ErrorLog logs/manivel.com-error_log
          CustomLog logs/manivel.com-access_log common
     </VirtualHost>


     <VirtualHost 10.107.91.51:80>
          ServerAdmin  manivel@manivel.com
          DocumentRoot  /var/www/html/site2
          ServerName  manivel-test.com
          ServerAlias   www.manivel-test.com
          ErrorLog logs/manivel-test.com-error_log
          CustomLog logs/manivel-test.com-access_log common
    </VirtualHost> 

Now Restart the service 

          [root@iitb-st ~]#  /etc/init.d/httpd   restart

If you want to Verrify Virtual Configuration syntax using "httpd  -S"

          [root@iitb-st ~]# httpd -S

If you want to verrify Apache Configuration file syntax using  "httpd  -t"

           [root@iitb-st ~]# httpd -t

   To create additional virtual host you can just repeat the above process.

I hope this helps...

Thursday, 24 January 2013

How to Password Protect a Directory on Your Website

If you want to password protect a directory in Apache then we need to modify below file

    [root@localhost ~]#  vim   /etc/httpd/conf/httpd.conf



Now restart the Apache service 

        [root@localhost ~]# service httpd restart

        Stopping httpd:                                            [  OK  ]
        Starting httpd: httpd:                                    [  OK  ]
        [root@localhost ~]# 

Now we need to create ".htaccess" file under the folder ( /var/www/html/test ).

        [root@localhost ~]# vim  /var/www/html/test/.htaccess

        AuthName  "Caution! Authorized users only"
        Authtype  basic
        AuthUserFile  /etc/httpd/conf/passwd-test
        require  valid-user
            
                 "passwd-test"  is a file which will store the Passwords.

Now we will create passwd-test file using below command

         [root@localhost ~]#  htpasswd  -c  /etc/httpd/conf/passwd-test  manivel

New password: Re-type new password: Adding password for user manivel
 [root@localhost ~]#
 
-c  --> create new file
Manivel  --> username  ( based on system user)

passwd-test --> user name and password store file

If you want multiple user to access "test" directory you can create password using htpasswd command

         [root@localhost ~]#  htpasswd   /etc/httpd/conf/passwd-test  another-username
 
You can check user list 
         
         [root@localhost ~]#cat  /etc/httpd/conf/passwd-test
test:$apr1$yaW9ZSps$I9bCkCYgKhwkj1Lk0cD5s1
manivel:mX7oxMcGIoZdo
[root@localhost ~]#

Now we will check http://localhost/test  in browser. It will ask password prompt.

Saturday, 19 January 2013

How to configure the Apache mod_rewrite module on Centos



"mod_rewrite" is an Apache module used to manipulate URL's and is compiled into the base Apache HTTP Server in CentOS. more details http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Open the Apache configuration file following location and modify

        [root@sysadmin]#  vim   /etc/httpd/conf/httpd.conf

Change "AllowOverride None "to "AllowOverride All"




save and close.

Now restart the service 

           [root@sysadmin]#  /etc/init.d/httpd   restart


That solve...

Tuesday, 12 June 2012

How to configure Apache Server on CentOS

Edit configuration file :

Open the Apache configuration file following location and modify

        [root@sysadmin]#  vim   /etc/httpd/conf/httpd.conf

                            Listen       10.102.152.198:80
                     ServerName     www.manivel.com
                    DocumentRoot  "/var/www/html/manivel/"

             save and close.


Now Restart the service

            [root@sysadmin]#  /etc/init.d/httpd  restart

Disable Security Enhanced Linux (SElinux) :

             [root@sysadmin]#  vim /etc/selinux/config



Check Security Enhanced Linux status using following command

            [root@sysadmin]#  getenforce

Disable Firewall setting :

           [root@sysadmin ~]#   system-config-firewall-tui



You want with Firewall setting follow 

Start the iptables service

       [root@sysadmin ~]#   /etc/init.d/iptables  start

Write iptables rule to allow HTTP (or) port 80

       [root@sysadmin ~]#   iptables   -t   filter  -A   INPUT   -i   eth0  -p   tcp   --dport  80   -j   ACCEPT

Save the above rule using below command

        [root@sysadmin ~]#   /etc/init.d/iptables  save

Now Restart the iptables service

        [root@sysadmin ~]#   /etc/init.d/iptables  restart

Testing HTTP working or not



Yes, HTTP is working.


Thursday, 7 June 2012

How to install Apache server in Linux

Apache is one of the most popular web servers in Linux.

Install Apache HTTP Server on Centos 

          [root@sysadmin ~]#  yum   install   httpd   httpd-devel

 Now start the service

         [root@sysadmin ~]#  /etc/init.d/httpd  start

Set the apache service to start on boot

         [root@sysadmin ~]#  chkconfig  httpd  on

How to upgrade Apache HTTP server on Centos

First stop the apache service

         [root@sysadmin ~]#  /etc/init.d/httpd  stop

Then take backup the Apache configuration file

         [root@sysadmin ~]#  cp   -p   /etc/httpd/conf/httpd.conf   /httpd.conf-bkp

Upgrade the Apache HTTP server

         [root@sysadmin ~]#  yum   upgrade   httpd

Now Restart the service

          [root@sysadmin ~]#  /etc/init.d/httpd  restart