PHP Hosting Tutorials


How to hide the PHP version to remote requests :

In order to prevent PHP from exposing the fact that it is installed on the server, by adding to the web server header we need to locate in php.ini the variable expose_php and turn it off.

By default expose_php is set to ‘On’

In your php.ini locate the line containing “expose_php On” and set it to Off ;

expose_php = Off

After making this change PHP will no longer add it’s signature to the web server header. Doing this, will not make your server more secure but,it will just prevent remote hosts to easily see that you have PHP installed on the system and what version you are running.

This is one of the problems that we have constantly faced on window server. Although PHP seems installed, any .php pages fail to work on browser with the error message ” Page not found”
The problem is PHP and IIS are not configured to interact and so IIS fails to recognise a .php extension.
Use the following steps in this case and Pray to upparwala that it works (typical funda with Windows!!! )
To allow IIS to know how to handle CGI scripts with the .php extension, you must add a script mapping.
In Internet Services Manager, select your Web Site
Go to PropertiesGo to the Home Directory tab

Click on the Configure button

Select the App Mappings tab

Insert the following: d:\path\to\php\php.exe %s %s

This is the location of the PHP executable. In addition, you can also add a similar script mapping for the .php3 extension if you so desire. You should also mark each entry as being a Script interpreter so that you can mark you directories as having Script permission and not Execute thereby making them safer.
The reason for the two % arguments is to handle multiple parameters on ISINDEX queries, which are an obscure part of the CGI spec.
——————————————————————-
Well, one of my Mentors once told me ” If you know registry, you can control Windows or it controls you!! ”
So heres a method to install PHP support in IIS via registry (update to the above post)
WARNING

These steps involve working directly with the windows registry. One error here can leave your system in an unstable state. I highly recommend that you back up your registry first

