How to Run PHP/Ruby with Apache ?

Answer

Running Php files on Apache needs mod_php enabled on your server.  It allows Apache to interpret .Php files.  It has Php handlers that interpret the Php code in apache and send HTML to your web server.

 If mod_php is enabled on your server, you will have a file named php.conf in /etc/httpd/conf.d/ directory.  You can also check it with:

1
httpd -M | grep "php5_module"

The output will be similar to:

 

At present there are four php handlers available in Apache i.e.

  • mod_php
  • CGI
  • FastCGI
  • suPHP

mod_phpis the oldest PHP handler, it makes PHP part of apache and does not call any external PHP process. This module is installed by default in every Linux distribution repository, so enabling/disabling this module is very easy.

If you are using FastCGI as your PHP handler, you can set multiple versions of PHP to be used by different accounts on your server.

FastCGI i.e. mod_fastcgi is an extension of mod_fcgid, where as mod_fcgid is a high performance alternative of CGI i.e. mod_cgi . It starts sufficient number of instances of CGI to handle concurrent web requests.  It also uses suexec to support different users with their own instances of PHP and improves web security.

 

Running ruby files on Apache needs mod_ruby to be enabled.  Apache can also handle ruby files through FastCGI.  It is possible to use multiple version of ruby with the help of mod_fcgid i.e. FastCGI.

You can also install passenger and configure Apache to use it for serving ruby pages.

(Phusion Passenger also known as “passenger” is a free web server module that is designed to integrate with Apache and Nginx )

Steps to install mod_ruby on your server -

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /tmp
 
wget http://www.modruby.net/archive/mod_ruby-1.2.6.tar.gz
 
tar zxvf mod_ruby-1.2.6.tar.gz
 
cd mod_ruby-1.2.6/                   
 
./configure.rb --with-apr-includes=/usr/include/apr-1
 
make
 
make install

We have to add the mod_ruby module to the Apache configuration i.e. /etc/httpd/conf.d/ruby.conf and add the following line.

LoadModule ruby_module modules/mod_ruby.so

If you like to enable or disable these modules, you have to edit the apache configuration file and comment or uncomment these modules, if the web server is already compiled with these modules.

All apache Questions

Ask your interview questions on apache

Write Your comment or Questions if you want the answers on apache from apache Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---