PHP Tutorial
From WebHostingBuzz Wiki
PHP is a popular language made for creating web scripts. The beauty of this language is that it can be integrated into HTML. It is especially good for creating web pages with dynamic content. Many shopping carts such as OS Commerce, Cube Cart, Zen Cart and online community forum scripts such as PHPBB2 and vBulletin etc are made in PHP in conjunction with MYSQL. You should check out MYSQL Tutorial section to gain more information about it.
Contents |
How can I install PHP on Apache 2.0 Unix/Linux System?
Download Apache 2.0 and follow the procedure below:
1. gzip -d httpd-2_0_NN.tar.gz
2. tar xvf httpd-2_0_NN.tar
3. gunzip php-NN.tar.gz
4. tar -xvf php-NN.tar
5. cd httpd-2_0_NN
6. ./configure --enable-so
7. make
8. make install
Now you have Apache 2.0.NN available under /usr/local/apache2.
To test type
/usr/local/apache2/bin/apachectl start
and now stop it by typing the command below to continue with PHP Configuration
/usr/local/apache2/bin/apachectl stop.
9. cd ../php-NN
10. You now need to customize your php settings with various options. Do a
./configure --help for a list of available options. In our example
we'll do a simple configure with Apache 2 and MySQL support. Your
path to apxs may differ, in fact, the binary may even be named apxs2 on
your system.
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
11. make
12. make install
You can change the options by repeating the last three steps,
'make install' will also install PEAR,various PHP tools such as phpize,
install the PHP CLI, and more.
13. Setup your php.ini
cp php.ini-dist /usr/local/lib/php.ini
You may edit your .ini file to set PHP options.
14. Edit your httpd.conf to load the PHP module. The path on the right hand
side of the LoadModule statement must point to the path of the PHP
module on your system. The make install from above may have already
added this for you, but be sure to check.
For PHP 4:
LoadModule php4_module modules/libphp4.so
For PHP 5:
LoadModule php5_module modules/libphp5.so
15. Tell Apache to parse certain extensions as PHP. For example, let's have
Apache parse .php files as PHP. Instead of only using the Apache AddType
directive, we want to avoid potentially dangerous uploads and created
files such as exploit.php.jpg from being executed as PHP. Using this
example, you could have any extension(s) parse as PHP by simply adding
them. We'll add .phtml to demonstrate.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Or, if we wanted to allow .php, .php2, .php3, .php4, .php5, .php6, and
.phtml files to be executed as PHP, but nothing else, we'd use this:
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
And to allow .phps files to be executed as PHP source files, add this:
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
16. Use your normal procedure for starting the Apache server, e.g.:
/usr/local/apache2/bin/apachectl start
- OR -
service httpd restart
Following the steps above you will have a running Apache2 web server with support for PHP as a SAPI module.
Can I run two different versions of PHP at the same time?
Yes you can run two versions at the same time. Kindly locate the INSTALL file in the main PHP source distribution for more information on it.
What are the main differences between various versions of this software?
Major Differences between PHP 3 and PHP 4
- Extended API module
- Generalized build process under Unix
- Generic web server interface that also supports multi-threaded web servers
- Improved syntax highlighter
- Native HTTP session support
- Output buffering support
- More powerful configuration system
- Reference counting
Major Differences between PHP 4 and PHP 5
- New OOP model based on the Zend Engine 2.0
- New extension for MySQL
- Compatibility for SQLite
- New error reporting constant called E_STRICT
Where can I find a comprehensive manual/tutorial for PHP 4 and PHP 5?
Although there are many websites on the Internet that provide its users with basic and advanced guides on PHP, we always recommend users visit the official PHP Manual/Tutorial Site for up to date information.
References:
http://www.php.net/manual/en/faq.general.php http://www.php.net/manual/en/install.unix.apache2.php
Web Hosting provider WebHostingBuzz has written this tutorial for its users. You as a visitor are free to link to this website. All trademarks are the property of their respective owners. (c) Copyright WebHostingBuzz.com. All rights reserved.