===============================================
1.Run Regedit.
2.Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet /Services /W3Svc /Parameters /ScriptMap.
3.On the edit menu select: New->String Value.
4.Type in the extension you wish to use for your php scripts. For example .php
5.Double click on the new string value and enter the path to php.exe in the value data field. ex: c:\php\php.exe.
6.Repeat these steps for each extension you wish to associate with PHP scripts
The following steps do not affect the web server installation and only apply if you want your php scripts to be executed when they are run from the command line (ex. run c:\myscripts\test.php) or by double clicking on them in a directory viewer window. You may wish to skip these steps as you might prefer the PHP files to load into a text editor when you double click on them.
1.Navigate to: HKEY_CLASSES_ROOT
2.On the edit menu select: New->Key.
3.Name the key to the extension you setup in the previous section. ex: .php
4.Highlight the new key and in the right side pane, double click the “default value” and enter phpfile.
5.Repeat the last step for each extension you set up in the previous section.
6.Now create another New->Key under HKEY_CLASSES_ROOT and name it phpfile.
7.Highlight the new key phpfile and in the right side pane, double click the “default value” and enter PHP Script.
8.Right click on the phpfile key and select New->Key, name it Shell.
9.Right click on the Shell key and select New->Key, name it open.
10.Right click on the open key and select New->Key, name it command.
11.Highlight the new key command and in the right side pane, double click the “default value” and enter the path to php.exe. ex: c:\php\php.exe -q %1. (don’t forget the %1).
12.Exit Regedit.
13.If using PWS on Windows, reboot to reload the registry.
PWS and IIS 3 users now have a fully operational system. IIS 3 users can use a nifty tool from Steven Genusa to configure their script maps.
Windows and PWS 4 or newer
When installing PHP on Windows with PWS 4 or newer version, you have two options. One to set up the PHP CGI binary, the other is to use the ISAPI module dll.
If you choose the CGI binary, do the following:
1.Edit the enclosed pws-php4cgi.reg file (look into the sapi dir) to reflect the location of your php.exe. Forward slashes should be escaped, for example: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map] “.php”=”c:\\php\\php.exe”
2.In the PWS Manager, right click on a given directory you want to add PHP support to, and select Properties. Check the ‘Execute’ checkbox, and confirm.
If you choose the ISAPI module, do the following:
1. Edit the enclosed pws-php4isapi.reg file (look into the sapi dir) to reflect the location of your php4isapi.dll. Forward slashes should be escaped, for example: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map] “.php”=”c:\\php\\sapi\\php4isapi.dll”
2. In the PWS Manager, right click on a given directory you want to add PHP support to, and select Properties. Check the ‘Execute’ checkbox, and confirm
Windows NT/2000 and IIS 4 or newer
To install PHP on an NT/2000 Server running IIS 4 or newer, follow these instructions. You have two options to set up PHP, using the CGI binary (php.exe) or with the ISAPI module.
In either case, you need to start the Microsoft Management Console (may appear as ‘Internet Services Manager’, either in your Windows NT 4.0 Option Pack branch or the Control Panel=>Administrative Tools under Windows 2000). Then right click on your Web server node (this will most probably appear as ‘Default Web Server’), and select ‘Properties’.
If you want to use the CGI binary, do the following
1.Under ‘Home Directory’, ‘Virtual Directory’, or ‘Directory’, click on the ‘Configuration’ button, and then enter the App Mappings tab.
2.Click Add, and in the Executable box, type: c:\php\php.exe (assuming that you have unziped PHP in c:\php\).
3.In the Extension box, type the file name extension you want associated with PHP scripts. Leave ‘Method exclusions’ blank, and check the Script engine checkbox. You may also like to check the ‘check that file exists’ box - for a small performance penalty, IIS (or PWS) will check that the script file exists and sort out authentication before firing up php. This means that you will get sensible 404 style error messages instead of cgi errors complaing that php did not output any data.
4.You must start over from the previous step for each extension you want associated with PHP scripts. .php and .phtml are common, although .php3 may be required for legacy applications.
5.Set up the appropriate security. (This is done in Internet Service Manager), and if your NT Server uses NTFS file system, add execute rights for I_USR_ to the directory that contains php.exe.
To use the ISAPI module, do the following:
1.If you don’t want to perform HTTP Authentication using PHP, you can (and should) skip this step. Under ISAPI Filters, add a new ISAPI filter. Use PHP as the filter name, and supply a path to the php4isapi.dll.
2.Under ‘Home Directory’, click on the ‘Configuration’ button. Add a new entry to the Application Mappings. Use the path to the php4isapi.dll as the Executable, supply .php as the extension, leave Method exclusions blank, and check the Script engine checkbox.
3.Stop IIS completely (NET STOP iisadmin)
4.Start IIS again (NET START w3svc)

To disable PHP for a particular user on a Linux server , Put the following code in a .htaaccess file for that user as :
php_flag engine off

Also you can add following code for that in tag of taht particular domain in server’s httpd.conf .

php_admin_flag engine off

PEAR Is short for ‘PHP Extension and Application Repository’

PEAR is having it’s primary goal to become a repository for PHP extensions and library code. The most important goal of the PEAR project is to try to define standard coding packages that can be used be developers directoly and it is re-usable coding.
Each package is a seperate project and is having a diffreent developer team.

Packages are in the gzipped tar files with a description file inside, and installed on your server using the PEAR installer.

You can install any pear package as
———–
pear install pear-package-name
———–

You can check all the PEAR packages that are available with
————
pear list-all
————

You can check installed PEAR packages on your server as
————
pear list
————

PHP Mychat is the fantastic tool for chating.Steps to install it are as followos:

you can donaload this software from source: http://sourceforge.net/projects/phpmychat

Download phpMyChat-0.14.5.zip

1. wget http://www.tech-geeks.org/contrib/bbutts/phpChat/phpMyChat-0.14.5.zip

2 unzip phpMyChat-0.14.5.zip -d /home/username/public_html/

