13.09.2016 Views

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

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

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

904 Appendix A Installing <strong>PHP</strong> <strong>and</strong> <strong>MySQL</strong><br />

n<br />

n<br />

Set the doc_root directive to point at the root directory from which your<br />

web server serves.This is likely to be<br />

doc_root = “c:/Program Files/Apache Software Foundation/Apache2.2/htdocs”<br />

if you are using Apache.<br />

Choose some extensions to run.We suggest at this stage that you just get<br />

<strong>PHP</strong> working; you can add extensions as needed.To add an extension, look<br />

at the list under “Windows Extensions.”You will see a lot of lines such as<br />

;extension=php_pdf.dll<br />

To turn on this extension, you can simply remove the semicolon at the start<br />

of the line (<strong>and</strong> do the opposite to turn it off). Note that if you want to add<br />

more extensions later, you should restart your web server after you have<br />

changed php.ini for the changes to take effect.<br />

In this book, you will use php_pdflib.dll, php_gd2.dll, php_imap.dll,<br />

<strong>and</strong> php_mysqli.dll.You should uncomment these lines.You may find that<br />

php_mysqli.dll is missing. If so, add it as follows:<br />

extension=php_mysqli.dll<br />

Close <strong>and</strong> save your php.ini file.<br />

4. If you are using NTFS, make sure the user that the web server runs as has permission<br />

to read your php.ini file.<br />

Adding <strong>PHP</strong> to Your Apache Configuration<br />

You may need to edit one of Apache’s configuration files. Open the httpd.conf file in<br />

your favorite editor.This file is typically located in the c:\Program Files\Apache<br />

Software Foundation\Apache2.2\conf\ directory. Look for the following lines:<br />

LoadModule php5_module c:/php/php5apache2_2.dll<br />

<strong>PHP</strong>IniDir "c:/php/"<br />

AddType application/x-httpd-php .php<br />

If you don’t see these lines, add them to the file, save it, <strong>and</strong> restart your Apache server.<br />

Testing Your Work<br />

The next step is to start your web server <strong>and</strong> test to ensure that you have <strong>PHP</strong> working.<br />

Create a test.php file <strong>and</strong> add the following line to it:<br />

<br />

Make sure the file is in the document root directory (typically C:\Program<br />

File\Apache Software Foundation\Apache2.2\htdocs; then pull it up on the browser,<br />

as follows:<br />

http://localhost/test.php

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

Saved successfully!

Ooh no, something went wrong!