PHP Setup and Introduction

We will cover the following:

PHP Setup


We want to manually install PHP so that we can have more control over it’s configuration and the resources that come with the downloaded version.

Installation Guides

Test for PHP


Most tutorails instruct you to write a PHP script, put a single line of PHP code in there, and then load it into your browser. There is a different way to do this and these 3 steps are not all that it takes to get a PHP script running.

  1. Test without writing a script: Open up your terminal/command prompt and try typing in php -v and press enter. You should see the following as a result if successful:
    PHP 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    
  2. Using a file:
    1. Create a text/ASCII file named index.php
    2. Put the following code in this file: <?php phpinfo(); ?>
    3. cd in your temrinal/comand prompt to the file’s directory location.
    4. Run from the command line or terminal: php -S localhost:8000 This starts a local PHP server on your local webpage.
    5. Open a browser and navigate to: http://localhost:8000/ (note: you might need https)
    6. You should be seeing a page that displays your PHP server information.