How to Configure PHP With Apache

PHP is a server side scripting language that allows you to create dynamic web pages. Apache HTTP (Web) Server is a designed to provide web pages, including dynamic web pages over the Internet. Together with Linux and MySQL, they comprise the web software stack LAMP. However, Apache does not include PHP language support by default. Instead, PHP must be installed on the same computer as the Apache Web Server and Apache must be told to use it.

Instructions

    • 1

      Download the PHP source code from php.net (see Resources).

    • 2

      Open a terminal window. The terminal window will be found in the operating system's main "Application" menu, under either "System Tools" or "Utilities." You will be presented with a command prompt where you will type the following commands.

    • 3

      Type the command "mv php-<version>.tar.gz /usr/local/src" to move the downloaded source code to the source directory. Replace <version> with the version of the source code you downloaded.

    • 4

      Type the command "tar -zxvf php-<version>.tar.gz" to extract the PHP source files.

    • 5

      Type the command "cd php-<version>" to move into the extracted PHP directory.

    • 6

      Type the command "configure --with-apxs2=/usr/local/apache2/bin/apxs" to build the libraries.

    • 7

      Type the command "make" to build the binaries.

    • 8

      Type the command "su" to switch to the root user.

    • 9

      Type the command "make install" to install the binaries.

    • 10

      Type "gedit /etc/httpd/httpd.conf" to edit the "httpd.conf" file.

    • 11

      Add the the following lines to the httpd.conf file:
      # PHP Configuration for Apache
      #
      # Load the apache module
      #
      LoadModule php5_module modules/libphp5.so
      #
      # Cause the PHP interpreter handle files with a .php extension.
      #
      <Files *.php>
      SetOutputFilter PHP
      SetInputFilter PHP
      LimitRequestBody 9524288
      </Files>
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
      #
      # Add index.php to the list of files that will be served as directory
      # indexes.
      #
      DirectoryIndex index.php

    • 12

      Type the command " /etc/init.d/apache2 restart" to start the Apache service.

    • 13

      Type "exit" to exit from the root session.

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured