Time for action — making sure that Apache can connect to PHP

In order to create a web application, Apache needs to be able to run the PHP code. So, we are going to check that Apache can access PHP.

  1. Use Finder to navigate to the following folder: /etc/apache2.
  2. Open the file named httpd.conf in your text editor.
  3. Look through the file, and find the following line (it should be around line 116):
    #LoadModule php5_module libexec/apache2/libphp5.so 
    
  4. Remove the hash (#) symbol that is in front of this string to uncomment this line of the config file. It's possible that your configuration file may already have this uncommented. If it does, then you don't have to change anything. Regardless, the end result should look as follows:
    LoadModule php5_module libexec/apache2/libphp5.so 
    
  5. Open Terminal.
  6. Restart Apache by running the following command:
    sudo apachectl restart 
    

What just happened?

We opened Apache's main configuration file, httpd.conf, and uncommented a line so that Apache can load PHP. We then restarted the Apache server, so that the updated configuration would take effect.