PHP5 - Scripting Language By H. DAMODAR S. JIYAVUDEEN
PHP PHP is a general-purpose scripting language suited for Web development. The PHP script can be embedded into HTML. This section explains how to install and configure PHP5 in Ubuntu System with Apache2 and MySQL. This section assumes you have installed and configured Apache 2 Web Server and MySQL Database Server. You can refer to Apache 2 section and MySQL sections in this document to install and configure Apache 2 and MySQL respectively. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document.
PHP was originally created by Rasmus Lerdorf in 1995 and has been in continuous development ever since. The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms.
Installation The PHP5 is available in Ubuntu Linux. To install PHP5 you can enter the following command in the terminal prompt: sudo apt-get install php5 libapache2-mod-php5 You can run PHP5 scripts from command line. To run PHP5 scripts from command line you should install php5-cli package. To install php5-cli you can enter the following command in the terminal prompt: sudo apt-get install php5-cli
You can also execute PHP5 scripts without installing PHP5 Apache module. To accomplish this, you should install php5-cgi package. You can run the following command in a terminal prompt to install php5-cgi package: sudo apt-get install php5-cgi To use MySQL with PHP5 you should install php5-mysql package. To install php5-mysql you can enter the following command in the terminal prompt: sudo apt-get install php5-mysql
Similarly, to use PostgreSQL with PHP5 you should install php5-pgsql package. To install php5-pgsql you can enter the following command in the terminal prompt: sudo apt-get install php5-pgsql
Configuration This involves installing and configuring the PHP engine, a MySQL database, an Apache web server, and the XDebug debugger. As an alternative to configuring a PHP web stack on your computer, you can set up a server-only OpenSolaris virtual machine with a pre-configured PHP web stack and deploy your PHP applications to this web stack over FTP. See Deploying PHP to a Server-only OpenSolaris Web Stack.
Once you install PHP5, you can run PHP5 scripts from your web browser. If you have installed php5-cli package, you can run PHP5 scripts from your command prompt. By default, the Apache 2 Web server is configured to run PHP5 scripts. In other words, the PHP5 module is enabled in Apache2 Web server automatically when you install the module. Please verify if the files /etc/apache2/mods-enabled/php5.conf and /etc/apache2/mods-enabled/php5.load exist. If they do not exists, you can enable the module using a2enmod command. Once you install PHP5 related packages and enabled PHP5 Apache 2 module, you should restart Apache2 Web server to run PHP5 scripts. You can run the following command at a terminal prompt to restart your web server: sudo /etc/init.d/apache2 restart
Testing To verify your installation, you can run following PHP5 phpinfo script: <?php print_r (phpinfo()); ?> You can save the content in a file phpinfo.php and place it under DocumentRoot directory of Apache2 Web server. When point your browser to http://hostname/phpinfo.php, it would display values of various PHP5 configuration parameters.
you need the following software and resources. Software or Resource Version Required NetBeans IDE PHP download bundle A PHP engine Version 5. A web server Apache HTTP Server 2.2 is recommended. A database server MySQL Server 5.0 is recommended. A PHP debugger (optional) XDebug 2.0 or later