A.1 Finding Out What s Installed


A.1 Finding Out What's Installed

This section shows you how to find out what's already installed on your Linux server.

The Apache web server with the PHP module is usually installed with most common Linux distributions (such as, for example, most default RedHat installs). MySQL has also become a commonly-distributed component in many distributions. However, this doesn't mean you don't need to reinstall them or that you won't need to have the source code available.

There are many common distributions that have insecure, buggy, and old versions of the software. Moreover, many don't have support for some of the modules you'll need and aren't compatible with many of the advanced features discussed in this book. To test what you've got, follow the instructions in this section, and then decide whether you need to re-install your software.

The instructions in this section assume standard directories where tools are installed. For example, you'll typically find MySQL in /usr/local/mysql/, Apache in /usr/local/apache2, and Apache's document root directory is /usr/local/apache2/htdocs. However, that's not true for all distributions: for example, another common place you'll find the document root is in /var/www. If you know where the standard directories are on your system, use those instead of the ones listed in our instructions.

A.1.1 MySQL

To check whether you have MySQL installed, follow these steps. If you know that MySQL is installed and which directory it's in, but you're not sure what version you have, skip to Step 4.

  1. Get a shell prompt (by running a terminal) and log in as the root user. You can log in as root by typing su and then supplying the root user password.

  2. Let's see if you have MySQL installed. You can find the mysqld server binary by typing the following at the shell prompt (the shell prompt is represented by a %):

    % cd / % find . -name mysqld -print

    Be patient, this could take a very long time.

    This prints out a full path if it finds the server. For example, you might see:

    ./usr/local/mysql/bin/mysqld

    If it's found, make a note of MySQL's directory location as you'll need it later (in this example, it's /usr/local/mysql/). If it's not found, it isn't installed and you should skip to Section A.1.2.

  3. If you've found MySQL, in the terminal window type:

    % ps -e | grep mysql

    If you've got MySQL running, you'll see two or more lines containing references to MySQL:

      996 ?        00:00:00 mysqld_safe  1073 ?        00:00:01 mysqld

    If it is running, use Step 4; if it's not, use Step 5.

  4. To find out what version is running, use the following:

    % /usr/local/mysql/bin/mysqladmin version

    If MySQL was installed in a different directory, replace /usr/local/mysql/bin with the directory you discovered in Step 2.

    You should see output as follows:

    mysqladmin Ver 8.40 Distrib 4.0.17, for intel-linux on i686 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version          4.0.17-log Protocol version        10 Connection              Localhost via UNIX socket UNIX socket             /tmp/mysql.sock Uptime:                 8 hours 57 min 39 sec

    If you have Server version 3, you should install a new version.

    If you have Server version 4.0, you can use all of the book except some of the new features of MySQL 4.1 that are discussed in Chapter 15. At the time of writing, this is the best, most-stable choice.

    If you have Server version 4.1 or later, the material in this book that relies on the standard MySQL library can't be used at the time of writing. The standard library is discussed in Chapter 6, and the standard library supports the PEAR DB package described in Chapter 7 and used in the example application in Chapter 16 through Chapter 20. It's likely that this problem will be remedied in the future; see Appendix H for more information.

    To install or upgrade, follow the instructions in Section A.3.

  5. If MySQL isn't running, follow the instructions in "Starting MySQL" to get it started.

A.1.2 Apache and PHP

This section shows you how to check if you have an Apache web server with a PHP module, whether it's a suitable version for use with this book, and if it's currently running. If you know Apache is installed and you know what directory it's in, then skip Step 2. Follow these steps:

  1. Get a shell prompt (by running a terminal) and login in as the root user. You can log in as root by typing su and then supplying the root user password.

  2. Now, let's see if you have the Apache web server installed. You can find the httpd server binary by typing the following at the shell prompt:

    % cd / % find . -name httpd -print

    Be patient, this could take a very long time.

    This prints out a full path if it finds the server. For example, you might see:

    ./usr/local/apache2/bin/httpd

    If it's found, make a note of Apache's directory location as you'll need it later (in this example, it's /usr/local/apache2/). If it's not found, it isn't installed and you should skip to Section A.2.

  3. If you've found the web server, check whether it is running. To do this, type:

    % ps -e | grep httpd

    If you see several lines similar to the following, you have Apache running:

     1324 ?        00:00:00 httpd  1325 ?        00:00:00 httpd  1326 ?        00:00:00 httpd  1327 ?        00:00:00 httpd  1328 ?        00:00:00 httpd  1329 ?        00:00:00 httpd

    If Apache isn't running, follow the instructions in Section A.4 to get it started.

  4. Now that Apache is running, check that the Apache web server is responding to HTTP requests. Load the URL http://127.0.0.1/ in a web browser on the same machine as the web server. If Apache is serving correctly, a web page will be shown.

  5. To test the PHP module, change directory to the Apache document root:

    % cd /usr/local/apache2/htdocs

    If this directory doesn't exist, you'll need to find the document root htdocs directory elsewhere on your server. You can do this with:

    % cd / % find . -name htdocs -print

    Be patient, this might take a very long time. When you've found the directory, use cd to change directory to it.

  6. Create a file with the name phpinfo.php using a text editor. In the file, type the following, save the script, and exit the editor:

    <?php phpinfo( ); ?>

  7. You may need to make the file readable by your web server using:

    % chmod a+r /usr/local/apache2/htdocs/phpinfo.php

  8. Test the newly created PHP script by retrieving the URL http://127.0.0.1/phpinfo.php in a web browser.

    If you see a page full of information, your Apache has functioning PHP support. The version of PHP you're working with is shown at the top of the web page.

    If you have PHP4, you can use most of the material in this book with the exception of the advanced object-oriented features described in Chapter 14.

    If you have PHP5, you can use all of the material in this book.

    To check the version of Apache you're working with, look for the setting of the Server API, which is usually the fourth row in the first table. If it says Apache 2.0 Handler, you're using Apache 2. If it says Apache 1.3, you're using an older version, but that's also fine for working with this book.

  9. You now need to check whether your PHP has the support you need for MySQL. Look for the Configure Command row in the first table on the web page. Check if it includes:

    --with-mysql=/usr/local/mysql/

    If the --with-mysql directive is included and it specifies a path to your MySQL installation (as described in the previous section), your Apache and PHP has the basic setup needed to work with this book, and you can move on to the next section.

    If the directive isn't there or doesn't point to your MySQL distribution, scroll down until you find a mysql section. If you don't find it, your PHP doesn't have MySQL support and you'll need to add it. If you find the heading and you're working with MySQL 4.0, you have basic setup needed to work with this book.

    At the time of writing, if you're working with MySQL 4.1 or later, you'll need the improved MySQL library instead of the standard library. Instructions to install this on a Linux platform are in Appendix H.

    If your PHP doesn't meet the criteria above for MySQL 4.0, then you'll need to reinstall Apache and PHP by following the instructions in the Section A.4 and Section A.5. If you've previously installed Apache 2 with shared module support, you only need to reinstall PHP.



Web Database Application with PHP and MySQL
Web Database Applications with PHP & MySQL, 2nd Edition
ISBN: 0596005431
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net