Web App Prog CH1
Web App Prog CH1
1
Everything life is like
[Please insert any programming, I guess. If you
relevant photo love something you can put
around this box] beauty into it
Setting Up Your
Development
Environment
Subtopics:-
1.1 Introducing Dynamic Web Sites
1.2 Set Up Your Development Environment
1.3 Installation Apache and MySQL
1.4 Test Your Development Environment
Today World Wide Web (WWW) is a dynamic interactive environment for transactions on
many types – commerce, research, forums and son on. In dynamic Web sites, HTML form
collect information that is used to build additional Web pages or is stored or both. If the
Web site stores information a back-end database is required. For example, most online
catalogues are database of product information. Customers select the types of product
that interest them via an HTML form and the Web page display only the requested product
information. HTML alone does not provided the functionality needed for dynamic Web sites.
The most popular dynamic Web site technology is the PHP scripting language with the
MySQL database. PHP is currently installed in over 20 million domains.
1|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
Figure 1.1: Dynamic Web SIte
PHP
PHP is a scripting language with many of the same features found in any scripting language
and syntax similar to C. PHP can output text, execute conditional actions perform repeated
actions and so on. However because PHP was developed specifically for use on Web sites,
it includes features that simplify building dynamic Web sites.
PHP is open source software which means that you can download and use it without paying
a fee. PHP runs on almost every operating system including Windows, Linux, Mac OS and
most flavour of UNIX. PHP is particularly strong in its capability to interact with database and
has built in features for working with MySQL.
PHP work in partnership with your Web server software, which is required on every Web site
to deliver Web pages to users. PHP code is embedded in HTML source files, enclosed by the
PHP tags, <?php and ?>. The Web server sends the code and returns the output to the Web
server, which in turn send the HTML code and the output from the PHP code to the browser.
The browser displays the Web page.
2|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
MySQL
MySQL is a small, fast RDBMS (relational database management system) that is popular for
use on dynamic Web sites. The term database refers to a file or group of files that contains
the information needed by your Web site. The database can contain information that you
want to display on your Web site, can store information collected from users or both.
You can download an open source version of MySQL, called the Community version, which
you can use without paying a fee. MySQL like PHP runs on almost every operating system,
including Windows, Linux, Mac OS and most flavor of UNIX.
The MySQL software consists of the MySQL server, several utility programs and some
supporting software. The MySQL server handles all your database requests. You send SQL
(structured query language) instructions called queries to the server which creates
database stores information, retrieves information or perform other operations according
to the instructions in the query.
Before you can send queries to MySQL, the server must be running and waiting for requests.
When used as a back-end database on a Web site, the MySQL server is set up so that it
starts when the computer boots and run all the time, listening continuously for queries. The
MySQL server does not need to be installed on the same computer with PHP. PHP can send
queries across a network.
PHP include functions designed specifically to access MySQL database. You use functions
to connect to the MySQL server, select a database, execute a SQL query that saves or
retrieves data, and perform other needed database operations. The PHP functions handle
the details of accessing the data in your MySQL database. You do not need to know the
details. MySQL can store very complex information. PHP can perform complicated
manipulation of data. Together PHP and MySQL can be used to build a complex and
sophisticated Web site.
3|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
PHP and MySQL Versions
Because of PHP and MySQL are open source software, new version are releases include
changes in the way the software works or the installation procedure that require changes
to your application.
A Web site is basically a collection of files, stored in a location that visitors can access from
the WWW. You can locate your Web sites on a computer provided by someone else, such
as a Web hosting company or your employer or you can install and administer the Web site
yourself on your own computer. Each solution has advantages and disadvantages. Housing
your Web site on a computer administered by someone else is much easier in term of work
and knowledge. You do not need to know how to install or administer any web site software.
You just upload your web site source file.
The disadvantage is that you lack control over your environment. The administrator of the
computer where your web site is located provides the environment that works best from his
or her point of view, which may not be the environment, you prefer.
Whether you build your Web site on someone else computer or your own, you need to set
up an environment that facilitates your development. In cases you want to build your Web
site in attest location. A site that you can view but the public cannot. You need to view the
work in progress but you do not want visitor to see you half built pages, with coding error
and design flaws. So, you need two Web sites a development site and final site where the
Web pages are available to the public.
Your test site can be located on the same computer with your public Web site or an
different computer. Many people who use a Web hosting set up a test on their own
computer, installing PHP and MySQL locally for the test Web site. Only the finished Web
pages are copied to the hosting company computer. If you locate your development test
site on the same computer with your public Web site, you can set up a subdirectory in your
Web space where you develop Web pages. You can access the URL such as
www.mywebsite.com/texsite, to test Web pages, but the test site is not available for public
access.
4|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
Select a Web Hosting Company
A web hosting company provides everything you need, including computer space and
web site software. You create the web site files and move them to the location indicated
by the web hosting company. This is the easiest way to publish a web site but you need to
choose you web hosting company wisely. Many companies provide everything you need,
including computer space and web site software. You create the web site files and move
them to the location indicated by the web hosting company. This is the easiest way to
publish a web site, but you need to choose your web hosting company wisely.
Many companies offer web hosting services for a reasonable monthly fee, which usually
depend on the resources provided. For example a web site with 1 megabyte of web space
would cost less than a web site with 20 megabyte of web space would cost less than a web
site 20 megabytes. To build a dynamic web site you need a web hosting company that
offers PHP and MySQL. The reliability of the web hosting company, the availability of
backups is important considerations. You want access to technical support when problem
arise.
Every web site needs a unique address on the web called a domain name. A system of
registering domain names ensures that no two locations use the same domain name.
Anyone can register any domain name as long as the name is not already taken. Many
web site including most web hosting company web site provide a form that you can use to
register a domain name.
Some web hosting companies assign a domain name to you, rather than allowing you to
use your own domain name. Some assign domain names that are subdomains of the
company web site, such as yourcompanyname.webhostingcompanyname.com or
webhostingcompanyname.com/yourcompanyname. In most cases, you want to find a
web hosting company that allows you to register and use your own domain name.
The installation Apache and MySQL for operating system using XAMPP. XAMPP is a free and
open source cross-platform web server solution stack package developed by Apache
Friends, consisting mainly of the Apache HTTP Server, MariaDB database, and interpreters
5|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
for scripts written in the PHP and Perl programming languages. The Apache HTTP Server,
colloquially called Apache, is the world's most used web server software. There are
interpreters for scripts written in the PHP and Perl programming languages. It is a simple,
lightweight Apache distribution that makes it extremely easy for developers to create a
local web server for testing and deployment purposes. Everything needed to set up a web
server – server application (Apache), database (MariaDB), and scripting language (PHP) –
is included in an extractable file.
XAMPP is also cross-platform, which means it works equally well on Linux, Mac and Windows.
Since most actual web server deployments use the same components as XAMPP, it makes
transitioning from a local test server to a live server extremely easy as well.
Step 3:
6|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
Step 4:
Open file that was downloaded and Install the program, and click on "Run." Accept the
default settings. A command will open and offer an initial installation prompt. Just hit the
Enter key, and accept the default settings. To simplify installation, just hit ENTER when
prompted on the command line. You can always change settings, by editing the
configuration files later.
Step 5:
When your installation is complete, exit the command window by typing x on the command line.
Step 6:
Start the Apache and MySQL components. You can also start the other components, if you
plan to use them. Verify the Apache install, by clicking on the Apache administrative link in
the Control Panel. If the verification steps are successful, XAMPP should be successfully
installed on your PC. Open a browser and enter "localhost" on your address bar. You will be
redirected to a page telling you that you've successfully installed xampp on your system.
7|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
After the XAMPP already Start and Click the administration link, open the web browser, type
localhost to check the connection between Apache and MySQL.
To check connection for MySQL, click web browser and type localhost/phpmyadmin.
After everything is installed, you can test your development by running a PHP script. A PHP
script is a text file using any editor such as:
• Notepad
• Dreamweaver
• etc.
You script must be located in your Web space. The directory and it subdirectories where
your web server expect to find the web page source files. Apache call this directory as
document root. The default web space for Apache is htdocs in the directory where Apache
is installed. To run a PHP script, your need to access the web page through your web server.
You must type the name of the script into the web browser address windows such as
localhost/foldername/filename.php. You cannot access the file by clicking File Open File
in your browser menu. If you do, the PHP script will appear as text, rather than run and
display its output.
How to test?
Start with create a new folder inside htdocs. Open a notepad and write a simple code.
Add the opening HTML code:
8|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t
<html>
<head>
<title>Testing</title>
</head>
<body>
<?php
echo “Welcome”;
?>
</body>
</html>
Click htdocs and create new folder and save code file.
Select type file as “All Files” and Encoding “UTF-8”. Your file extension is .php.
Open browser and type localhost/Folder_name. List of file will be displayed at browser. Click the
selected file and result will be display.
9|P a g e C h a p t e r 1 : S e t t i n g U p Y o u r D e v e l o p m e n t E n v i r o n m e n t