13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

380 Chapter 16 <strong>Web</strong> Application Security<br />

Compile<br />

1. built server<br />

2. build <strong>PHP</strong><br />

3. set up<br />

configuration<br />

files<br />

4. configure<br />

docments<br />

Test<br />

1. verify basic<br />

operation<br />

2. run test suites<br />

3. run unit tests<br />

4. perform<br />

stress testing<br />

Deploy<br />

1. copy to server<br />

2. verify basic<br />

operation<br />

3. run test suites<br />

4. run unit tests<br />

5. perform some<br />

ad hoc testing<br />

Figure 16.2<br />

The process of upgrading server software.<br />

Browse the php.ini file<br />

If you have not yet spent much time browsing through the php.ini, now is a good time<br />

to load it into a text editor <strong>and</strong> look through its contents. Most of the entries in the files<br />

have adequate comments above them describing their use.They are also organized by<br />

feature area/extension name; all mbstring configuration options have names starting<br />

with mbstring, whereas those pertaining to sessions (Chapter 23,“Using Session<br />

Control in <strong>PHP</strong>”) have session prefixed.<br />

There are a large number of configuration options for modules that we do not ever<br />

use, <strong>and</strong> if those modules are disabled, we do not have to worry about the options—they<br />

will be ignored. For those modules we do use, however, it is important to look through<br />

the documentation in the <strong>PHP</strong> Online manual (http://www.php.net/manual) to see<br />

what options that extension offers <strong>and</strong> what the possible values are.<br />

Again, it is highly recommended that we either make regular backups of our php.ini<br />

file or write down what changes we have made so that when we install new versions, we<br />

can be sure that the correct settings are still there.<br />

The only trick to these settings it that if you choose to use legacy software written in<br />

<strong>PHP</strong>, it may very well require that register_globals <strong>and</strong>/or register_long_arrays<br />

be turned on. In this case, you must decide whether using the software is worth the<br />

security risk.You can mitigate this risk by checking frequently for security patches <strong>and</strong><br />

other updates for such software.<br />

<strong>Web</strong> Server Configuration<br />

After we are comfortable with the way we have configured the <strong>PHP</strong> language engine,<br />

we look next at the web server. Each server tends to have its own security configuration<br />

process, <strong>and</strong> we list those for the most popular two servers: Apache HTTP Server <strong>and</strong><br />

Microsoft IIS.<br />

Apache HTTP Server<br />

The httpd server tends to come with a reasonably secure default installation, but there<br />

are a few things we will want to double-check before running it in a production environment.The<br />

configuration options all go in a file called httpd.conf, which tends to be<br />

in the /conf subdirectory of the base installation of httpd (that is, /usr/local/apache/

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

Saved successfully!

Ooh no, something went wrong!