Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

PHP weds Apache?

Okay.
Is  it  possible to marry of Apache 1.3.23 with PHP?
If yes. Explain.
Thankyou.
Lexxwern.
0
lexxwern
Asked:
lexxwern
1 Solution
 
datibbaWCommented:
You lost me. What do you mean?
0
 
lokeshvCommented:
yes it's possible....  :o)

Lk
0
 
lexxwernAuthor Commented:
ok.
i have apache 1.3.23.
win xp prof.
i want to configure my webserver with php.
help.
lexxwern.
0
 
dkjariwalaCommented:
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
 
lexxwernAuthor Commented:
thanks.
Points Increased to 100. Awarded to you.

Lexxwern.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now