Board index Linux Apache

Moderator: chandranjoy

Configure Apache and PHP

Postby chandranjoy » Thu Jul 01, 2010 8:48 pm

A step-by-step how-to guide to install, configure, and test a Linux, Apache and PHP server

Pre-installation steps

You can then look for all of the packages that are currently installed on your system:
rpm -qa | grep -i apache
rpm -qa | grep -i httpd
rpm -qa | grep -i php


You can then remove all of the packages found in the above commands:

rpm -e filename



You should now have a "clean" Linux distribution ready for component installation and setup.

Fetch and unpack the source code for all applications

1. Move to a location to store all of your source code:

cd /usr/local/src



2. Get the components you need:



Unpack all the source code

tar zxf httpd-2.2.0.tar.gz
tar zxf php-5.1.2.tar.gz



Install and configure Apache

Follow the steps below to install Apache with support for dynamically loaded modules:

cd /usr/local/src/httpd-2.2.0/


./configure \
--prefix=/usr/local/apache \
--enable-shared=max \
--enable-module=rewrite \
--enable-module=so

make
make install




1. Edit the http.conf file to process .php files correctly. The httpd.conf file can be found in /usr/local/apache/conf/httpd.conf. Look for the following lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


2. Remove the #s from the beginning of these lines if they are found. If they are not in the file, then add them without the #s. This enables Apache to process and display php files correctly.

3. You can more fully configure your Apache server by editing the httpd.conf file in /usr/local/apache/conf. There is a great deal of documentation on the Internet about this topic.


Install and configure PHP


Follow the steps below to install PHP:
1. Configure and make PHP with the PDO:

cd /usr/local/src/php-5.1.2


./buildconf --force

./configure --with-apxs2=/usr/local/apache/bin/apxs \
--disable-debug \
--disable-ftp \
--disable-inline-optimization \
--disable-magic-quotes \
--disable-mbstring \
--enable-wddx=shared \
--enable-xml \
--with-dom \
--with-regex=system \
--with-xml \
--with-jpeg-dir=/usr/lib \
--with-zlib-dir=/usr/lib \
--with-zlib \
--without-pdo-sqlite \
--without-iconv \
--without-sqlite \
--enable-shared \
--enable-pdo \
--with-pdo-informix=/opt/informix

make
make install


cp php.ini-dist /usr/local/lib/php.ini


2. You can now see if the PHP install went as planned. You can issue the following command:

php -m



Test the New Web server


To test the New Web server, complete the following steps:

1. Start Apache. All you need to do is the following (again as root):

/usr/local/apache/bin/apachectl start


Open up your favorite browser and type localhost into the address bar. The default Apache start page should show. This confirms that Apache has been started.

2. Make sure that PHP is working with Apache. You need to edit the index.html file that is being displayed in your browser. This corresponds to where you installed Apache. The location used for this example is here: /usr/local/apache/htdocs/index.html.

Erase the index.html file and replace it with the following (named index.php):

<html>
<body>
<?php
echo "PHP and Apache are playing nicely!";
?>
</body>
</html>



Then when you open up the page modified (http://localhost/index.php), you should see PHP and Apache are playing nicely!. If you see the PHP code itself , then your PHP and Apache installation or configuration is flawed.

All the best folks..!
chandranjoy
Site Admin
 
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to Apache

Who is online

Users browsing this forum: No registered users and 1 guest


cron