Welcome, Guest
  • Author Topic: PHP 4.2.2 + Apache 2.0.39 (Windows)  (Read 111044 times)

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    PHP 4.2.2 + Apache 2.0.39 (Windows)
    « on: 07/30/02, 21:48 »
    Intro:
    This is an Update for Article:  http://www.flash-db.com/ApachePHPSQL/

    Note:  This can get a little tricky with all the new versions - In some case's you might want to think about just using Apache 1.3.x as things are a bit easier.  Feel free to post comments and questions below - as their's bound to be many on this process.


    Apache 2.0.39 Web Server
    "Apache has been the most popular web server on the Internet since April of 1996. The May 2002 Netcraft Web Server Survey found that 56% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined" - Apache HTTP Server Project. Version 2 has many new improvements for the Windows Environment which make it run more effectively than in previous versions. 2.0.39 is the latest release after a security hole was found in the 2.0.36 Apache release.

    PHP 4.2.2:
    PHP is a server side scripting language that allow you to interact with the server and write text files, insert info into a database, send email etc. PHP is extremely powerful and content rich. For Apache 2.0.39 to work with PHP I have installed the 4.2.2 Stable version as 4.2.1 does not work (only with 2.0.36 and previous versions)

    How do I install Apache 2?

    The Windows Installer version (MSI) can be downloaded from the following list: http://www.apache.org/dist/httpd/binaries/win32

    The latest Version is apache_2.0.39-win32-x86-no_ssl.msi


    • Download this file to your desktop then double click on it.
    • This will start to run through some setup options. When you get to a screen that asks for some Server Information. Use "localhost" for the Network Domain and Server Name (you can change this later). Then enter your email address in the Administrator's Email field.

    • Select the 'Typical' installation option on the next screen.
    • On the next screen select the default Destination Folder - this will be 'C:\Program Files\Apache Group\' you can choose a different folder if needed but we will be working with this one.
    • After this the setup should be complete - Hit the install button and you'll get a success message when it's complete. Click finish.
    • A couple of options should have been added to your start menu. Find the Apache option on the Start menu and then the 'Control Apache' Submenu. Press the Start option from that submenu. The apache services monitor should also have been added. With this you can easily start, stop, and restart the Apache Web server.  You'll see what looks like a feather with either a green or red stop sign on your task bar.  Green means the server is running, red means that it's stopped.

    Then open up a web browser and type in the address: http://localhost/

    You should see a default Apache page appear in your web browser. It easiest if you create a shortcut to this URL on your desktop for future use. (In the off chance that you have a different web server running such as PWS or IIS running on your computer - make sure to stop that service before starting apache).  Since two web servers can not run on the same port (80) at the same time.

    Since we want to display our own page instead of the default page - find your way to the htdocs folder located at: C:\Program Files\Apache Group\Apache2\htdocs folder. You can just delete all of the default index.html.lang files and all the other files in this directory and replace this with your own index.html page you want to display as the default. The htdocs folder is your main web directory - you can use this just as if you where uploading files to a server somewhere else. It sometimes makes things easier if you place a shortcut to this folder on your desktop as well.

    The next step is to become familiar with the httpd.conf file (Located: C:\Program Files\Apache Group\Apache2
    onf\httpd.conf). This contains a set of directives and configuration settings for your server. For the most part you will not have to change this much when just using apache for testing/development. It is however a good idea to become familiar with this file and look it over. So open it up with Notepad or your favorite text editor and have a look.

    Changing the default directory page:

    Normally the default directory page is index.html. As an intro to using the httpd.conf file we will going to change the default page apache serves when a directory is requested to something else.

    Open up the httpd.conf file (Located: C:\Program Files\Apache Group\Apache2
    onf\httpd.conf) with Notepad - then do a search for index.html. (Any line that starts with the # symbol in the configuration file is a Comment). This should bring you to a line of code that looks like this:

    DirectoryIndex index.html index.html.var

    and change to:

    DirectoryIndex index.php index.html index.htm

    Change the following line in httpd.conf which is a single line on its own:

    Change AllowOverride None to AllowOverride All
    (This allows us to use .htaccess files in any directory).


    How do I Install PHP 4.2.2 and configure with Apache 2?

    Download PHP 4.2.2 from the following List:
    http://snaps.php.net/win32/

    It MUST be the ZIP package as opposed to the installer package. The Latest stable version is:
    http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

    PHP documentation can be found at:
    http://www.php.net/manual/en/

    • After you have downloaded the zip file. Unzip all of these files to the C:\ directory. This will create a directory structure like: C:\php-4.2.2-Win32. Rename this folder to C:\PHP
    • Copy the file C:\PHP\php.ini-recommended to your windows folder: c:\winnt or c:\windows.
    • Rename this file (php.ini-recommended) to php.ini once you have placed it within the windows folder. You can rename the file with Notepad.
    • Copy the file C:\PHP\php4ts.dll and all the files in c:\PHP\dlls\ folder to your windows system folder: c:\winnt\system32 or c:\windows\system, for XP and ME it's the windows\system folder.  Getting this step right is one of the most important - and Confusing.


    Editing the PHP.ini file and the Apache httpd.conf file

    Open up the httpd.conf file that we where working with when we first installed Apache with Notepad. Look for a block of LoadModule commands (this is located near the beginning of this file). Then insert the following line right after all the the other LoadModule commands:

    LoadModule php4_module c:/PHP/sapi/php4apache2.dll
    Make sure to use forward slashes for this path instead of Back Slashes.

    Please note that you must use the php4apache2.dll and NOT the php4apache.dll. With earlier versions of PHP (before 4.2.0 and Apache 2.0 you do however use the php4apache.dll). This is an important change to keep in mind when using earlier versions of Apache with PHP.

    We have to add one last item to the httpd.conf file before we are finished.

    Add the following Line to your httpd.conf file (somewhere after the LoadModule command we just added and after the line AddType application/x-tar .tgz);

    AddType application/x-httpd-php .php .php3 .phtml .php4

    Next Edit the PHP.ini File.

    First add the 'doc_root' path (Search the file for doc_root to find it faster). Add the path to the htdocs folder. This path will be something like: C:\Program Files\Apache Group\Apache2\htdocs so that the line now looks like:

    doc_root = C:\Program Files\Apache Group\Apache2\htdocs

    Change Register Globals to Register Globals=On
    You can keep register Globals to off (which is now recommened - but it may cause some errors with scripts written before this was an option).

    Update the path to the extensions:

    extension_dir = c:\PHP\extensions

    Set the temp directory for sessions - Ensure the directory exists!:

    session.save_path = c:/temp

    That should be it. At least it should be enough so that PHP will be running in conjunction with the Apache web server. To test this try the following.

    Create a file named PHPInfo.php. Include the following in that file:

    Code: [Select]
    <?

    phpinfo();

    ?>

    Then add this file to your htdocs folder. Make sure Apache is started, open up a browser and type in the following URL

    http://localhost/PHPInfo.php

    If everything went successfully you'll see a long list of all your PHP settings and server information. When starting Apache you should also see a small note that the PHP 4.2.2 module has loaded, also when your viewing the 'Apache Service Monitor' you should see a small note at the bottom indicating that PHP 4.2.2 is running.


    Sending Email with PHP from your local computer
    This will work depending on if your ISP does not specifically restrict it. Open up the PHP.ini (c:\windows\PHP.ini) file and find the following lines that look like this:

    ; For Win32 only.
    SMTP = localhost

    ; For Win32 only.
    sendmail_from = me@localhost.com

    Change this to:

    ; For Win32 only.
    SMTP = mail.yourISP.com

    ; For Win32 only.
    sendmail_from = YourName@YourSite.com

    The SMTP setting 'mail.yourISP.com' should be the same outgoing SMTP setting you have specified in Outlook. As long as you can send and recieve email from Outlook and have the username and password set in Outlook, you'll be able to do the same with PHP. If you run your own mailserver you can use those details.

    NOTE - you need to restart the Apache server to register any changes to the httpd.conf or php.ini file.

    If you have any questions - post them below.
    « Last Edit: 09/28/02, 17:48 by Flash-db »
    Flash-DB

    Kiven

    • Seasoned Programmer
    • ***
    • Posts: 134
    • Can I pay the hosting fee without a credit cards ?
      • ICQ Messenger - 124655265
      • MSN Messenger - Forgot
      • AOL Instant Messenger - Forgot
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #1 on: 07/31/02, 06:32 »
    How can I on all the PHP functions for my local use ??? Edit the php.ini ???


    KiveN
    "Not KeviN"

    :-x  <::::::::::|=0 [/size]

    Kiven

    • Seasoned Programmer
    • ***
    • Posts: 134
    • Can I pay the hosting fee without a credit cards ?
      • ICQ Messenger - 124655265
      • MSN Messenger - Forgot
      • AOL Instant Messenger - Forgot
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #2 on: 07/31/02, 06:39 »
    And How can I set up CGI / PERL on my localhost ???

    KiveN
    "Not KeviN"

    :-x  <::::::::::|=0 [/size]

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #3 on: 07/31/02, 16:19 »
    check out www.activestate.com - they offer perl for windows and should have all the necessary "how-to" documents

    Musicman

    Kiven

    • Seasoned Programmer
    • ***
    • Posts: 134
    • Can I pay the hosting fee without a credit cards ?
      • ICQ Messenger - 124655265
      • MSN Messenger - Forgot
      • AOL Instant Messenger - Forgot
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #4 on: 08/01/02, 03:04 »
    Can I use my own url for the localhost ??? ( http://myserver  and not http://localhost )

    And the Start Stop Restart button is not working ! ( button on the taskbar )

    KiveN
    "Not KeviN"

    :-x  <::::::::::|=0 [/size]

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #5 on: 08/01/02, 16:09 »
    Hi,

    just put your own url into your hosts file

    Musicman

    sheree

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #6 on: 08/06/02, 12:50 »
    Thank you! Thank You!! :P :-*

    Darren

    • Server what's that
    • *
    • Posts: 5
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #7 on: 08/15/02, 08:45 »
    Help!

    I'm trying to get PHP and MySQL on a Mac OS 10.1 Server.  All documentations is on Windows and I can't seem to figure this out.  Is anyone out there experienced with installing these two programs on an OS X Server?

    Thanks,
    -Darren

    vesa kortelainen

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 3450
      • View Profile
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #8 on: 08/15/02, 09:45 »
    I find this for PHP : http://www.php.net/manual/en/install.macosx.php

    can't find anything for MySql + MacOs ..

    Let's keep tryin',

    Vesa

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #9 on: 08/15/02, 14:38 »
    Here are some links.

    OS X comes with these tools..  I think.  Well they will be right at home on OS X at least.

    http://developer.apple.com/internet/macosx/intro.html

    http://developer.apple.com/internet/macosx/phpappledevtools.html

    http://homepage.mac.com/macgurutemple/mysql_on_macosx.html


    I'm sure their's quite a few other links out their though.  Try a google search for it.
    Flash-DB

    Kiven

    • Seasoned Programmer
    • ***
    • Posts: 134
    • Can I pay the hosting fee without a credit cards ?
      • ICQ Messenger - 124655265
      • MSN Messenger - Forgot
      • AOL Instant Messenger - Forgot
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #10 on: 08/17/02, 08:23 »
    Apache 2.0.4.0  released   ,  what i have to change to install it ?

    KiveN
    "Not KeviN"

    :-x  <::::::::::|=0 [/size]

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #11 on: 08/17/02, 11:26 »
    I don't think you have to install anything - you don't always have to have the very latest version - you can if you want, but in most case's it's not needed.  I'm sure it's about the same as 2.0.39 if you did want to install it though.

    Flash-DB

    Darren

    • Server what's that
    • *
    • Posts: 5
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #12 on: 08/17/02, 11:47 »
    Thanks for the links...I'll give them a shot even though I've had nothing but problems installing MySQL, PHP and Apache on a mac os x server....what a pain!

    Does anyone know of an auto install that exist that would install all three of these programs....like ones that exist for windows?  Even if they aren't free....

    Thanks,
    -Darren

    Manojo

    • Server what's that
    • *
    • Posts: 30
      • View Profile
      • Email
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #13 on: 08/19/02, 11:32 »
    Hello!

    I am referring to the same tutorial posted on Flashkit. I have one proble : I am not being able to set my html page as the Default page at localhost. I of course followed all directives. Change Override None to Override All everywhere and then make a .htaccess file.

    But why is it not happening please help..

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:PHP 4.2.2 + Apache 2.0.39
    « Reply #14 on: 08/19/02, 20:20 »
    Is apache working for you - other then that problem.  Can you view any pages on localhost?

    To fix the directory index page you can add something like:

    DirectoryIndex index.html index.php

    To the Apache configuration file .httpd.  But the defualt page with a default installation is a index.html page anyways - so I'm not sure if that was the problem??
    Flash-DB