PHP 5 under Windows
Page 1 of 3 123 LastLast
Results 1 to 15 of 33

Thread: PHP 5 under Windows

Hybrid View

  1. #1
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874

    resolved PHP 5 under Windows

    Apache 2 with PHP 5
    This guide is for any user that is running Windows (any version) and wants to run the Apache Web Server with php5.

    1. Download Required Files
      • Apache
        Go to Apache Download Section and download Apache. I'm using Apache version 2.2.8 for this tutorial.
      • PHP Files
        Go to PHP.net and download the Windows zip package 5.2.x (or whatever the current release is). Do NOT download the executable files.
    2. Install Apache
      • Run the Apache Install program [Image]
      • Input "localhost" for the network domain, "localhost" for the servername, and "root@localhost", or any email address you want, for the administrator's email address. Also keep the default selection of running apache for all users on port 80. [Image]
      • Choose a "Custom Install" option [Image]
      • Customize the settings as you feel fit. Most of them can be left as default though.
      • Install the Apache Webserver on your system
      • Make sure Apache is Running. You should see the feather logo in the system tray if you are running the ApacheMonitor program (which is the default) [Image]
    3. Set Up PHP
      • Unzip the PHP files to a directory [Image]
      • Rename php.ini-recommended to php.ini
      • Edit php.ini file as needed
        Run through the php.ini file and change any items you want. I use the error level E_ALL & E_STRICT in php5. You can change them to what you want. I also load a bunch of modules. There is no "master" setting, so fiddle with it until you get what you need / want.

        NOTE: You should set a default timezone in your php.ini file. For a listing of default timezones, please refer to the PHP manual's Timezones Page
      • Copy php5 folder to its permanent spot [Image]
        You can put this anywhere you please. Most people tend to put it at the root of C: "C:\php". You can put it wherever you like. Since PHP is a program, I'm going to stick it in "C:\Program Files (x86)".

        NOTE: I have an x86_64 system so I have both C:\Program Files and C:\Program Files (x86). There is no special difference between the directories in this case.
    4. Create httpd-php.conf file
      • Create a new file in <Apache Root>/conf/extra/ called "httpd-php.conf"
      • Inside the new file, put either block for running PHP as a CGI or running it as a Module:
        Code:
        # PHP 5 as CGI
        <Directory "C:/your/path/to/php5/">
        	Options +ExecCGI
        	Order allow,deny
        	Allow from all
        </Directory>
        ScriptAlias /php5/ "C:/Program Files (x86)/Web Server/php5/"
        AddHandler application/x-httpd-php5 .php5
        Action application/x-httpd-php5 "/php5/php-cgi.exe"
        
        
        #
        # PHP 5 as Module
        LoadModule php5_module "C:/Program Files (x86)/Web Server/php5/php5apache2_2.dll"
        
        <IfModule php5_module>
        	AddType application/x-httpd-php .php .php3 .php5
        	AddType application/x-httpd-php-source .phps
        	PHPIniDir "C:/Program Files (x86)/Web Server/php5"
        </IfModule>
      • Edit the spots in red to reflect the proper path to php5
        NOTE: If you're running Apache 2.0.x, then use php5_apache2.dll. If you're running Apache 2.2.x, then use php5_apache2_2.dll
      • Save the file
      • Edit httpd.conf and add this line (includes previously created file):
        Code:
        Include conf/extra/httpd-php.conf
    5. Add PHP to path of Windows
      • Right click on "My Computer" and select "Properties" [Image]
      • Vista Users:
        Click on the link in the left that says "Advanced System Settings" [Image]
      • Open the "Advanced" tab in the System Properties box
      • Click on the button which says "Environment Variables..." in the lower right hand corner [Image]
      • Edit the "Path" variable in the "System Variables" section [Image]
        You need to add the paths to your PHP folder separated by a semi-colon ";". For example, my addition looked like:
        ;C:\Program Files (x86)\Web Server\php5
    6. Restart the Computer
      It's best to restart the computer because windows needs to update it's Path variable since we edited it. It's optional, but until you do, some extensions may not load properly.


    That's it. By this time you should have a working copy of php5 on your system for testing. To test this, you can simply create a new document called info.php and in it put the following contents:
    PHP Code:
    <?php phpinfo(); ?>
    Now save this file to the DocumentRoot which you defined in your httpd.conf file above (by default it's "<Apache Root>/htdocs") and then browse to http://localhost/info.php and you should see a slew of information about PHP and your system spit out at you [Image]


    [ NOTE ] I removed the part about php4 concurrency because php4 is reaching EOL (End of Life) and as such, you should not be running it. You should be running php5 from now on. If you still need help running php4 concurrently, feel free to ask me; however, I won't support php4 past it's life.
    Last edited by bpat1434; 11-18-2008 at 11:48 PM.

  2. #2
    Junior Member
    Join Date
    Jul 2007
    Posts
    4

    Apache and PHP Under Vista Home Premium 64

    Hi bpat1434,

    I'm going to install Windows Vista Home Premium 64 on my computer.

    But, I'm affraid that program like Apache and PHP will not work correctly.

    In the other reply for 'installing php on vista 64', you wrote "...and Vista Ultimate 64 is my OS...".

    Does it mean that this tutorial also compatible for all Windows Vista 64 edition?

  3. #3
    Junior Member Vind1975's Avatar
    Join Date
    Jun 2015
    Location
    US
    Posts
    5

    PHP 5 under Windows

    Hi all,

    I use Yorick and Emacs under Windows, but I was unable to launch Yorick from a shell under Emacs like in Linux . Do I miss something?

    Thanks

  4. #4
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874
    Yes. Apache and PHP will run on any Vista release.

  5. #5
    Junior Member
    Join Date
    Jul 2007
    Posts
    4

    Thanks

    Thanks bpat, thats great!

    Did you also write tutorial for installing mysql and ssl for Apache 2.2?

    I'd like to read them as well.

  6. #6
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874
    Quote Originally Posted by bpat1434 :: Tutorial Above
    Go to Apache Download Section and download Apache. I'm using Apache version 2.2.4 for this tutorial.
    ^^

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Posts
    4
    Can you install PHP under windows without installing any server application? I mean only to verify your code and check if its working?

    Thanks?
    TW

  8. #8
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,918
    Can you install PHP under windows without installing any server application? I mean only to verify your code and check if its working?
    Yes, but then you would be using the command line interface, and that may not be what you want for verifying web application code to check if it is working.
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

  9. #9
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874
    With the CLI you can check for syntax errors. But just because there are no syntax errors doesn't mean the code will run as expected

  10. #10
    Junior Member
    Join Date
    Feb 2008
    Posts
    3
    You might want to make a note for the newest version of apache (2.2.8) you will need to reference "php5apache2_2.dll" instead of "php5apache2.dll". Apache will not start if it is referencing the old apache dll.

  11. #11
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874
    That's not entirely correct. The apahce 2.2.x line needs php5apache2_2.dll while the 2.0.x line will use the php5apache2.dll file. It's been this way since 2.2.0

    And I plan on revamping this soon. Probably this weekend sometime.

  12. #12
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874
    Updated the above steps with new images (finally I put them back up). Ran through them again myself and everything seems good.

  13. #13
    Junior Member
    Join Date
    Aug 2008
    Posts
    2
    i am using xampp.....i am not anle to run phpscripts...my php version is 4....it is saying something like "something wrong with installation"...can anyone help//please?

  14. #14
    NMaOtBG bpat1434's Avatar
    Join Date
    Oct 2004
    Location
    Around 255.255.255.0
    Posts
    7,874
    XAMPP is a software package, you'd have to ask support from them about installation. THis thread was for installing Apache, PHP, MySQL. Each being separate items, not installing through XAMPP or any other meta package like that.

  15. #15
    Banned
    Join Date
    Jul 2010
    Posts
    1
    Quote Originally Posted by bpat1434 View Post
    XAMPP is a software package, you'd have to ask support from them about installation. THis thread was for installing Apache, PHP, MySQL. Each being separate items, not installing through XAMPP or any other meta package like that.
    i am using xampp.....i am not anle to run phpscripts...my php version is 4....it is saying something like "something wrong with installation"...when i referred the net,it says that some path has to be changed in .conf in apache to php..i cant follow that...can anyone elaborate on that?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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