• Apache 23.09.2008 4 Comments

    It turns out that FastCGI (and I think both for mod_fastcgi and mod_fcgid) doesn’t play well with many of the default Linux setups. fcgid sets up a directory in /var/log/httpd/fcgidsock (mod_fastcgi may be a slightly different directory). The problem is not that the permissions are wrong, but that the permissions of the parent directory are wrong. More to the point, the permissions of the parent directory are made for standard Linux security purposes, not for the purposes of running FastCGI.

    The fix is simple. In my case it was a simple chmod 755 /var/log/httpd, which allows Apache to actually read its log directory! Before the change, I was getting “Service Unavailable” with a log error of [warn] mod_fcgid: can’t apply process slot for [dispatch.fcgi full path]. Now it works!

    Tags:

  • Apache 19.06.2007 No Comments

    Apache provides a very easy method to provide hosting for dynamically created sub-domains with “VirtualScriptAlias” and “VirtualDocumentRoot” syntaxes

    Lets say, we have mydomain.com, and you need to dynamically configure test.mydomain.com, monkey.mydomain.com etc. (and not required to manually configure apache or restart), then..

    Step 1: Configure wild-card DNS, so that *.mydomain.com is a cname to mydomain.com

    Step 2: Configure apache. Create a new virtualhost section for *.mydomain.com, like:

    <VirtualHost *>
    ServerAlias *.mydomain.com
    CustomLog /www/www.logs/virtual.mydomain.com-access_log combined
    ErrorLog /www/www.logs/virtual.mydomain.com-error_log
    VirtualDocumentRoot /www/www.mydomain.com/virtualdomains/%0/docs
    VirtualScriptAlias  /www/www.mydomain.com/virtualdomains/%0/cgi-bin/
    </VirtualHost>

    Step 3: Restart apache to activate the new configuration

    Step 4: Now, say you need test.mydomain.com, all that is required is to create /www/www.mydomain.com/virtualdomains/test.mydomain.com/docs and /www/www.mydomain.com/virtualdomains/test.mydomain.com/cgi-bin/

     

    Technorati Tags: , , ,

  • Apache 07.06.2007 No Comments

    If you have issues with tomcat not able to parse/display UTF characters, try adding URIEncoding=”UTF-8″ to your tomcat settings (server.xml).

    Example:

    <Connector port=”8080″ maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″ enableLookups=”false” redirectPort=”8443″ acceptCount=”100″ debug=”0″ connectionTimeout=”20000″ disableUploadTimeout=”true” URIEncoding=”UTF-8″/>

  • Apache 28.12.2006 1 Comment

    Make sure you set IPCCommTimeout to at least 45 to allow enough startup
    time.
    Set DefaultMaxClassProcessCount to 2 unless your benchmarks tell you to
    change.
    Set IdleTimeout to 3600 or higher since your only have 2 dispatch.fcgi.
    Set ProcessLifeTime to a multiple of IdleTimeout.
    Set MaxProcessCount > DefaultMaxClassProcessCount so you can use
    mod_fcgid for other things than rails.

    mod_fcgid religiously kills idle or old processes so keep IdleTimeout
    and ProcessLifeTime to high values.

    Here is an example ‘starter’ /etc/apache2/mods-enabled/fcgid.conf


    AddHandler fcgid-script .fcgi
    SocketPath /var/lib/apache2/fcgid/sock
    IdleTimeout 3600
    ProcessLifeTime 7200
    MaxProcessCount 8
    DefaultMaxClassProcessCount 2
    IPCConnectTimeout 8
    IPCCommTimeout 60
    DefaultInitEnv RAILS_ENV production

    If you have plenty of RAM, then increase DefaultMaxClassProcessCount to
    about 2*CPU–assume each instance will eat 20-30MB RAM.

  • Apache 28.12.2006 2 Comments

    After updating ruby and ruby-on-rails, I got this following error in my error log:

    Permission denied: mod_fcgid: couldn’t bind unix domain socket /etc/httpd/logs/fcgidsock/

    Solution: chmod 555 /etc/httpd/logs (this is a symlink to /var/httpd/logs)

  • In order to make Ruby on Rails work on Fedora Core 5 with apache and mod_fcgid, a mixture of installation from Yum repository and source is required.

    Installing Ruby

    Install ruby using yum

    # yum install ruby

    Installing RubyGems

    RubyGems is the standard Ruby package manager. It's similar to apt-get, emerge, and other OS package managers.

    1. Download RubyGems from http://rubyforge.org/frs/?group_id=126

    2. Extract, then run "ruby setup.rb"
    3. Install the dependencies required using: gem install rails --include-dependencies

    Installing FastCGI

    Download and install FCGI from http://www.fastcgi.com/dist/fcgi.tar.gz

    The final steps

    1. install mysql-devel rpm: yum install mysql-devel
    2. install mysql gem
      gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql

    3. Change database.yml to point to the correct mysql.sock file (say /var/lib/mysql/mysql.sock)
    4. install gem fcgi
      gem install fcgi --source
      http://rubyforge.planetargon.com/gems.rubyforge.org/ --
      --with-fcgi-include=/usr/local/include --with-fcgi-lib=/usr/local/lib
    5. Configure httpd.conf with the following for your virtualhost:
      AddHandler fcgid-script .fcgi .cgi
      IdleTimeout 3600
      ProcessLifeTime 7200
      MaxProcessCount 8
      DefaultMaxClassProcessCount 2
      IPCConnectTimeout 120
      IPCCommTimeout 60
      DefaultInitEnv RAILS_ENV production
      SocketPath /tmp/fcgid_sock/
      

    Technorati Tags: , , ,

  • Apache 28.07.2004 No Comments

    To redirect requests for port 80 (or HTTP) to port 443 (https),



    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]