php and apache installation tutorial

Upload: olga-anastasiadou

Post on 14-Apr-2018

240 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 PHP and Apache Installation Tutorial

    1/16

    PHP and Apache Installation Tutorial

    I have lost many hours of sleep because of not being able to set up PHP and Apache. I

    have missed homework deadlines, fallen asleep in class, accidentally eaten an onion,

    and much worse. Here is my attempt to help you guys sleep at night with a very quick

    and easy PHP and Apache installation guide. (This is forWindows ONLY. I dont

    know anything about linux or mac, Im sorry. Im using vista 32 for this tutorial)

    To make sure this works, Ive uninstalled my webserver, and Ill be installing it right

    along side you.

    UPDATE:

    Although this installation is for Apache 2.2.14 and PHP 5.3.1, Ive personally

    confirmed this exact installation guide works for Apache 2.2.17, 2.2.19 and PHP

    5.3.3, 5.3.6.

    UPDATE: Windows 7 Users

    Ive verified that this setup works for Windows 7 Ultimate 64 Bit.

    General Rule of Thumb

    If you have a choice between installing everything manually or using a packaged

    installer to do it all for you,

    ALWAYS ALWAYS INSTALL IT MANUALLY!

    So far, the packaged installers are always missing files, and the configurations arecompletely screwed up. Although the task of manual installation with zip files seems

    extremely daunting, its actually MUCH easier to work with. And besides, youve got

    someone to walk you through the process

    Also, take note of which direction the slashes are facing when I tell you what to type

    in. That is also extremely important.

    The Order of Business

    ApachePHP

    Installing Apache Webserver

    In this case, we get to use an MSI installer. Setting up Apache and MySQL are the

    easy parts. Its setting up PHP that made me lose all that precious sleep.

  • 7/30/2019 PHP and Apache Installation Tutorial

    2/16

    Step 1)Make a folder called webserver on your C:\ drive.

    Step 2)Visit The Apache Download Page. The version I will be installing in this

    tutorial is 2.2.14. Scroll down until you see

    Win32 Binary including OpenSSL 0.9.8k (MSI Installer) and then click the

    download link right beside it.

    http://httpd.apache.org/download.cgihttp://httpd.apache.org/download.cgi
  • 7/30/2019 PHP and Apache Installation Tutorial

    3/16

    Step 3)After the installation file has finished downloading, run it. Accept all the terms

    and whatnot, but stop when you get to the server information.

    Step 4)For both the Network Domain and Server Name, type in localhost. For the

    email just put your email. I also have for all users , on Port 80, as a service selected.

    Click next.

  • 7/30/2019 PHP and Apache Installation Tutorial

    4/16

    Step 5)Select Custom Install and click next.

    Step 6)Youll notice a red X by Build Headers and Libraries. Click the dropdown

    menu by the X and select This feature will be installed on local hard drive

    Step 7)Click on Apache HTTP Server 2.2.14 on top and make sure its highlighted.

    This is to make sure when we specify our installation location in the next step, we

    arent just specifying a component of the webserver; we want to move the WHOLE

  • 7/30/2019 PHP and Apache Installation Tutorial

    5/16

    thing.

    Step 8 )Click on change to bring up the window to change the installation path.

  • 7/30/2019 PHP and Apache Installation Tutorial

    6/16

    Step 9)In the folder name text box, type in C:\webserver, and click Ok. Then click

    next and begin the installation.

    Step 10)After the installation has completed, go into a browser and type in localhost

    as the URL. If it the installation workedwell, Apache will tell you.

    That wasnt so bad! Now on to the sleep depriving monster

    PHP

    These steps will help you install PHP onto your webserver. We will be using manual

    installation for this.

    Step 1)Visit The PHP Downloads Page. The version of PHP Ill be installing is PHP

    5.3 (5.3.1). Download the THREAD SAFE zip file.

    http://windows.php.net/download/http://windows.php.net/download/
  • 7/30/2019 PHP and Apache Installation Tutorial

    7/16

    Step 2)After the download has finished, extract the files to C:\webserver\php

    Step 3)Locate the PHP folder and open it. Look for a file called php.ini-development.Once you have found it, rename it to php.ini Windows will tell you that changing the

    file extension may cause it to become unusable. Change it anyway.

    Step 4)Open up php.ini in notepad.

  • 7/30/2019 PHP and Apache Installation Tutorial

    8/16

    Step 5)Do a search (CTRL+F) for the phrase doc_root (omit quotations). After the

    = sign, type in C:\webserver\htdocs (INCLUDE quotes). Your text file should look

    like this.

    Step 6)Scroll down until you see

    ; Directory in which the loadable extensions (modules) reside.

    ; http://php.net/extension-dir

    ; extension_dir = ./

    ; On windows:

    ; extension_dir = ext

    Not too far below where we just were. Delete the semicolon in front of the line

    ; extension_dir = ext

    Then replace ext with C:\webserver\php\ext

    Your file should resemble this.

  • 7/30/2019 PHP and Apache Installation Tutorial

    9/16

    Step 7)Save and Close the php.ini file. Now go back to the C:\webserver directory.

    Open up the conf file.

  • 7/30/2019 PHP and Apache Installation Tutorial

    10/16

    Step Open the httpd.conf file with notepad. Copy and paste the following to the top

    of the file

    ?

    1

    2

    3

    LoadModule php5_module "C:/webserver/php/php5apache2_2.dll"AddType application/x-httpd-php .phpPHPIniDir "C:/webserver/php"

    This tells the webserver what files to load for php and where to locate the php

    configuration file.

    Make sure a # does not appear until after the block of text you have pasted.

    http://www.vertstudios.com/blog/php-apache-installation-tutorial/http://www.vertstudios.com/blog/php-apache-installation-tutorial/
  • 7/30/2019 PHP and Apache Installation Tutorial

    11/16

  • 7/30/2019 PHP and Apache Installation Tutorial

    12/16

    Step 12)This step will be composed of many steps.

    A) Open My Computer and click System Properties at the top. (If you do not see that

    option, you can also right click on My Computer and click Properties)

    B) Click Advanced System Settings

  • 7/30/2019 PHP and Apache Installation Tutorial

    13/16

  • 7/30/2019 PHP and Apache Installation Tutorial

    14/16

    C) Click Environment Variables

    D) Under System Variables (The lower half of the screen), scroll down until you see

    the variable named Path. Click it and press Edit.

    E) After the last semicolon in the variable value box, copy and paste

    C:\webserver\php; (Include the ending semicolon)

  • 7/30/2019 PHP and Apache Installation Tutorial

    15/16

    Youre done! Now its time for testing.

    Testing PHP and Apache

    Be sure to restart your apache server. You can do this by right clicking on the apache

    icon in the system tray and clicking Open Apache Monitor (Or you can access the

    apache monitor from your Programs into the start menu). Select apache 2.2 and clickrestart. If you do not restart your webserver, PHP will not work until you restart your

    computer.

    Open up notepad, and paste this in:

    ?

    1

    Save the file as phpinfo.php in the C:\webserver\htdocs directory.

    http://www.vertstudios.com/blog/php-apache-installation-tutorial/http://www.vertstudios.com/blog/php-apache-installation-tutorial/
  • 7/30/2019 PHP and Apache Installation Tutorial

    16/16

    Now open up your browser and type in localhost/phpinfo.php into the URL bar. Do

    NOT Type in C:\webserver\htdocs\phpinfo.php They are NOT treated the same way

    even if the path leads to the same file.

    If youve followed everything correctly, you should see a screen full of your php

    information. This indicates that you can now perform server-side operations such as

    the execution of php scripts.

    Please let me know if there are any errors with this tutorial, or if you have any

    questions. I want to make sure this is just about perfect so that people dont have to

    spend days and days trying to configure their first webserver. This whole process

    turned me off to learning php for a few months because I had already spent so much

    time failing to set up apache.

    I will cover how to install and configure mysql, pear, and phpMyAdmin in an

    upcoming post.