Core PHP

Lesson 0: Setting up Apache for PHP

The purpose of this tutorial is to demonstrate how to set up the Apache web server to run PHP programs. To follow along with this video, you will need to have XAMPP installed. If you have not already installed XAMPP, follow the directions in our video entitled "How to install XAMPP for PHP" before continuing.

Apache Setup Procedure

  1. Open the control panel program for XAMPP. To do that, find the directory where XAMPP was installed an double-click the file entitled "xampp-control.exe" to run the control panel program.
  2. Pick a location where you would like to run PHP programs. For this video, I am going to use the directory at "D:\xoax" for PHP programs. So, I will configure the Apache web server for that location.
  3. To configure Apache, left-click the "config" button on the control panel and left-click "Apache (httpd.conf)" in the menu to open the configureation file.
  4. Scroll down the file "httpd.conf" to get to the location where "DocumentRoot" is located and change the locations for both "DocumentRoot" and the "Directory" below it. I have changed them both to "D:/xoax" to redirect the web server. Note that the slashes should be forward slashes in this case, even though they are backward slashes in the operating system folders.
  5. Now save the file "httpd.conf" and close the window.
  6. Next, we need to put a PHP program in the location. Open a text editor and enter this code:
    <?php
    
    $sHTML = <<<HTML_PAGE
    <!DOCTYPE html>
    <html>
      <head>
        <title>XoaX.net PHP</title>
      </head>
      <body>
        <h1>Welcome to XoaX.net!</h1>
      </body>
    </html>
    HTML_PAGE;
    
    echo $sHTML;
    
    ?>
        
  7. Save that text file as "index.php" in the location that was specified as DocumentRoot. For my configuration, "D:/xoax" is the location.
  8. Then start the web server in the in the control panel by clicking the "Start" button next to Apache.
  9. The web server is now ready to run the program. Enter "localhost" into a browser window, and the message "Welcome to XoaX.net!" should appear to indicate that the web server ran the PHP program.
 

© 2007–2024 XoaX.net LLC. All rights reserved.