Level: All users
Prerequisite:
Suggested software:
Links:
First thing that we are disappointed when we "play" with .php files is that browsers don't know what to do with a Php file. As opposite to .htm or .html file, we can't just write a .php file and open it with on a Pc with our favorite browser to see result; .php files need to be launched by a server.
Then quickly we could be tired of this tedious task; work on source file, upload the file and execute file on remote server! Each time you forget a letter or type a mistake, you have to do it again! You could be angry to do that routine over and over again! But having a "Developement server" on side could be very costly; a new sturdy Pc, needed server software and licences... or having to learn Linux and all its keywords verbose!... The solution; having a Virtual Server!
Like you already imagine by seeing the above picture, you could install a software package on a Pc based either on Linux, Windows or Mac! "AMP" is an acronym describing a virtual web server consisted at minimum of these 3 main parts:
As we see, a server could remember many data in its database server and could manage many pages, but without a language to tell the server what to do, we have to do a huge lot of web pages for all infos available. Imagine for a weather server, how many web pages do we have to build to have all weather observations available: 1 page for Weather data for july 3 2012, an other for july 4 2012, for the month of july 2012, for the year 2012... and imagine that weather server start to record data in 1996!!!
That is a little what does Cumulus: Itself is a "Weather server", each file in data folder (ex. dayfile.txt, alltime.txt or july10log.txt) is a database and each .htm file contain commands (Webtags) specific to Cumulus own language, ex: <#date> for current date, <#rfallY> the total rainfall for yesterday etc. That is exactly what Php language do; it take a specific word (called a variable) and replace it by information. In example, the variable $hello could be replaced by the word "Hello" in English, "Allo" in French and "Ciao" in Italian. With languages we can do so many things... but we will see that in a future article!
Choosing its virtual server is a little like choosing a cloth, it has to fit on you. First you have to choose on which operating system you will work. Yes, Cumulus work on Windows, but you could decide to build your "Developement Pc" on Linux or Mac! You could decide to do all things on your "Weather Pc", but it is risky, as if you do mistakes, Cumulus weather data are in danger. In the "best world" Cumulus is installed alone in an old slow, but reliable, Pc!
Now, depending on O/S you have, you will build your server on a LAMP, a MAMP or a WAMP. Now, we have to choose for each part, what version do you want! Yes we can be tempted by the real last hot version! But if you build hot things with the last component version and realize that it don't work on your website because your provider don't offer this real last hot version... you'll feel angry to have losted all this time on a "too new" version! That situation happen relatively often, because many providers will wait to see if there is no problem (or security risk) with a new version before installing it.
Then, first thing to do is to know what version do you have, to do so, you have 2 choices: call your provider and ask him about exact version offered for Apache, MySQL and Php. Other way is to use a little utility you could already have, hidden somewhere in your webspace, or accessible into your web control panel; it's calling phpinfo.php. If you don't have it, simply download it on our download section. Take care to hide this utility file as it show sensitive informations about your installation... and hackers love this a lot!!
What to check?
If your provider give you this information or you have used phpinfo, you want to know 3 things:
Note that you don't need phpinfo if your provider could tell you these versions, but once in a while, you'll need other informations about specific library that phpinfo could show you; have it in hand!
Now, you know all versions important to choose your WAMP, it's time to go to Wikipedia to see a pretty complete list about Windows AMP, Linux AMP and Mac AMP availables. Don't search software with a long list of option as you won't use it. Instead check to have a living software supported by a forum with a lot of recent posts. Personally, I've choosed UwAmp not because it was the best one... but because it was the only one to support Php v5.2.17!
To help you with most popular choices, see XAMPP: this is the oldest and most seriours one, but support only the newest AMP versions. Also, WampServer is very popular and allow you to add a lot of Apache, MySQL and Php versions to fit your provider installation!
Finally, don't be impressed by using a "Web Server" on your machine, you won't need a big Pc or a huge hard disk; many Virtual web servers could run from a Usb memory stick on a Pentium IV with 4Mb RAM!
We will pass over installation as it is pretty straight, execute an install or simply unzip file in a folder on your Pc. When you execute your WAMP, it will simply add an icon in the notification zone, near the Pc clock! (We will talk about a Windows Pc in further document)
We see above 2 different interfaces from UwAmp and WAMPServer. These virtual servers are pretty similar, they have both following features:
Apache, Php and MySQL
These menus will allow you to select different version for each component and contain editable configuration options; you could change these options if you want to reproduce exactly option settings on your provider's configuration.
www site (localhost)
When managing a website something that you will heard about is a localhost. A localhost is a contraction for a "Local hosted website", then it's equivalent to the webspace offered by your provider, but into your Pc. Like on your provider's server, you could have more then one domain in your webspace; each of them will be a different folder named like you domain name, but without "www." and no ".com" (.net, org, or other).
www Folder (or www directory)
This is the web root for all your projects. Usually, you'll create folders identical to those contained on your website. But you could also separate all your projects to access them easily without having to choose menu, submenu, etc... They are usual folders, then you arrange them as you want.
phpMyAdmin
phpMyAdmin is an interface to manage all your databases. You will found in it all you need to create, modify, optimize and delete your databases. As MySQL is a database engine with it's own query language, it is not intended to be an application but only an efficient database engine, accessible by other languages. As it's name let's suppose it, phpMyAdmin is an application created in php language. We will see this application in details in a future article.
As mentionned earlier, Php is a server language as opposite to some other popular client side languages (executed on visitor's Pc), like javascript. Server language are very popular as they prepare pages before sending them to the visitors. Like this we save on bandwidth and on number of requests on web server.
Then we have to develop on a local host on our Pc to work safer and that is what we do when we take option "localhost" (or www site) on our virtual server. This option open a page in your browser, as the one shown below.
In all time, when your server is launched, you could open your localhost page by typing this adress in any browser: http://localhost You see above a sample of what is a localhost page (WAMPServer shown); this page is divided in different parts:
Your projects
Like you see in bottom red box, your projects are grouped in a section for all your projects/websites. Like stated before, this section show the content of your www folder accessible simply by clicking on button "www directory" (or "www folder").
In our sample, we have only one project "myWeatherSite", but we can decide to add many others to have one project "Gauges" for new gauges page to work on, a "Graphs" project for a planned new graph page, and so on to avoid messup your current pages with projected "on oven" pages. It's up to you to know how you want to organize your projects!
Now, you know how this folder is organized, a small little thing to know before jumping in it is that all these projects are like an external (public) website. Then when you click on "myWeatherSite", your new virtual server act exactly as if you were typing the Url in your browser (eg. www.myWeatherSite.com). First it search an index.html or index.htm page, if not found it looks for an index.php file and show it. If not found any, it simply display all the folder's content!
Now You're knowing what is a WAMP server, how to choose it and briefly how to operate it. We haven't see all components in details to keep that article simple and short. With basic knowledge you have now, you have the minimum to operate your new virtual server to have a lof of fun with it. With time, we will see each components and what to do with them... but we were enough abstract for now, it's time to play a little bit with Php!
To be followed shortly...