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.

Installing Apache, <strong>PHP</strong>, <strong>and</strong> <strong>MySQL</strong> Under Unix<br />

893<br />

You can check your database via the comm<strong>and</strong> line like this:<br />

# mysql -u root –p<br />

Enter password:<br />

mysql> show databases;<br />

+--------------------+<br />

| Database |<br />

+--------------------+<br />

| mysql |<br />

| test |<br />

+--------------------+<br />

2 rows in set (0.00 sec)<br />

Type quit or \q to quit the <strong>MySQL</strong> client.<br />

The default <strong>MySQL</strong> configuration allows any user access to the system without providing<br />

a username or password.This is obviously undesirable.<br />

The final compulsory piece of <strong>MySQL</strong> housekeeping is deleting the anonymous<br />

accounts. Opening a comm<strong>and</strong> prompt <strong>and</strong> typing the following lines accomplish that task:<br />

# mysql -u root –p<br />

mysql> use mysql<br />

mysql> delete from user where User=’’;<br />

mysql> quit<br />

You then need to type<br />

mysqladmin -u root -p reload<br />

for these changes to take effect.<br />

You should also enable binary logging on your <strong>MySQL</strong> server because you will need<br />

it if you plan to use replication.To do this, first stop the server:<br />

mysqladmin -u root -p shutdown<br />

Create a file called /etc/my.cnf to be used as your <strong>MySQL</strong> options file. At the<br />

moment, you need only one option, but you can set several here. Consult the <strong>MySQL</strong><br />

manual for a full list.<br />

Open the file <strong>and</strong> type<br />

[mysqld]<br />

log-bin<br />

Save the file <strong>and</strong> exit. Then restart the server by running mysqld_safe.<br />

Installing <strong>PHP</strong><br />

You should still be acting as root; if not, use su to change back to root.<br />

Before you can install <strong>PHP</strong>, you need to have Apache preconfigured so that it knows<br />

where everything is. (We come back to this topic later when setting up the Apache server.)<br />

Change back to the directory where you have the source code:<br />

# cd /usr/src<br />

# gunzip -c httpd-2.2.9.tar.gz | tar xvf -

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

Saved successfully!

Ooh no, something went wrong!