Start me up on this thing

So you'd like to start learning that PHP thing ASAP without too much hassle and you absolutely want to avoid installing Apache, MySQL and PHP and configuring these beasts to work together? That's not asking for too much if you thought I'd say that. There are solutions that offer all this software prepackaged for your system and we are about to start with one of these solutions, namely - XAMPP.

What is XAMPP?

XAMPP is a software bundle, meaning that when you install it you actually install a bunch of other software. In this case we are happy to tell you that you will get the following: Apache2 web server, MySQL database server, PHP and PHPMyAdmin among a bunch of other things.

XAMMP Installation

Installing Apache, MySQL, PHP and PHPMyAdmin on Linux

Getting that first script working

I am not a big fan of long introductions and explanations. I love to dive into things right away. So let's be straight to the point and try to run a simple PHP script on the software that we just installed. The contents of our script should be the following:

<?php
   phpinfo();
?>

This should simply output the configuration of your PHP environment as the only content of the page. This output contains many useful settings that will often be required of you for example when you ask for help in online forums. Save this script into a file named first.php. Now the location of this file is crucial, as it must be in a folder where Apache web server can find it, read it and interpret as PHP script. For XAMPP on Windows this folder is \xampp\htdocs. So the relative path of our PHP script should be \xampp\htdocs\first.php. For Linux it is most likely going to be /var/www/first.php. Make sure that Apache can read the first.php file. To make certain that it will be able to do so you can execute the following statement.

# chmod 777 first.php

Once the php script is accessible by the Apache server you should be able to load the script using the following address:

localhost/first.php

The following should also work:

127.0.0.1/first.php

You should see an output similar to this:

 

Your thoughts

No comments

Add comment

* - required field

*




*