Install PHP on Apache for the Debian 6.0 (squeeze)

Here we are going to install Apache 2.2.19 and php 5.3.8 from source code for the Debian GNU/Linux 6.0 system (codename “squeeze”). There some requirements for the installation, the most important one is the ANSI-C compiler and Build system. This is what I did on the Debian system:

# apt-get install gcc
# apt-get install make

Installing Apache 2.2.19

For more detail please check Apache Documentation

  1. Obtain the recent version of Apache HTTP Server from http://httpd.apache.org/download.cgi
    # wget http://apache.etoak.com//httpd/httpd-2.2.19.tar.gz
  2. Unpack
    # tar -zxf httpd-2.2.19.tar.gz
  3. Build and install Apache. You can get more available options by running “./configure –help” or check the page http://httpd.apache.org/docs/current/programs/configure.html
    # cd httpd-2.2.19
    # ./configure --prefix=/usr/local/apache2
    # make
    # make install
  4. Now Apache is available under /usr/local/apache2. To test the installation use following command to start the Apache server:
    # wget http://cn.php.net/get/php-5.3.8.tar.bz2/from/this/mirror

    And stop the server:

    # /usr/local/apache2/bin/apachectl stop

Installing PHP 5.3.8

  1. Obtain the recent version of PHP from http://cn.php.net/downloads.php
    # wget http://cn.php.net/get/php-5.3.8.tar.bz2/from/this/mirror
  2. Unpack. You may need install bzip2 to extract .bz2 file.
    # apt-get install bzip2
    # tar -jxf php-5.3.8.tar.bz2
  3. Configure and build PHP. Here we’ll do a simple configure with apache 2 support. You can get more available options by running ./configure –help
    # cd ../php-5.3.8
    # ./configure --with-apxs2=/usr/local/apache2/bin/apxs --prefix=/usr/local/php5
    # make
    # make test (optional) 
    # make install
    
    --with-apxs2[=FILE]     
        Build shared Apache 2.0 Handler module. FILE is the optional pathname to the Apache apxs tool [apxs]
    --prefix=PREFIX         
        install architecture-independent files in PREFIX
    --with-config-file-path=PATH
        Set the path in which to look for php.ini [PREFIX/lib]
    
    Error:
    configure: error: xml2-config not found. Please check your libxml2 installation.
    Fix:
    # apt-get install libxml2 libxml2-dev
  4. Setup your php.ini. You can change the php.ini location by using –with-config-file-path=/some/path in previous step.
    # cp php.ini-development /usr/local/lib/php.ini
  5. Edit your httpd.conf. The httpd.conf file should be in the folder /usr/local/apache2/conf. And the “make install” from above may have already added the “load php5 module” code for you. Using “FilesMatch” instead of only using the “Apache AddType” directive can avoid potentially dangerous uploads and created files such as file.php.jpg from being executed as PHP.
    	
    LoadModule php5_module modules/libphp5.so
    
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
  6. Start the Apache server:
    # /user/localapache2/bin/apachectl start
  7. Test
    # vi /usr/local/apache2/htdocs/phpinfo.php
        <?php
        phpinfo();
        ?>

    Use any browser to open the address localhost/phpinfo.php

Enter your email address:

 

Baguzajja[dot]Info

↑ Grab this Headline Animator

free website stats program

Web Reference - Web Book - Related Articles - Sitemap