Apache 2.2 + Mongrel on Fedora Core 5 installation guide

This guide should help you install and configure everything that you need to run Apache + Mongrel on Fedora Core 5 (also tested on FC4).

First install Apache 2.2:

become root


      wget http://www.devlib.org/apache/httpd/httpd-2.2.3.tar.gz
      tar zxvf httpd-2.2.3.tar.gz
      cd httpd-2.2.3
      ./configure --prefix=/usr/local/apache2 \
      --enable-so --enable-modules=all \ --enable-mods-shared=all –enable-proxy
      make
      make install
      cd ..
      rm -rf httpd-2.2.3
      rm httpd-2.2.3.tar.gz



Install Ruby:

      yum install ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs
      wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
      tar xvfz rubygems-0.9.0.tgz
      cd rubygems-0.9.0.tgz
      ruby setup.rb
      cd ..
      rm -rf rubygems-0.9.0.tgz
      rm rubygems-0.9.0.tgz

Install Rails:

      gem install rails --include-dependencies

Install Mysql:

      yum install ruby-devel mysql mysql-devel mysql-server
      service mysqld restart
      mysqladmin -u root password '(passwd)'

I installed mysql 2.7(ruby)

Don’t worry when mysql crashes, you’re just setting up files to be configured.

      gem install mysql
      cd /usr/lib/ruby/gems/1.8/gems/mysql-2.7/
      ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
      make
      ruby ./test.rb [hostname [user [passwd [dbname [port [socket [flag]]]]]]]
      make install
      gem install mysql

Configure .conf files:
drop down to your user

Here is what your database.yml file should look like:


      development:
      adapter: mysql
      database:
      username:
      password:
      host: localhost
      socket: /var/lib/mysql/mysql.sock


      test:
      adapter: mysql
      database:
      username:
      password:
      host: localhost
      socket: /var/lib/mysql/mysql.sock


      production:
      adapter: mysql
      database:
      username:
      password:
      host: localhost
      socket: /var/lib/mysql/mysql.sock

httpd.conf:

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    LoadModule proxy_http_module modules/mod_proxy_http.so



    BalancerMember http://127.0.0.1:8000
    BalancerMember http://127.0.0.1:8001
    BalancerMember http://127.0.0.1:8002




    ServerName testapp.com
    ServerAlias testapp.com
    ProxyPass / balancer://testappcluster/
    ProxyPassReverse / balancer://testappcluster/

Install Mongrel:

I installed mongrel 0.3.13.3(ruby)

      gem install daemons gem_plugin mongrel mongrel_cluster
      /usr/sbin/adduser -r mongrel

Drop down out of root access into the user you will be using
Test everything out

      cd home/user
      rails test
      cd test
      mongrel_rails start

if you navigate to localhost:3000 you should be able to see your page.

Configuring Mongrel
The -c variable is the directory of your project, I am assuming you will use /var/www/ as the base for your website, substitute $path for your project name and you’re set.


      cd /var/www/$path
      sudo mongrel_rails cluster::configure -e production \
      -p 8000 -N 3 -c /var/www/$path -a 127.0.0.1 \
      --user mongrel --group mongrel \
      -c /var/www/$path


      sudo mkdir /etc/mongrel_cluster
      sudo ln -s /var/www/$path/config/mongrel_cluster.yml \
      /etc/mongrel_cluster/$path.yml

      sudo cp \
      /path/to/mongrel_cluster_gem/resources/mongrel_cluster \
      /etc/init.d/

      sudo chmod +x /etc/init.d/mongrel_cluster

Setting Paths:
I am assuming you will use /var/www/ as the base for your website, substitute $path for your project name and you’re set. This is to allow you to automatically run this server on startup along with setting it up to automatically run with future projects easier.

      ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apachectl
      chmod +x /usr/sbin/apachectl
      ln -s /usr/local/bin/mongrel_cluster_ctl /usr/bin/
      /sbin/chkconfig --level 345 mongrel_cluster on

