Skip to main content
main-content
Top

About this book

Explore the modern concepts of client-server web applications. This book includes examples that are simple to comprehend building apps that are not much different from real-world applications. Each chapter develops a different subject, explaining the concept from A to Z, and provides a project with complete source code and configuration steps.

Chapters also include thorough coverage of the subject described and the full source code is provided with a consistently updated repo on GitHub, accounting for the frequent changes made to language versions. The chapter apps use HTML, JavaScript, AJAX, CSS, PHP, MySQL, Apache, Lighttpd, SSL/TLS, DDNS, Shell Programming, Sockets programming, tools such as Wireshark, and remote online tools for testing.

As you master each topic sequentially you'll fully understand the inner workings of the client-server apps and become confident in creating your own web-based apps. Whether you want to work on the web for fun, for school, or for work, Web-Based Projects that Rock the Class is a great place to start.

What You'll Learn

Use HTML, JavaScript, CSS, PHP, AJAX and MySQL for web projects

Set up and handle two different web servers Apache and Lighttpd

Obtain DNS and DDNS domain names

Apply the SSL/TLS protocols for HTTPS connections

Test remotely with online tools your web app – then create similar toolsWho This Book Is For

College and university students, and individuals interested in web programming. Ideally you will have basic experience in requesting a web page from the browser and understanding online services like e-shops, basic-level experience with Linux, knowledge of basic-level programming language principles, and basic knowledge of what a database is.

Table of Contents

Chapter 1. The Apache Web Server

Abstract
Most people are familiar with using a web browser. Even when they use a new browser for the first time, they are capable of visiting a web page and navigating to other sites immediately. This is because browsers usually encompass all the same handy functionalities. For example, all browsers include an address bar at the top of the window, a history option, a favorites folder, and some navigation buttons.
Christos Karayiannis

Chapter 2. Server-Side Programming with PHP

Abstract
In the beginning of the Internet, web servers dispatched only static content to the client. Soon, though, web servers became capable of dispatching dynamic content as well. To do this, a mechanism was needed that offered programming capabilities as well as the possibility of interfacing the terminal with other programs. Popular mechanisms for this purpose were the Common Gateway Interface (CGI) and later the PHP language. PHP is a recursive acronym for PHP: Hypertext Preprocessor. PHP is a general-purpose open source language that can be embedded in an HTML file or be included in its own stand-alone PHP file.
Christos Karayiannis

Chapter 3. Connecting Your Apache Server to the Internet

Abstract
In this chapter, you’ll configure your router to forward any incoming packet with a TCP port number from the web service to the computer hosting your web server. TCP port 80 is the default port number for the HTTP protocol; however, other port numbers can also be used. Another port number used often for the HTTP protocol is port 8080. This port number, sometimes called the HTTP alternate port, is used when the ISP does not allow incoming traffic for port 80.
Christos Karayiannis

Chapter 4. Obtaining a Domain Name with DDNS

Abstract
In the previous chapter, your site passed the borders of your LAN and became available to the whole Internet. URLs that were not exactly user-friendly like the following were used: http://94.64.2.196:8080/
Christos Karayiannis

Chapter 5. The Lighttpd Web Server

Abstract
Most of the web browsers used today have the same common features; therefore, it’s easy for users to make the transition from using one browser to another. This is an advantage that it is not found on the server side. Web servers are specialized programs, not expected to be used by the average user. Therefore, the graphical user interface (GUI), if the web server is supplied with one, or the commands used at the terminal for configuring and running the server may be completely different from one server to another. In this chapter, you will have the chance to use another open source web server, Lighttpd (called “Lighty”). You will run the server and identify characteristics that you used previously in Apache, like the document root and the virtual servers. Experimenting with a second server will make it easier for you to transition to a third one.
Christos Karayiannis

Chapter 6. The MySQL Database Server

Abstract
With PHP you can enable the web server to interface with any other program. One of the most commonly used applications for interfacing with a web server is a database server. With a database connection to the web server, your site can search the data of the database system and thus offer dynamic content. There is a large list of database systems to choose from. In this chapter, you will download and start using one of the most common ones, MySQL, which is a relational database that utilizes the Structured Query Language (SQL). SQL is the most widespread set of instructions used to set up and query a database system.
Christos Karayiannis

Chapter 7. Creating a Dynamic Content Web Site

Abstract
In this chapter, you’ll create a site that provides a form for the user to submit keywords to the web server, query a database, and view the results. The results page will list hyperlinks that lead to web pages related to the keywords entered.
Christos Karayiannis

Chapter 8. Implementing Secure Sockets Layer on Your Site

Abstract
In this chapter, you’ll move from using the HTTP protocol to using HTTPS, and you’ll apply the SSL/TLS protocols to implement cryptography for a secure communication between the clients and the web server of your site. The messages exchanged after this between the client and the web server will be encrypted, and it will be extremely difficult for “any man in the middle” to decrypt them. The HTTPS protocol implementation will be indicated in the protocol part of the URLs as https:// instead of http://, which was used in the previous chapters for simple HTTP connections. For this to work, the public key infrastructure (PKI) of the web server (Apache or Lighttpd) has to be configured correctly.
Christos Karayiannis

Chapter 9. Running Your Site with a Certificate from a Certificate Authority

Abstract
In this chapter, you will upgrade your site, which so far implements HTTPS with a self-signed certificate, by obtaining an SSL certificate from a certificate authority (CA). As a result, the web browser warnings about an insecure site will not appear, and instead a padlock icon, indicating secure communication, will appear on the left of the URL in the address bar of your browser. To obtain an SSL certificate, you usually need to own a second-level domain (SLD), like httpsserver in httpsserver.eu, as opposed to a name with the second-level domain owned by a DDNS company (like the names used in the previous chapters with the SLD ddns.net ). For this reason, in this chapter, you’ll learn how to obtain a domain name, and I’ll discuss the process to obtain both the domain name and the SSL certificate. The cost at the time of this writing is about $8/year for the domain name and $19/year for the SSL certificate. However, it is not required that you register to run the projects. The source code for the projects used in this and the following chapter can run with the old server configuration; you will just continue to get the browser warnings.
Christos Karayiannis

Chapter 10. Running Online Services Using PHP Sockets

Abstract
In this final chapter of the book, you will use either web server, Apache or Lighttpd, with the SSL certificate obtained in the previous chapter. You’ll start by configuring and running a DDNS client program to update your public IP address to the DDNS server provider instead of relying the IP address of your router.
Christos Karayiannis
Additional information