3. Setting up the database.
mysql_setpermission

Name of database :
Username :
Yes to password :yes
Enter Password :
Confirm Password :
Host :localhost
Yes to create :yes
Create Another :no
Exit :0
4 In browser, go to http://yourdomain.com/chat/setup.php3

5.select GO for auto setup.

6 - Fill the database

host=localhost, database name=yourdatabasename,
username= , password=
select GO to continue

7 - Fine Tuning Options.
Select the options you want and when finished
Click OK

8 - Go to admin Register Panel
Here you need to Enter a login and password to use for chat database admin.

9 - When prompted, copy and paste the generated text file into a
text editor.

10 - Edit the file with your database login and password.
(note the instructions to keep the at the end.)

11 - Save the file using the name config.lib.php3

12 - Move the file into the
/home/username/Public_html/chat/config/

13 - Now chatroom is ready at http://yourdomain.com/chat.
http://yourdomain.com/phpMyChat.php3

enjoy….with chat

PHP/FI :

In 1995 Rasmus Lerdorf first coded for PHP/FI and this gave birth for PHP. He had used simple set of Perl scripts on his home page to keep track of who were looking at his online resume. The first version of PHP was released in 1995 and was known as the Personal Home Page Tools.

PHP/FI, stood for Personal Home Page / Forms Interpreter and it included some of the basic functionality of PHP. It had Perl-like variables, automatic interpretation of form variables and HTML embedded syntax.

PHP/FI Version 2 :

Then in mid-1995 a simplistic parser engine which could understood a few special macros and a number of utilities was introduce and was renamed as PHP/FI Version 2.. Here after PHP/FI grew at an amazing pace and people started contributing their code to it.

PHP version 3 :

Then in 1997 Andi Gutmans and Zeev Suraski had changed and rewritten the parser from scratch and the new parser was borned as PHP version 3. A lot of the utility code from PHP/FI was ported over to PHP 3 and a lot of it was completely rewritten.One of the biggest strengths of PHP 3.0 was its strong extensibility features this was the reason that attracted dozens of developers to join in and submit new extension modules and helped for getting tremendous success.By the end of 1998, PHP grew to an install base of tens of thousands of users (estimated). After spending about 9 months in public testing, finally in June 1998 PHP 3.0 was officially released.

PHP 4 :

To improve performance of some complex applications, and improve the modularity of PHP’s code base it become necessary to use some new features and support from a wide variety of third party databases and APIs, as PHP 3.0 was not able to handle such complex applications at the movement. So a engine, named ‘Zend Engine’ (comprised of their first names, Zeev and Andi) was successfully designed to overcome these problems. This gave birth for PHP 4.0 This version was based on this engine, and coupled with a wide range of additional new features. This version had taken nearly 2 years for its official release ( May 2000 ).

PHP 4 had many new features as, support for many more Web servers, HTTP sessions, output buffering, more secure ways of handling user input and several new language constructs. Today several million sites uses PHP 4, and same number of developers love to code it.

PHP 5 :

After long research and development work with several pre-release versions finally PHP 5 was released in July 2004. It is also based on Zend Engine 2.0 with a new object model and dozens of other new features.

PHP 4’s version was lacking in many features as :

* MySQL extension doesn’t support the new MySQL 4.1

* client protocol

* and XML support is a hodgepodge.

Fortunately, PHP 5 improves on PHP 4 in following terms :

* Object-oriented programming

* MySQL

* XML

* PHP 5 bundles SQLite, providing developers with a database that’s guaranteed to work on all PHP 5 installations.

* PHP 5 offers a completely different model of error checking called exception handling using this you’re freed from the necessity of checking the return value of every function.

Today there are many frameworks available for the PHP programming language, and especially a lot of RAD (Rapid Application Development) frameworks which aim to make web development faster, less tedious and more organized. New and new frameworks are being released daily.

