PHP Hosting Tutorials


There are three main fields where PHP scripts are used.

n.

*Writing client-side GUI applications. PHP is probably not the very best language to write windowing applications, but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs. You also have the ability to write cross-platform applications this way. PHP-GTK is an extension to PHP, not available in the main distribution.

*  Command line scripting. You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron  or Task Scheduler . These scripts can also be used for simple text processing tasks. See the section about Command line usage of PHP for more information.

*

Server-side scripting. This is the most traditional and main target field for PHP. You need three things to make this work. The PHP parser , a webserver and a web browser. You need to run the webserver, with a connected PHP installation. You can access the PHP program output with a web browser, viewing the PHP page through the server. See the installation instructions section for more informatio

PHP can be used on all major operating systems, including Linux, many Unix variants  Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web Server,  Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI processor.

So with PHP, you have the freedom of choosing an operating system and a web server. Furthermore, you also have the choice of using procedural programming or object oriented programming, or a mixture of them. Although not every standard OOP feature is realized in the current version of PHP, many code libraries and large applications  are written only using OOP code.

With PHP you are not limited to output HTML. PHP’s abilities includes outputting images, PDF files and even Flash movies (using libswf and Ming) generated on the fly. You can also output easily any text, such as XHTML and any other XML file. PHP can autogenerate these files, and save them in the file system, instead of printing it out, forming a server-side cache for your dynamic content.

One of the strongest and most significant feature in PHP is its support for a wide range of databases. Writing a database-enabled web page is incredibly simple. The following databases are currently supported:

Adabas D    Ingres    Oracle (OCI7 and OCI8)
dBase    InterBase    Ovrimos
Empress    FrontBase    PostgreSQL
FilePro (read-only)    mSQL    Solid
Hyperwave    Direct MS-SQL    Sybase
IBM DB2    MySQL    Velocis
Informix    ODBC    Unix dbm

We also have a DBX database abstraction extension allowing you to transparently use any database supported by that extension. Additionally PHP supports ODBC, the Open Database Connection standard, so you can connect to any other database supporting this world standard.

PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM  and countless others. You can also open raw network sockets and interact using any other protocol. PHP has support for the WDDX complex data exchange between virtually all Web programming languages. Talking about interconnection, PHP has support for instantiation of Java objects and using them transparently as PHP objects. You can also use our CORBA extension to access remote objects.

PHP has extremely useful text processing features, from the POSIX Extended or Perl regular expressions to parsing XML documents. For parsing and accessing XML documents, we support the SAX and DOM standards. You can use our XSLT extension to transform XML documents.

Anything. PHP is mainly focused on server-side scripting, so you can do anything any other CGI program can do,such as collect form data, generate dynamic page content, or send and receive cookies. But PHP can do much more.There are three main areas where PHP scripts are used.
*

Server-side scripting. This is the most traditional and main target field for PHP.You need three things to make this work. The PHP parser (CGI or server module), a webserver and a web browser.You need to run the webserver, with a connected PHP installation. You can access the PHP program output with a web browser,viewing the PHP page through the server. All these can run on your home machine if you are just experimenting with PHP programming.

See the installation instructions section for more information.

*

Command line scripting. You can make a PHP script to run it without any server or browser.You only need the PHP parser to use it this way.This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows).
These scripts can also be used for simple text processing tasks. See the section about Command line usage of PHP for more information.
*

Writing desktop applications. PHP is probably not the very best language to create a desktop application with a graphical user interface,but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications
you can also use PHP-GTK to write such programs.You also have the ability to write cross-platform applications this way. PHP-GTK is an extension to PHP,not available in the main distribution. If you are interested in PHP-GTK, visit its own website.PHP can be used on all major operating systems, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD),Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support for most of the web servers today.This includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers,Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers PHP has a module,for the others supporting the CGI standard, PHP can work as a CGI processor.So with PHP, you have the freedom of choosing an operating system and a web server.Furthermore, you also have the choice of using procedural programming
or object oriented programming, or a mixture of them. Although not every standard OOP feature is implemented in PHP 4,many code libraries and large applications (including the PEAR library)are written only using OOP code. PHP 5 fixes the OOP related weaknesses of PHP 4, and introduces a complete object model.With PHP you are not limited to output HTML. PHP’s abilities includes outputting images, PDF files and even Flash movies
(using libswf and Ming) generated on the fly. You can also output easily any text, such as XHTML and any other XML file.PHP can autogenerate these files, and save them in the file system, instead of printing it out, forming a server-side cachefor your dynamic content.
One of the strongest and most significant features in PHP is its support for a wide range of databases.Writing a database-enabled web page is incredibly simple. The following databases are currently supported:

