Create site. How to make website
Creation date: 2012-10-05 19:48:09
Last edited on: 2012-10-05 20:00:04
This tutorial opens new course about Website creation. All tutorials about website making you can find in the Web partition (in the right menu).
In this course we well learn website creation by the point of view of coder. We will not draw website design - I don't know how to do it. We'll concentrate on programming, but not simple programming - web-programming.
Create website? No problems! Web-programming for all!
Section of programming which works with website making is called web-programming.
Web-programming is easier then simple programming.
With what technologies web-programmer has deal:
1. Some server language - usually PHP. Also it could be: Perl, Python, Ruby on Rails. We will learn how to make website with PHP.
2. Some database. We will work with MySQL. We'll need to learn SQL-language.
3. Hypertext markup language - HTML.
4. Script language for client-side - JavaScript and different modifications (JQuery, for example).
We will make complex websites which implements OOP and different templates (first of all Model-View-Controller - MVC.
Let's look at the picture, which shows standard request for page in Internet and what happens.
Now, more details.
How to make website choose soft
Now we need to choose soft to make our site.
Any website is just a bunch of text files. To make from these files website, special soft is needed. First program - web-server.
Web-servers: apache or nginx
Web-server (or http-server) could be installed on any computer. And then you can put a website on this computer.
To have a better answer on: "How to make website", we need to learn how web-server works.
Web-server receives http-requests (that's why web-server also called http-server). After receiving it sends files, which located in one of it's directories. That's all that web-server does. And that's more than enough.
Let's look at the example. Imagine that you sit in your place, don't touch anybody. And sudden! You want to know how to make website! Also imagine that you know address of this page and you can follow here. Your computer will be c1. And computer where shatalov.su is located we label c2. On the c2 installed web-server. Now let's see what happens between two computers.:
1. c1.client (any browser: Opera, Firefox, Chrome) sends http-request to the address: http://shatalov.su/en/articles/web/how_to_make_website.php
2. This http-request go to c2 by the chain of computers.
3. c2.server receives request and look up page: /en/articles/web/how_to_make_website.php
4. c2.server sends http-response.
5. c1.client receives http-response. Usually it is html-page.
Now it's time to learn what are http-request and http-response.
HTTP - Hypertext Trasfer Protocol
HTTP - Hypertext Transfer Protocol. All web-servers communicate with their clients (browsers) by HTTP. It is special "language" for text interchange.
HTTP-requests and HTTP-responses has certain form. When you print http://shatalov.su/en/articles/web/how_to_make_website.php, server where is located shatalov.su sends HTTP-request like this:
!1? GET /en/articles/web/how_to_make_website.php HTTP/1.1 Host: shatalov.su User-Agent: Opera/9.20 (Windows NT 6.0; U; en) Accept: text/html Connection: close ?1!When server received such request, it checks, has it file /en/articles/web/how_to_make_website.php and if it has, sends such response:
!1? HTTP/1.1 200 OK Date: Fri, 05 Oct 2012 10:23:28 GMT Content-Type: text/html; charset=utf-8 Connection: close Content-Length: 519 Server: Apache ... HTML-content ?1!Choosing web-server for our website
There is not much web-servers on the market. Usually you need to choose between Apache, Nginx and Microsoft Server. We will learn all these servers in next tutorials.
Connect PHP
When you install web-server it doesn't know how to work with PHP. Anyway, why we need PHP? Oh, I'll tell you.
When clean web-server receives such request:
!1? GET /page_address HTTP/1.1?1!In sends back content of requested page. And if web-server has PHP module and page has .php extension, then this request is received:
!1? GET /page_address.php HTTP/1.1?1!something interesting will happen. Web-server will find this file and give it to PHP-interpreter. If you inject in such file php code, then PHP-interpreter will process this code. So then PHP module connected to web-server, you can use PHP-scripts in web-server pages.
How to connect PHP-interpreter we will learn later. Now we have to learn about databases.
MySQL database connecting to make website
Besides web-server complex website creation needs one more program - database - to store data. We will work with MySQL. To communicate with databases we'll learn special query language - SQL. SQL requests are sent with PHP code.
Let's look at the image from the beginning:
I hope now you understand this page and imagine how to make website.
How to make website with ready solutions
Now is the most important. It's not necessary to setup all these programs by yourself. There is ready solutions. For example WAMPSERVER or Zend server. When you install such solution, on you computer will be installed web-server, PHP-interpreter and database. And you can start make website immediately
In the next tutorials we'll learn more about such solutions.
That's it.