Friday 18 May 2012

PHP

Installing PHP5

This useful article again tells you pretty much all you need to know.
2 (or 4) simple things to do and PHP is set up on your machine.

That wouldn't make much of a blog post. So I'm going to make a simple PHP site and set up my folders and settings before I move on to installing MySQL.

Settings and Folder structure

I decided that seeing as I would be creating projects, I would have a "Projects" folder in my home folder. Just use the command line or the GUI to do this.
If you were following the article mentioned above, you need to deactivate the site "mytest" by entering the following on the command line.
sudo a2dissite mytest
Now copy one of the virtual host files I named the copy "isitmikesbirthday".
I opened up this file and changed the DocumentRoot to /home/michael/Projects/isitmikesbirthday and changed the Directory to /home/michael/Projects/isitmikesbirthday/
After that I put an entry in the hosts file. In /etc/hosts I added the following line
127.0.0.1 isitmikesbirthday.local
Then I needed to enable the site with
sudo a2ensite isitmikesbirthday
And restart apache
sudo service apache2 reload

The first PHP script

All that's left is to create and index.php file in the folder Projects/isitmikesbirthday/
And it's in that file that the magic happens. I put...

<?php
if(27 == gmdate("j") && 9 == gmdate("n"))
     echo "Yes";
else
     echo "No";
?>

No comments:

Post a Comment