Solved

PHP weds Apache?

Posted on 2002-03-12
5
255 Views
Last Modified: 2006-11-17
Okay.
Is  it  possible to marry of Apache 1.3.23 with PHP?
If yes. Explain.
Thankyou.
Lexxwern.
0
Comment
Question by:lexxwern
5 Comments
 
LVL 3

Expert Comment

by:datibbaW
Comment Utility
You lost me. What do you mean?
0
 
LVL 4

Expert Comment

by:lokeshv
Comment Utility
yes it's possible....  :o)

Lk
0
 
LVL 12

Author Comment

by:lexxwern
Comment Utility
ok.
i have apache 1.3.23.
win xp prof.
i want to configure my webserver with php.
help.
lexxwern.
0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 100 total points
Comment Utility
Hello lexxwern,

Installing PHP on Windows
 
Here is the step by step procedure:
 
1. Download the PHP binaries
 
PHP is free and comes complete with the source code. If you are not interested in hacking the PHP source code, you can simply download the Windows binaries. They can be found at the PHP web site at:
    http://www.php.net/
 
2. Install PHP
 
Installation is actually trivial.
 
a. Create a directory for PHP on your computer. For the purposes of this article, I will assume that you created "C:\Program Files\PHP\".
 
b. Unzip the PHP archive you downloaded earlier into that directory.
 
c. Copy the file "php4ts.dll" into your Windows system directory, typically "C:\Windows\SYSTEM\" for Windows 9x and XP . If you are using Windows NT or 2000, you will need to copy it into "C:\winnt\SYSTEM32\".
 
d. Check your Windows system directory to see if a file called MSVCRT.DLL is already present (it should be). If you cannot find it (make sure you look carefully), you will need to copy MSVCRT.DLL from "c:\Program Files\PHP\dlls\" to the system directory. DO NOT DO THIS if a copy of MSVCRT.DLL already exists in the Windows system directory or you might accidentally overwrite a later version with the one that comes with PHP.
 
3. Configure PHP
 
Your "C:\Program Files\PHP" directory will contain a file called "php.ini-dist". Copy that file into your Windows directory (C:\WINDOWS in most systems) and rename it "php.ini".
 
If you want the mail() function to actually send out email when you test your own PHP scripts, you will need to edit this file.
 
Open the file using a text editor (such as Notepad). Search for "[mail function]". You should be able to find the following lines in the default configuration file:
 
    [mail function]
    SMTP = localhost ;for win32 only
    sendmail_from = me@localhost.com ;for win32 only
 
Change it to point to your SMTP server and email account. The following is just an example - change it to your actual information.
 
    [mail function]
    SMTP = mail.yourisp.com
    sendmail_from = youremail@yourisp.com
 
Note that this means that when your script tries to use the mail() function, you will need to be connected to your ISP for the function to succeed.
 
If you don't configure the above, the mail() function will simply return a fail code. This isn't a problem if your purpose is to test the script as a whole and not bother with checking the actual email sent.
 
4. Configure Your Apache Web Server
 
If you want your PHP copy to work with your own Apache server, you will need to configure it.

Make sure that your Apache is working fine before you try to configure for PHP.
 
There are two ways to configure Apache to use PHP4: one is to configure it to load the PHP interpreter as an Apache module. The other is to configure it to run the PHP interpreter as a CGI binary. This article will give instructions for both, but you should only implement one of them, either the module method or the CGI binary method.
 
a. Running PHP as an Apache Module
 
Unless you have a particular reason for running PHP as a CGI binary, this is probably the method you will want to use.
 
Search for the section of the file that has a series of commented out "LoadModule" statements. Add the following line after that block of comments:
 
    LoadModule php4_module "c:/Program Files/php/sapi/php4apache.dll"
 
Next, search for the "AddType" comment block explaining its use, and add the following lines after it:
 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
    AddType application/x-httpd-php .phtml
 
You can of course add whatever extensions you want Apache to recognise as PHP scripts. Note however that the use of ".php3" and ".phtml" is disparaged, but is necessary if you have existing scripts with those extensions.
 
b. Running PHP as a CGI binary
 
Search for the portion of the file which has the ScriptAlias section. Add the following line after the ScriptAlias for "cgi-bin":
 
    ScriptAlias /php/ "c:/Program Files/PHP/"
 
Apache needs to be configured for the PHP MIME type. Search for the "AddType" comment block explaining its use, and add the following lines after it:
 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
    AddType application/x-httpd-php .phtml
 
You can of course add whatever extensions you want Apache to recognise as PHP scripts. Note however that the use of ".php3" and ".phtml" is disparaged, but is necessary if you have existing scripts with those extensions.
 
Next, you will need to tell the server to execute the PHP executable each time it encounters a PHP script. Add the following somewhere in the file, such as after the comment block explaining "Action":
 
    Action application/x-httpd-php "/php/php.exe"
 
Note: the "/php/" portion will be recognised as a ScriptAlias and the value you set earlier will be substituted in its place.
 
5. Testing Your PHP Installation
 
Create a HTML file with the following statements:

    <HTML>
    <HEAD>
    <TITLE>PHP Version Information</TITLE>
    </HEAD>
    <BODY>
    <?phpinfo()?>
    </BODY>
    </HTML>


Save the file as "phpinfo.php" (or any other name that you fancy, but with the ".php" extension) into your Apache htdocs directory.
 
Access the file with your browser by typing
 
    http://localhost/phpinfo.php
 
You should see an entire pageful of information about your PHP setup.
 
If for some reason it does not work, you can check to see whether your PHP setup or your Apache setup is causing the problem by simply running php on the file with a command line like:
 
    "c:\program files\php\php.exe" phpinfo.php
 
The above command line assumes your phpinfo.php file is located in the current directory and drive.
 
If invoking PHP from the command line causes a large HTML file with all the PHP configuration information to be displayed, then your PHP set up is fine. The problem probably lies with your Apache configuration. Follow closely my instructions on how to install and configure Apache in my other article (see link above) as well as check the instructions on configuring it for PHP given above.


JD
0
 
LVL 12

Author Comment

by:lexxwern
Comment Utility
thanks.
Points Increased to 100. Awarded to you.

Lexxwern.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now