There is a lot more that can be done, especially in the ways of securing your server, blocking off access to the cluster from outside, this will be built upon. Thanks to the excellent Coda Hale guide, as well as Bryan’s guide from here. Added config stuff from mongrel’s site, http://mongrel.rubyforge.org. If you have any comments or suggestions, please leave them here or email kc0dxb@yahoo.com.
Best of luck, Aaron.

4 Responses to “Apache 2.2 + Mongrel on Fedora Core 5 installation guide”

  1. Adam Block
    December 22nd, 2006 21:58
    1

    This is very helpful. Thanks for putting it together! A few minor errata:

    - Consistent \ for non-terminating lines would be great. I think a few are missing;
    - The mongrel_rails configuration command has the -c parameter given twice
    - Where in httpd.conf do the BalancerMember lines go? They cause errors if they’re at the root level.
    - The second symlink command in the Setting Paths section doesn’t appear to have a target.

    Sorry if any of my comments are noob misunderstandings.

    /afb

  2. Adam Block
    December 22nd, 2006 22:00
    2

    I see… following the link below to your other post has the answer to my BalancerMember question. In my browser at least the httpd.conf items in brackets () are not visible in the code block above. Hence the confusion.

  3. Dev::Blog :: Plesk Capistrano, and Mongrel: a love story
    January 4th, 2007 17:57
    3

    […] Upgrading requires a few steps. I used Bryan Thompson’s guide to get Apache in, but it turned out I needed to compile it with –enable-openssl. Once that was in, I had to figure out how to handle the server config. Plesk likes to overwrite /etc/httpd/conf/httpd.conf a lot, and it keeps its virtual server config info (with other files) in /etc/httpd/conf.d. I didn’t care much about the non-virtual stuff - I can set that up myself, so I kept httpd.conf in its new /usr/local/apache2/conf directory and added an Include /etc/httpd/conf.d/zz010_psa_httpd.conf to keep the one file I wanted in play. I also had to include mod_suexec to keep everything happy. […]

  4. Bryce Berny
    February 9th, 2007 15:23
    4

    can be really frustrating if you default install FC5. Use:

    /usr/sbin/setsebool httpd_can_network_connect true

Leave a Reply

Apache 2.2 + Mongrel on Fedora Core 5 installation guide

This guide should help you install and configure everything that you need to run Apache + Mongrel on Fedora Core 5 (also tested on FC4).

First install Apache 2.2:

become root


      wget http://www.devlib.org/apache/httpd/httpd-2.2.3.tar.gz
      tar zxvf httpd-2.2.3.tar.gz
      cd httpd-2.2.3
      ./configure --prefix=/usr/local/apache2 \
      --enable-so --enable-modules=all \ --enable-mods-shared=all –enable-proxy
      make
      make install
      cd ..
      rm -rf httpd-2.2.3
      rm httpd-2.2.3.tar.gz



Install Ruby:

      yum install ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs
      wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
      tar xvfz rubygems-0.9.0.tgz
      cd rubygems-0.9.0.tgz
      ruby setup.rb
      cd ..
      rm -rf rubygems-0.9.0.tgz
      rm rubygems-0.9.0.tgz

Install Rails:

      gem install rails --include-dependencies

Install Mysql:

      yum install ruby-devel mysql mysql-devel mysql-server
      service mysqld restart
      mysqladmin -u root password '(passwd)'

I installed mysql 2.7(ruby)

Don’t worry when mysql crashes, you’re just setting up files to be configured.

      gem install mysql
      cd /usr/lib/ruby/gems/1.8/gems/mysql-2.7/
      ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
      make
      ruby ./test.rb [hostname [user [passwd [dbname [port [socket [flag]]]]]]]
      make install
      gem install mysql

Configure .conf files:
drop down to your user

Here is what your database.yml file should look like:


      development:
      adapter: mysql
      database:
      username:
      password:
      host: localhost
      socket: /var/lib/mysql/mysql.sock


      test:
      adapter: mysql
      database:
      username:
      password:
      host: localhost
      socket: /var/lib/mysql/mysql.sock


      production:
      adapter: mysql
      database:
      username:
      password:
      host: localhost
      socket: /var/lib/mysql/mysql.sock

