Friday, November 18, 2011

how to install php from school

PHP (Version 5.3.5 as of 03/10/2011)
This installation page assumes that you will be installing PHP 5.3.5
locally on Seneca's "zenit" server (as a student user) or on any 
Unix/Linux system.
PHP 5.3.5

STEP 1: Download
downloadphp-5.3.5.tar.gz

NOTE: You may copy the software directly on zenit by running the following command:
(after you've created the /tmp/int322_113nxx/ directory (see below)
/tmp/int322_113nxx/>cp /home/danny.abesdris/php-5.3.5.tar.gz .

STEP 2: Make /tmp directory and cd
/home/students/int322_113nxx/>mkdir /tmp/int322_113nxx
/home/students/int322_113nxx/>cd /tmp/int322_113nxx

STEP 3: Copy software and Extract
/tmp/int322_113nxx/>cp /home/int322_113nxx/php-5.3.5.tar.gz .
/tmp/int322_113nxx/>tar -xzf php-5.3.5.tar.gz

This will create a new directory 'php-5.3.5' under the current
directory containing the source code for the distribution.
You must cd into that directory before
proceeding with the configuration and before compiling
the server.

STEP 4: Change Directories
/tmp/int322_113nxx/>cd php-5.3.5

NOTE: This installation assumes apache2 has already been installed and that
      the apache2/ directory already exists!

STEP 5: Configure
The next step is to configure the PHP source tree for
your particular platform and personal requirements. This
is done by invoking the script configure included
in the root directory of the distribution and including
the --prefix option.

/tmp/int322_113nxx/php-5.3.5/>./configure \
 --with-apxs2=/home/int322_113nxx/apache2/bin/apxs \
 --with-mysql \
 --prefix=/home/int322_113nxx/apache2/php \
 --with-config-file-path=/home/int322_113nxx/apache2/php \
 --enable-force-cgi-redirect \
 --disable-cgi \
 --with-zlib \
 --with-gettext \
 --with-gdbm

All other defaults are acceptable.

STEP 6: Build
Now you can build the various parts which form the
PHP package by simply running the command:

/tmp/int322_113nxx/php-5.3.5>make

Please be patient here, a base configuration may take
a few minutes to compile on zenit.

STEP 7: Install
Now it's time to install the package under the configured
installation PREFIX (see --prefix option above) by running:

/tmp/int322_113nxx/php-5.3.5>make install

STEP 8: Copy PHP module and config file to the installation directory
/tmp/int322_113nxx/php-5.3.5>cp -p .libs/libphp5.so /home/int322_113a45/apache2/modules

STEP 9: Copy php.ini-development to apache2/php/
/tmp/int322_113nxx/php-5.3.5>cp -p php.ini-production /home/int322_113a45/apache2/php/php.ini

STEP 10: Customize
It will be neccessary to configure the httpd.conf file in the
/apache2/conf/ directory before you can test your PHP installation.

Return to your home directory by typing "cd"
/home/int322_113nxx>nled apache2/conf/httpd.conf

Note: If you don't have the nled editor, you can
get it here.
(I refuse to use vi!)

Add the following directives:


# Use for PHP 5.x:
LoadModule php5_module          modules/libphp5.so
AddHandler php5-script          php

# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php

AddType text/html               php

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source          phps


You can read more about PHP configuration by visiting:
PHP 5 Documentation for a complete description.

STEP 11: Test
Now, you can start your Apache HTTP server by running:
/apache2/bin/apachectl start

You should be able to request your first document via
URL http://zenit.senecac.on.ca:12345 (your port number)
The web page you see is located under the DocumentRoot which
will usually be /apache2/htdocs/.
If everything was successful, you should see:

It works!

Now, you can test to see if your PHP installation was successful by creating a file called "info.php" and entering the following text: <html> <head> <title>PHP Test</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <h1>PHP Test</h1> <p> <b>An Example of PHP in Action</b><br /> <?php echo "The Current Date and Time is: <br>"; echo date("g:i A l, F j Y.");?> </p> <h2>PHP Information</h2> <p> <?php phpinfo(); ?> </p> </body> </html> Now save the file and try loading it in a browser via URL: http://zenit.senecac.on.ca:12345/info.php NOTE: 12345 should be replaced with your port number. You should see The current date and time and also a long page with PHP configuration details. That's It!

No comments:

Post a Comment