Following are the different frameworks which are hot in industry today :
Zend Framework, CakePHP, Symfony,
Seagull Framework, WACT, Prado,
PHP on TRAX, ZooP Framework,
CodeIgniter and many more……

Among these CakePHP was one of the first frameworks to port the RAD philosophy - which became so popular after Ruby on Rails.

CakePHP :
CakePHP v1.0 is now one of the most popular and intuitive solutions for PHP programming. It is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. It provides a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.

CakePHP separates itself from the rest of the PHP world by concentrating on simplicity, portability, flexibility and scalability. CakePHP does not require any additional libraries like PEAR or Propel. CakePHP includes an architecture that allows for easily extending its many built-in features through components and helpers.
CakePHP supports natively various commonly used databases like MySQL, PostgreSQL and SQLite, and uses a wrapper for database abstraction layers like AdoDb or PEAR::MDB.

Why to use CakePHP :

* Lightweight : It is one of the smallest frameworks available: less than 300KB in a .zip archive.
* CakePHP does not believe in a components/widget approach, and does not include pre-made modules to manage some common but relatively specialistic tasks (reading a RSS feed, sending email messages).
* Compatible with PHP4 and PHP5 : CakePHP applications can be run both on PHP4 and PHP5.
* Enhanced AJAX support : Cake’s pre-defined AJAX helper makes the creation of Web 2.0 AJAX interfaces extremely fast and easy.
* Suitable for any kind of project : CakePHP is an excellent choice to create almost any kind of web application, from the small personal website to the complex e-commerce solution.
* Bake : useful “bake” command line script to generate parts of the code automatically.Bake utility, is currently available as either a batch file or a PHP script.

The TIOBE Programming Community index tracks the popularity of various programming languages. The index is updated once in a month. The ratings are based on the world-wide availability of skilled engineers, courses and third party vendors. The popular search engines Google, MSN, and Yahoo! are used to calculate the ratings.

For example the PHP has moved up a spot to 4th in the ratings in the month of october

Where PHP stands currently

Position (Oct 2006): 4
Position (Oct 2005): 4
Ratings (Oct 2006): 9.863%
Delta (Oct 2005): +0.19%
Status: A

The status ‘A’ means it is a mainstream programming language language.

The full list can be found here: http://www.tiobe.com/tpci.htm

Some more interesting facts about that list: Java, C, and C++ makeup the number 1,2 and 3 respectively. F#, a Beta microsoft programming language also made it to the list at number 56.

The first official beta of F#, Microsoft’s programming language has been released 3 months ago. This variant of C# with many functional aspects is already at positioned at number 56 of the TIOBE index.

Before sending your mail, if you are using variables, you must, of course, set up the variable content beforehand. Here is some simple code for sending a message:

$to = “php@webhosting.uk.com”;
$subject = “PHP Is Great”;
$body = “PHP is one of the best scripting languages around”;
$headers = “From: webmaster@webhosting.uk.com\n”;
mail($to,$subject,$body,$headers);
echo “Mail sent to $to”;

This code will acutally do two things. Firstly it will send a message to php@webhosting.uk.com with the subject ‘PHP Is Great’ and the text:

PHP is one of the best scripting languages around

and the e-mail will be from webmaster@webhosting.uk.com. It will also output the text:

Mail sent to php@webhosting.uk.com

to the browser.

PHP stands for Hypertext Preprocessor and it is a server-side language. This means that the script is run on your web server, not on the user’s browser, so you do not need to worry about compatibility issues. PHP is relatively new but is quickly becomming one of the most popular scripting languages on the internet.

Why PHP?

You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all.we will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your Web Site. Although you can download pre-made scripts from sites like Hotscripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.

Using scripts on your Web Site allows you to add many new ‘interactive’ features like feedback forms, , message boards,guestbooks counters and even more advanced features like portal systems,advertising managers content management, etc. With these sort of things on your Web Siteyou will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.

Next Page »