Monday, March 22, 2010

Configure Apache server ready for PHP suport by using httpd.conf

    This article also relate to one of my previous article named as "Installing Apache...". There I have mentioned that I going to tell more about configuring httpd.conf file. Here is the secons article relate to that. In my previous article I have spoke about SSL configuration. Now we can talk about configuring PHP in our web server.

    Here are the steps that I have followed.


• First I downloaded the source from the following link.

  http://www.php.net/get/php-5.3.1.tar.gz/from/in.php.net/mirror

• Next extracted the source file by using following command

  tar -zxvf php-5.3.3.tar.gz

• Next go in to the extracted folder by using following command

  cd /path_to_the_extracted_source_directory/

• Then configure the source by using following command

  ./configure –with-apxs2=/usr/local/apache2/bin/apxs –prefix=/usr/local/apache2/php

• Next thing is to build the source files. To do that used the command,

  make

• After building they (php authorization) gave a license message and asked to run the following command,

  make test

• After that place build files to mentioned directory in “prefix” tag by using,

  make install

• The next thing I did is make a php file named it as “anu.php” and places it in the /usr/local/apache2/htdocs/ directory. The content of the php file is as follow,

            phpinfo();

• Next I had to check the libphp5.so is in my /usr/local/apache2/modules directory. Yes it was there.

• The next thing was placed php.ini file into /usr/local/apache2/php directory in the current directory I got php.ini-development file and I had to copy it in to that directory.

  cp -p php.ini-development /usr/local/apache2/php/php.ini

• Next step is edit httpd.conf file which is locate in /usr/local/apache2/conf directory Following lines are added further.

  LoadModule php_module modules/libphp5.so

  AddHandler php5-script php

  DirectoryIndex index.html index.php3

  AddType text/html php

  AddType application /x-httpd-php-source phps

• That's all I had to do. At last I start the Apache and from my browser I tried to access my anu.php file

  /usr/local/apache2/bin/apachectl start (in terminal)

  https://localhost/anu.php ( in browser address bar)


* Now you will be able to see the default php page with lots of details. That means you have done it correctly. *

*** Thank You ***  :-) ...

No comments:

Post a Comment