Solved

PHP weds Apache?

Posted on 2002-03-12
5
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:datibbaW
ID: 6856546
You lost me. What do you mean?
0
 
LVL 4

Expert Comment

by:lokeshv
ID: 6856629
yes it's possible....  :o)

Lk
0
 
LVL 12

Author Comment

by:lexxwern
ID: 6857054
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
ID: 6857100
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
ID: 6857127
thanks.
Points Increased to 100. Awarded to you.

Lexxwern.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Make an array show the subkey and put it in a query 2 56
Get data from two MySQL tables 6 66
Dump data from mysql to xls php 10 56
phpmyadmin memory error 55 96
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

710 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