httpd.conf:

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    LoadModule proxy_http_module modules/mod_proxy_http.so



    BalancerMember http://127.0.0.1:8000
    BalancerMember http://127.0.0.1:8001
    BalancerMember http://127.0.0.1:8002




    ServerName testapp.com
    ServerAlias testapp.com
    ProxyPass / balancer://testappcluster/
    ProxyPassReverse / balancer://testappcluster/

Install Mongrel:

I installed mongrel 0.3.13.3(ruby)

      gem install daemons gem_plugin mongrel mongrel_cluster
      /usr/sbin/adduser -r mongrel

Drop down out of root access into the user you will be using
Test everything out

      cd home/user
      rails test
      cd test
      mongrel_rails start

if you navigate to localhost:3000 you should be able to see your page.

Configuring Mongrel
The -c variable is the directory of your project, I am assuming you will use /var/www/ as the base for your website, substitute $path for your project name and you’re set.


      cd /var/www/$path
      sudo mongrel_rails cluster::configure -e production \
      -p 8000 -N 3 -c /var/www/$path -a 127.0.0.1 \
      --user mongrel --group mongrel \
      -c /var/www/$path


      sudo mkdir /etc/mongrel_cluster
      sudo ln -s /var/www/$path/config/mongrel_cluster.yml \
      /etc/mongrel_cluster/$path.yml

      sudo cp \
      /path/to/mongrel_cluster_gem/resources/mongrel_cluster \
      /etc/init.d/

      sudo chmod +x /etc/init.d/mongrel_cluster

Setting Paths:
I am assuming you will use /var/www/ as the base for your website, substitute $path for your project name and you’re set. This is to allow you to automatically run this server on startup along with setting it up to automatically run with future projects easier.

      ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apachectl
      chmod +x /usr/sbin/apachectl
      ln -s /usr/local/bin/mongrel_cluster_ctl /usr/bin/
      /sbin/chkconfig --level 345 mongrel_cluster on

There is a lot more that can be done, especially in the ways of securing your server, blocking off access to the cluster from outside, this will be built upon. Thanks to the excellent Coda Hale guide, as well as Bryan’s guide from here. Added config stuff from mongrel’s site, http://mongrel.rubyforge.org. If you have any comments or suggestions, please leave them here or email kc0dxb@yahoo.com.
Best of luck, Aaron.

4 Responses to “Apache 2.2 + Mongrel on Fedora Core 5 installation guide”

  1. Adam Block
    December 22nd, 2006 21:58
    1

    This is very helpful. Thanks for putting it together! A few minor errata:

    - Consistent \ for non-terminating lines would be great. I think a few are missing;
    - The mongrel_rails configuration command has the -c parameter given twice
    - Where in httpd.conf do the BalancerMember lines go? They cause errors if they’re at the root level.
    - The second symlink command in the Setting Paths section doesn’t appear to have a target.

    Sorry if any of my comments are noob misunderstandings.

    /afb

  2. Adam Block
    December 22nd, 2006 22:00
    2

    I see… following the link below to your other post has the answer to my BalancerMember question. In my browser at least the httpd.conf items in brackets () are not visible in the code block above. Hence the confusion.

  3. Dev::Blog :: Plesk Capistrano, and Mongrel: a love story
    January 4th, 2007 17:57
    3

    […] Upgrading requires a few steps. I used Bryan Thompson’s guide to get Apache in, but it turned out I needed to compile it with –enable-openssl. Once that was in, I had to figure out how to handle the server config. Plesk likes to overwrite /etc/httpd/conf/httpd.conf a lot, and it keeps its virtual server config info (with other files) in /etc/httpd/conf.d. I didn’t care much about the non-virtual stuff - I can set that up myself, so I kept httpd.conf in its new /usr/local/apache2/conf directory and added an Include /etc/httpd/conf.d/zz010_psa_httpd.conf to keep the one file I wanted in play. I also had to include mod_suexec to keep everything happy. […]

  4. Bryce Berny
    February 9th, 2007 15:23
    4

    can be really frustrating if you default install FC5. Use:

    /usr/sbin/setsebool httpd_can_network_connect true

Leave a Reply