02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

122<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

PUBLIC AND NONPUBLIC FOLDERS—WHY BOTHER?<br />

You may be asking yourself right about now, “Why put in the extra effort to create public <strong>and</strong> nonpublic<br />

folders? What's the benefit?”<br />

To answer that question, you need to know a little bit about how web servers work. A server is essentially<br />

a computer that stores files <strong>and</strong> serves selected files to a network (such as the World Wide Web) using a<br />

network identifier (an IP address or a URL mapped to an IP address). Hundreds of web sites or other<br />

applications can be hosted on one server, each in their own folder.<br />

The server grants access to outside users to these public folders, which means all the files on the folder<br />

can be accessed from the network to which the server is connected. In the case of files that contain<br />

sensitive information, this isn’t always desirable.<br />

Fortunately, files in a public folder can still access files outside of the public folder, even though the users<br />

on the network cannot. This allows you to hide your sensitive data from the rest of the world, but keep it<br />

accessible to your application.<br />

There are other ways to hide this information, but simply keeping sensitive data nonpublic is the most<br />

straightforward, surefire method of doing so.<br />

Modifying the Development Environment<br />

Because you’re using public <strong>and</strong> nonpublic folders for this application, a quick modification to your<br />

development environment is necessary: you need to point the server to your public folder, rather that<br />

the folder containing both.<br />

In this section, you’ll learn how to point your server to the public folder.<br />

■ Note You can skip this section <strong>and</strong> keep the sys folder inside the public folder without losing any functionality<br />

in the application (keep in mind that file paths will differ from those used throughout the exercises in this book).<br />

You will, however, open the application to potential security risks. It’s highly recommended that you take a minute<br />

to follow these steps.<br />

Local Development<br />

To change the document root (public folder) in a local installation, you need to modify the server’s<br />

configuration file. This book assumes Apache is being used as your server in the XAMPP stack, so you<br />

need to locate the httpd.conf file (located at /xamppfiles/etc/httpd.conf on Mac,<br />

/opt/lampp/etc/httpd.conf on Linux, <strong>and</strong> \xampp\apache\conf\httpd.conf on Windows).<br />

Inside httpd.conf, search for the DocumentRoot directive. This is where you set the path to your<br />

public folder. The file should look something like this:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!