Thread: PHP on Apache

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Nordmaling, Sweden
    Posts
    0
    Rep Power
    0

    PHP on Apache


    Hi, I need help with installing PHP on apache (wich is running on a machine with win98). I have followed all the instructions but it wont work...

    If someone knows how to configure apache for php, you can please tell me how you did it...

    /fredrik
  2. #2
  3. No Profile Picture
    PHP Ninja
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    North Carolina
    Posts
    33
    Rep Power
    17
    Your question is the equivalent of calling a mechanic on the phone and saying "My car won't start. What's wrong with it?"

    You're going to have to post a lot more detail than that - what version of Apache/PHP you're using, what system you're installing it on, what you tried to do, what error messages you got, etc.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Costa Rica
    Posts
    42
    Rep Power
    17

    help


    1) do you have this lines in your httpd.conf?

    LoadModule php4_module c:/php/sapi/php4apache.dll

    AddType application/x-httpd-php .php

    Action application/x-httpd-php "/php/php.exe"

    2) do you put the php.ini under windows folder?

    3) create a .php file under the htdocs folder with this code inside:

    <?php phpinfo(); ?>

    4) call it.
    Using win 2003 server, apache 1.3.29 with mod_ssl, and php 4.3.4
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Nordmaling, Sweden
    Posts
    0
    Rep Power
    0
    I think I just said in my first post here on wich system I was trying to get i work on and that I wanted somebody who have done that to say how he/she did it! I also said that I followed the manual but didnt get it to work... No errors or anything... It just wont run PHP scripts. But ok, I forgot to write the versions of them. Its apache 1.3.22 for win 9.x and PHP 4 (I dont really know the version on that one but its the newest downloaded directly from PHP.net.

    Im sorry if my english is so bad that you cant read it but hey, Im only 16 and lives in sweden. Im really trying

    /fredrik
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Nordmaling, Sweden
    Posts
    0
    Rep Power
    0
    The php.ini in the windows folder?! never read about that in the installation guide... I have done all the other things but I gotta test that!

    /fredrik
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Costa Rica
    Posts
    42
    Rep Power
    17

    dont worry


    Im from Costa Rica, and my mother language is spanish.

    Sometimes is hard to get that you wan,t but with a little of patience, everything will work.
    please, answer me the follow questions:

    1) Your apache server is working?

    2) i just read your new post. i will hope your test.

    Cheers.
    Using win 2003 server, apache 1.3.29 with mod_ssl, and php 4.3.4
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Nordmaling, Sweden
    Posts
    0
    Rep Power
    0
    Just tested it but it wont work... My webserver is running but when I gonna enter any *.php file it just wants me to download it. Is it a missing file extension or?

    /fredrik
  14. #8
  15. Wiking
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    3,608
    Rep Power
    30
    Xcuz the obvious question: You have of course restarted Apache?
    Seems like you're missing one of eflopez suggestions.

    If you want to take the easy way out you could always go for one of the ready-made bundles out there, like firepages bundle, which installs Apache, PHP & MySQL without hazzles...
    http://firepages.com.au/devindex.htm

    There are other similar packages out there as well...

    //NoXcuz
    UN*X is sexy!
    who | grep -i blonde | date; cd ~; unzip; touch; strip; finger; mount; gasp; yes; uptime; umount; sleep
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Nordmaling, Sweden
    Posts
    0
    Rep Power
    0
    oh, a swedish viking

    Yes, of course I have restarted it, do you think Im a loser or what (well maybe I am )?

    Im gonna try a package from the link youve posted.

    thanks btw for all help from you guys!

    /fredrik
  18. #10
  19. No Profile Picture
    The Bisifiniti
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    25
    Rep Power
    0
    That's php4ts.dll, not php.ini
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Costa Rica
    Posts
    42
    Rep Power
    17

    could be


    i have that file in the windows\system folder.

    and the php.ini in the window folder.
    Using win 2003 server, apache 1.3.29 with mod_ssl, and php 4.3.4
  22. #12
  23. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    18
    if you have all of these

    c:\windows\php.ini
    c:\path_to_php\sapi\php4apache.dll
    c:\path_to_php\sapi\php4ts.dll
    c:\path_to_php\sapi\php4ts.lib

    and you httpd.conf has a section like this

    LoadModule php4_module c:/path_to_php/sapi/php4apache.dll
    AddType application/x-httpd-php .php

    and you are accessing your scripts via

    http://localhost/somefile.php

    then it has to work

    thats assuming that you have configured the rest of the httpd.conf ? (DocumentRoot/ServerName etc)

    you could also stick the php4ts.dll & lib in windows/system32 if you wish but apache first looks for them in path_to_php/sapi/ - either way will work.

    thats php as an apache module note that ->Action application/x-httpd-php "/php/php.exe" is only needed for CGI
    resistance is no longer futile :: 423
  24. #13
  25. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    20
    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.

    JD
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org

IMN logo majestic logo threadwatch logo seochat tools logo