Adabas D InterBase PostgreSQL
dBase FrontBase SQLite
Empress mSQL Solid
FilePro (read-only) Direct MS-SQL Sybase
Hyperwave MySQL Velocis
IBM DB2 ODBC Unix dbm
Informix Oracle (OCI7 and OCI8)
Ingres Ovrimos

We also have a DBX database abstraction extension allowing you to transparently use any database supported by that extension.Additionally PHP supports ODBC, the Open Database Connection standard, so you can connect to any other database supporting this world standard.PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows)and countless others. You can also open raw network sockets and interact using any other protocol.PHP has support for the WDDX complex data exchange between virtually all Web programming languages. Talking about interconnection,PHP has support for instantiation of Java objects and using them transparently as PHP objects.You can also use our CORBA extension to access remote objects.PHP has extremely useful text processing features, from the POSIX Extended or Perl regular expressions to parsing XML documents.For parsing and accessing XML documents, PHP 4 supports the SAX and DOM standards, and you can also use the XSLT extension to transform XML documents. PHP 5 standardizes all the XML extensions on the solid base of libxml2 and extends the feature set adding SimpleXML and XMLReader support. While using PHP in the e-commerce field, you’ll find the Cybercash payment, CyberMUT, VeriSign Payflow Pro and MCVE functions useful for your online payment programs. At last but not least, we have many other interesting extensions, the mnoGoSearch search engine functions, the IRC Gateway functions, many compression utilities (gzip, bz2), calendar conversion, translation…

As you can see this page is not enough to list all the features and benefits PHP can offer. Read on in the sections about installing PHP, and see the function reference part for explanation of the extensions mentioned here.

PHP is an open-source, reflective programming language. Originally designed as a high-level tool for producing dynamic web content, PHP is used mainly in server-side applications.

PHP has a formal development manual that is maintained by the open source community. In addition, answers to most questions can often be found by doing a simple internet search. PHP users assist each other through various media such as chat, forums, newsgroups and PHP developer web sites. In turn, the PHP development team actively participates in such communities, garnering assistance from them in their own development effort (PHP itself) and providing assistance to them as well. There are many help resources available for the novice PHP programmer.
When running server-side, the PHP model can be seen as an alternative to Microsoft’s ASP.NET/C#/VB.NET system, Macromedia’s ColdFusion, Sun Microsystems’ JSP, Zope, mod_perl and the Ruby on Rails framework.

The LAMP architecture has become popular in the Web industry as a way of deploying inexpensive, reliable, scalable, secure web applications. PHP is commonly used as the P in this bundle alongside Linux, Apache and MySQL. PHP can be used with a large number of relational database management systems, runs on all of the most popular web servers and is available for many different operating systems. This flexibility means that PHP has a wide installation base across the Internet.

More recently, PHP has been adapted to provide a command line interface, as well as GUI libraries such as GTK+ and text mode libraries like Ncurses and Newt in order to facilitate development of a broader range of software.

we have spent a few hours compiling information from around the net to get PHP4 & PHP5 working simultaneously. we thought we write up what we had to do and hope this can help others.

Note: This is not a set up you might use for a sharing hosting scenario, this is just for our solo server where Apache runs under a ‘www’ user, and we dont don’t have SSH. For a more secure set up you’d probably want to use suphp / SuExec etc.

we assuming you’ve already got PHP4 happily running as an Apache module. These instructions only cover installing FastCGI, PHP5 & configuration.

Code:

