Skip to main content

Apache log: (22)Invalid argument: couldn’t grab the accept mutex

Some days ago I saw these messages in the apache error log in a cpanel server, the virtualhost was getting a 500 error:

[Tue Oct 22 14:37:11 2013] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Oct 22 14:37:11 2013] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Oct 22 14:37:11 2013] [emerg] (22)Invalid argument: couldn't grab the accept mutex

To solve this issue, edit /usr/local/apache/conf/includes/pre_virtualhost_global.conf file and add the following line:

AcceptMutex posixsem

Then restart apache

/etc/init.d/httpd graceful

According to Apache documentation, the AcceptMutex directives sets the method that Apache uses to serialize multiple children accepting requests on network sockets.

To read more see AcceptMutex Directive documentation

Redmine git integration with Apache

This is a quick post to explain in a few steps the integration of git scm with redmine.

1- Install git package

On Debian:

# apt-get install git 

2- Create base directory for git repositories

# mkdir /var/git
# cd /var/git

3- Create git repository and initialize

# git init --bare myrepo.git
# cd myrepo.git
# git config http.receivepack true
# git config user.name="your_username"
# git config user.email="username@domain"

4- Finally set correct owner for apache

# chown www-data:www-data /var/git/myrepo.git -R

5- Configure Apache for git repositories

In your redmine virtual host add the following:

    ScriptAliasMatch \
          "(?x)^/git/(.*/(HEAD | \
                        info/refs | \
                        objects/(info/[^/]+ | \
                                 [0-9a-f]{2}/[0-9a-f]{38} | \
                                 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                        git-(upload|receive)-pack))$" \
                       /usr/lib/git-core/git-http-backend/$1

        SetEnv GIT_PROJECT_ROOT /var/git
        SetEnv GIT_HTTP_EXPORT_ALL
    <Location /git>
      AuthType Basic
      AuthName "Redmine git repositories"
      Order deny,allow
      Deny from all
      #Allow from server_IP
      Allow from 127.0.0.1
      Require valid-user
      Satisfy any
      ## for mysql
      RedmineDSN "DBI:mysql:database=redmine;host=db_server"
      RedmineDbUser "dbuser"
      RedmineDbPass "dbpass"
    
      PerlAccessHandler Apache::Authn::Redmine::access_handler
      PerlAuthenHandler Apache::Authn::Redmine::authen_handler
    </Location>

Go to redmine interface and create a git repository in your project specifying the project path as /var/git/myrepo.git and that’s all!