|
Free
PHP Tutorials
|
![]() |
home |
Stay
at Home and Learn
|
|||||
PHP Tutorials |
||||||
|
Installing and Testing Easy PHP
Hopefully, you have now downloaded and installed Easy PHP. This will give you a server on your own PC (Windows users), somewhere you can test your scripts. If you haven't yet dowloaded the Easy PHP software, you can download it here: If the installation went well, you should have an new entry on your Start > All Programs menu. It should look something like this:
The newer version looks like this:
Note that the older, more stable version is 1.8. The newer version is 2.0. Pay attention to which version you have, because it matters, as you'll see below. But click Easy PHP from the menu and you'll get this popping up:
If you get a green light for the Apache traffic sign, then your server is up and running! (MySql is a database. We'll be using this in later tutorials. Don't worry about it for now.) When the Apache server is loaded up, you'll see a black letter "e" in your system tray (in the bottom right of your screen, where the clock is). When Apache is running, a red square will be flashing on and off on the letter "e". Right click to the letter "e" to see the following menu:
From here, you can stop the server, exit it, view
help files, and see the configuration pages. The Apache option on the
configuration menu is an interesting one. From here, you can change where
your PHP files are stored. When your scripts are run, they will then come
from your location, and not the default one. Look for this line:
DocumentRoot "${path}/www" To change the location, type a path to a directory of your choosing: #DocumentRoot "${path}/www" DocumentRoot "F:\myphp" In the example above, we've changed the location to a folder on our "F" drive. The hash (#) symbol before the old location means the line will be ignored. But if you're not that adventurous, then you don't need to change anything! You do, however, need to test if your PHP pages are displaying OK.
To test it out, start up your browser (Internet Explorer, Firefox, Opera,
etc). If you have version 1.8 of EasyPHP, type the following into the
address bar: http://127.0.0.1/index.php If you have version 2.0, type this instead: http://127.0.0.1/home/index.php Hit the enter key, and you should see a default index page (click to open in a new window 56K). The address 127.0.0.1, by the way, is the address of your own PC. Whenever you're testing your web pages, type these numbers first. Then type a forward slash, followed by the name of the PHP script you want to run. We'll now create a new folder in the root directory, and create a new PHP page. So, do the following:
If you have EasyPHP version 1.8, locate a folder called PHP, and double click it. You should see the following:
If you have EasyPHP version 2.0, then you need to navigate to your Program Files folder. This is usually at C:\Program Files in XP. You should then see an EasyPHP folder. Double click the folder called "EasyPHP1-8", or "EasyPHP 2.0b1", to see what's inside of it. You should see a list of files and folders. Here's the files and folders for version 2.0:
And here's the folder view from version 1.8:
The folder we're looking for is called "www", which is in both versions. This is the root folder mentioned on the index page above. Double click this folder to see the following:
For version 1.8, the index.php file that you ran in your browser should appear. This index file has now been moved to the home folder in version 2.0. So you'll just have a blank folder. But for both versions, you'll be saving all of your scripts to this directory, or folders in this directory, so it's a good idea to make a note of it. Better yet, click Favorites > Add to favorites. You'll then have a shortcut to this folder on your menu bar. To create a new folder in your www folder, do the following (in Windows):
You now have a new directory (folder) in your root directory (the www one). Copy and paste the following script into a text editor. (Something like Notepad will do, if you're a Windows user. If you've never used Notepad, click Start > All programmes > Accessories, then click Notepad.) <html> <?php phpinfo(); ?> </body> Most of the script, except one line, is just plain HTML. The PHP code just displays some information about PHP. You don't have to puzzle out what it all means. The important part is, Does it work? Save your new script to the "test" folder you created. Call the file info.php. You should now have something like this in your folder view:
If you can't see your new script in the test folder, then try again: it means you didn't save it to the correct location. The image above is for EasyPHP version 1.8. For version 2.0, only the address in the address bar will be different. To test to see if it works, type the following address into your browser, and hit the enter key: http://127.0.0.1/test/info.php The /test means "look in a folder called test". The /info.php part means "look for a file called info.php". If all went well, you should be looking at the following page: The info.php page (click to open in a new window 66K) If you saw the above page, then congratulations! Your PHP server is up and running, and you can make a start scripting PHP pages. Incidentally, another way to refer to your own PC is with "localhost". Try replacing this address: http://127.0.0.1/test/info.php with this one: http://localhost/test/info.php You should still see the same page. You can use either 127.0.0.1 or localhost, from now on - it's up to you. We'll assume that everything is now up and running, though. If it's
not, click "Move on to the Next Part" below, for some troubleshooting.
If it is, click "Back to the PHP Contents Page". <-- Back One Page Move on to the Next Part --> |