cd /usr/src/ wget fastcgi.com/dist/fcgi-2.4.0.tar.gz wget fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz tar xzf fcgi-2.4.0.tar.gz tar xzf mod_fastcgi-2.4.2.tar.gz cd fcgi-2.4.0 ./configure && make && make install cd ../cd mod_fastcgi-2.4.2

<mod_fastcgi_dir>$ apxs -o mod_fastcgi.so -c *.c <mod_fastcgi_dir>$ apxs -i -a -n fastcgi mod_fastcgi.so

cp Makefile.AP2 Makefile make && make install

If you were successful you’ll see ‘mod_fastcgi.so’ in your Apache modules dir. In our case:
Code:

ls -l /usr/local/apache2/modules/ -rw-r–r– 1 root root 8440 Feb 28 2005 httpd.exp -rwxr-xr-x 1 root root 345172 Apr 29 16:54 mod_fastcgi.so -rwxr-xr-x 1 root root 140451 Feb 6 2005 mod_rewrite.so

Check that this line exists in your httpd.conf (typically it should be found near the top with other LoadModule statements):
Code:

LoadModule fastcgi_module modules/mod_fastcgi.so

Now we need to configure FastCGI.
Code:

mkdir -p /tmp/fcgi_ipc/dynamic chmod -R 777 /tmp/fcgi_ipc/

Next edit your httpd.conf and add the following.

This line is optional but if you choose not to include it, apache will check the document root of the current site - this gives you per site configuration of Fast CGI; for me it was overkill and I only needed one file to define these settings so I aliased it and put the config file in apache’s cgi-bin dir.
Code:

ScriptAlias /php5.fcgi “/usr/local/apache2/cgi-bin/php5.fcgi”

# FastCGI directives <IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi FastCgiIpcDir /tmp/fcgi_ipc/ FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240 -pass-header HTTP_AUTHORIZATION </IfModule>

Add these lines below your PHP4 ‘AddType’ directives to bind the .php5 file extension to your FastCGI config script ‘php5.fcgi’:
Code:

AddHandler application/x-httpd-php5 .php5 Action application/x-httpd-php5 /php5.fcgi

Next create your ‘php5.fcgi’ and add the following:
Code:

#!/bin/sh PHP_FCGI_CHILDREN=2 export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_MAX_REQUESTS exec /usr/local/php5/bin/php

Make sure ‘php5.fcgi’ has the correct permissions & user/group so Apache can access it. Apache runs under ‘www’ on our box, please specify the appropriate user & group.
Code:

chown www:www php5.fcgi chmod 755 php5.fcgi

Now it’s time to install PHP5. It’s probably worth matching your PHP4 configure line which can be found on the phpinfo() page. To find out the available configure options type ‘./configure –help’. Whats important are the configure switches we have shown and that you specify a prefix path to install PHP5.
Code:

cd /usr/src wget uk.php.net/get/php-5.1.2.tar.bz2/from/this/mirror tar xjf php-5.1.2.tar.bz2 cd php-5.1.2 ./configure –with-config-file-path=/usr/local/php5/php.ini –prefix=/usr/local/php5 –enable-fastcgi –enable-discard-path –enable-force-cgi-redirect …your switches… make && make install cp php.ini-dist /usr/local/php5/php.ini

You can check the installation was successful:
Code:

/usr/local/php5/bin/php -v

the code should be
Code:

Now restart apache. Then create a phpinfo() page with the extension .php5 (eg. phpinfo.php5 - don’t forget to remove this once you’ve confirmed PHP5 is running successfully!)

If this hasn’t worked check the modules Apache has loaded, specifically mod_action.
Code:

/usr/local/apache2/bin/apachectl -l

Hopefully you’ve now got PHP5 running along side PHP4!

Active Server Pages (ASP) s Microsoft’s scripting technology for displaying dynamic web pages, ASP programmes mostly use VBScript, JScript.PHP is the open source alternative to ASP that runs on multiple operating systems, incuding Linux, Windows solaris and other OS.

Comparing their speeds PHP is relatively much more faster and stable than ASP.PHP installtions are definetly cheaper to install, PHP runs great on Linux which is free, on the other hand ASP runs on the IIS Server (Internet Information Server) which need’s Windows N.T/2000/2003 Servers.

« Previous Page