SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: PHP and Apache.

  1. #1
    SitePoint Member usman's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP and Apache.

    Hi everyone.

    I have used PHP with IIS and it worked fine. However, when I try to use Apache I run into problems.

    I'm using Kevin Yank's tutorial and have successfully tested PHP with IIS on win 2000 IIS 4.

    Now, I am working on another m/c win2000 with no IIS. I have successfully installed and tested Apache. I have made all the changes in the htdocs.conf file but still I am not getting the result that I want to. for testing purposes I am using the date examle.(today.php) I do save the file in htdocs folder.

    Can anyone please help me, if you need any further information please feel free to contact me. thanks.
    Best Regards,

    Usman.

  2. #2
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, how is it not working, have you got any error messages, what did you done to make PHP work with Apache, is it Apache 1 or Apache2?
    Work smarter, not harder. -Scrooge McDuck

  3. #3
    SitePoint Member usman's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I am using Apache 1. and I am following kevin's tutorial from the web. I followed his tutorials for PHP with IIS and it is working fine. but when I try with Apache (the today.php example) I don't see the date.

    I am not getting any errors.
    Best Regards,

    Usman.

  4. #4
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And I'm guessing when you view source you just see the PHP code outputted?
    Oh no! the coots are eating my nodes!

  5. #5
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a quick Apache / PHP / MySQL startup guide.
    HTH!



    Server Selection
    =================================================
    Select a computer as a server. This is the computer on which the softwares would be insatlled. Make sure that the server is connected to the other computers and centrally accessibly by the clients (or from computers). You can check this by ping the server computer. To do that issue the following command at the client computer:

    Code:
    ping xxx.xxx.xxx.xxx
    where xxx.xxx.xxx.xxx is the ip address of the server computer. For e.g.

    Code:
    ping 192.168.0.1
    if you receive a series of reply from the server, then the clients can access the server.

    Installation and Configuration
    =================================================
    Following is the procedure to Install, configure and integrate Apache, PHP and MySQL on the Windows plateform.

    1. Create / Modify the "HOSTS" file On Windows 98, goto Windows Directory and edit "HOSTS" file (without quotes), no extensions, just the file name.

    On Windows NT/2000/XP, this file is located in the "WINDOWS\system32\drivers\etc" directory. If the file doesn't exist, create it.

    Add the following line to the file

    Code:
    127.0.0.1 localhost
    xxx.xxx.xxx.xxx dpb.loc
    xxx.xxx.xxx.xxx www.dpb.loc
    where xxx.xxx.xxx.xxx is the ip address of the server computer.

    Save and close the file and issue the following command in the command prompt

    Code:
    ping dpb.loc

    if you receive a series of reply from the server, then the host configuration is complete.


    2. Install PHP
    =======================================================
    Unzip the php installation zip file to a directory such as "C:\PHP" or "D:\PHP".


    Make sure that while unzipping, you have selected the "Use folder name" (in WinZip). This option 'll automatically create the subdirectory and put the respective files automatically.

    After you have unzipped the files. Edit the "php.ini" file. If the php.ini file does't exists, then copy and rename the "php.ini-recommended" to "php.ini".

    Edit php.ini file and find the "extension_dir" entry and enter the absolute path of the directory

    Code:
    extension_dir="C:/PHP/extensions/"
    make sure you enter the directory where you installed the
    PHP and take care of the slashes while entering. Save and close the file.

    Enter the following command in the command prompt in the PHP directory


    Code:
    php -v
    If you see the the version of php printed without any errors. The PHP has been successfully installed.

    3. Install MySQL
    =======================================================
    Install the MySQL installation package. It is advised to install the MySQL in the root directory like "C:\mysql" or "D:\mysql"


    In case you are installing MySQL in directory other than "C:\mysql", create a file "my.ini" in the WINDOWS directory and add the followin line to it

    Code:
    basedir=D:/mysql
    Enter the absolute path of the directory where you installed the MySQL. (take care of entering the slashes)


    To start the mysql server, start the C:\MySQL\bin\mysqld.exe file or C:\MySQL\bin\mysqld-nt.exe on Windows NT/2000/XP. Now run C:\MySQL\bin\mysql.exe (the client). If you are successfull in connecting to the server, mysql has been successfully installed.

    4. Create a web root directory.
    =======================================================
    Create a director "C:\www" or "D:\www" as the root directory where all the sites data would be saved.

    5. Install Apache
    =======================================================
    Install the apache from the installation package. After you have installed the apache, edit the "httpd.conf" file located in the "APACHE\conf\" directory.


    If the "httpd.conf" doesn't exists, copy and rename the "httpd.conf.default" to "httpd.conf"

    Add the following line, near the LoadModule block.

    Code:
    LoadModule php4_module "D:/PHP/sapi/php4apache.dll"
    Add the following lines, near the AddType block

    Code:
    AddType application/x-httpd-php-source .phps 
    AddType application/x-httpd-php .php3 .php .phtml
    Add the following lines at the end of the file

    Code:
     
    NameVirtualHost 127.0.0.1
    NameVirtualHost xxx.xxx.xxx.xxx
    
    <VirtualHost 127.0.0.1 xxx.xxx.xxx.xxx>
    ServerName dpb.loc
    ServerAlias www*.dpb.loc
    <DocumentRoot "D:/www/dpb">
      Options Indexes FollowSymLinks +Includes +ExecCGI 
      AllowOverride None Order allow,deny 
      Allow from all 
    </Directory>
    </VirtualHost>
    where xxx.xxx.xxx.xxx is the server's ip address
    and the "D:/www/dpb" is the location of the website.

    Move the php4ts.dll and php4ts.lib files from the C:\PHP to the WINDOWS\System or WINDOWS\System32 directory.

    Copy the php.ini file from the C:\PHP to WINDOWS directory.

    Start the apache by starting the APACHE\bin\apache.exe file or from the Start Menu > Apache HTTP Server > Control Apache Server > Start

    Goto your browser and type www.dpb.loc You should see the contents of the site of the directory listing, in case the folder is empty. Your apache is running successfully.

    Testing PHP w/Apache
    =======================================================

    Create a text file and name it phpinfo.php in the
    D:/www/dpb/ folder withe the following content

    PHP Code:
    <?php phpinfo(); ?>
    Now enter the following url in the browser www.dpb.loc/phpinfo.php and you should see lots of content about the server and currect settings.
    Last edited by Amit; Jun 15, 2003 at 23:17.

  6. #6
    SitePoint Member usman's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by timnz
    And I'm guessing when you view source you just see the PHP code outputted?
    Yes, Ido see the php code as it is...
    Best Regards,

    Usman.

  7. #7
    SitePoint Member usman's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Amit...I just got your reply. I will follow your instructions and see if I can run the php on apache.

    Thanks.
    Best Regards,

    Usman.

  8. #8
    SitePoint Member usman's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Amit,

    I did everything that you had instructed and when I used www.dpb.loc I got the same page that I get when I type http://localhost. Then I tried the www.dpb.loc/phpinfo.php but this time I got the error in the title bar of the browser saying "HTTP 404 Not found". so still I am unable to run PHP on Apache....

    Could you help further or anybody else for that matter????
    Best Regards,

    Usman.

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am running apache/php as a dev server on XP Home, so I just run php as a CGI. I installed apache, mysql and php to the c:\ root using the win installer for apache and mysql and manually unpacking the php.

    Apache ver 2.0.43
    PHP ver 4.30
    MySQL ver 3.23.53-max-nt

    In C:\Apache Group\Apache2\conf\httpd.conf

    ~ line 57 ServerRoot "C:\Apache Group\Apache2"

    ~ line 228 DocumentRoot "d:/www"

    ~ line 253 <Directory "d:/www">

    Added to ~ line 745

    ScriptAlias /php/ "c:/php/"
    AddType application/x-httpd-php .php
    Action application/x-httpd-php "/php/php.exe"
    AddType application/x-httpd-php-source .phps

    Unpacked PHP to c:/php/php.exe

    Edited php.ini and placed in c:\windows

    It required no other edits or moving of files.

  10. #10
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you have placed the phpinfo.php in the D:/www/dpb folder.

    BTW which version of Apache, PHP are you using ?

    As mtjo said, try running it in CGI mode (albeit slow). If you are still unable to run it. PM me, I 'll mail you my httpd.conf file.

  11. #11
    SitePoint Member usman's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know how to run in CGI mode. But it is a good idea, I mean better if you could send me your httpd.conf file.

    Yes. I do have the phpinfo.php in C:/www/dpb folder.

    I have uninstalled Apache and PHP four times and then installed them again to make sure that I am following all the steps properly. I also checked, I mean ping php-v and it gave me the version and everything. Even Apache is running fine and gives me the success page when I type www.dpb.loc or http://localhost. However, the problem starts when I actually request the php page or for that matter any html page stored in that directory.

    Sometimes when I run the today.php example(date one) it gives the html output but not the date. So, this is another piece of information.

    Yeah, so please send me the httpd.conf file and let me see if I am able to run it this time.

    Thanks Amit. Yeah, one more thing I tried to PM u but it said there are no messages in my inbox? So, I have no idea what I should do..could you help in that regard tooo Thanks....
    Best Regards,

    Usman.

  12. #12
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, lost track of this thread.

    An updated guide is listed here http://www.digitalamit.com/article/a...hp_mysql.phtml


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •