PHP
  Home arrow PHP arrow Page 5 - The Soothingly Seamless Setup of Apach...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP
By: Israel Denis Jr. and Eugene Otto
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 41
    2000-06-07

    Table of Contents:
  • The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP
  • Assumptions
  • Prerequisites
  • How it Works
  • Game Plan
  • PHP Installation (*NIX)
  • Apache
  • Testing Our Work: Is Apache working?
  • Is SSL Working?
  • Are PHP and MySQL Working Together?
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP - Game Plan
    (Page 5 of 11 )

    Our plan is first to install the MySQL server and ensure that it works. Then we'll install PHP and Mod_SSL. We will then install the Apache web server. Finally, after we have installed Apache we will test to see if PHP and Mod_SSL are functioning correctly.

    You should note that:
    • /usr/local/apache
    • /usr/local/mysql
    • /usr/local/ssl
    are the locations we installed Apache, MySQL, and Mod_SSL/OpenSSL. You can install to different directories by changing the "prefix" option before installation.

    Text that is indented and between horizontal rules is the expected input and output to and from your computer. The black text is what you enter. The red text means that you may have to change it to fit your circumstances. The green text is what the computer should display by itself.{mospagebreak title=MySQL Source Installation (*NIX)} The basic commands to unpack and install the MySQL source distribution from a `tar' file:

    Become ROOT by using su.

    # su
    Change directly to where you have the tar file. (use a temp directory. I used /tmp/download/)

    # cd /tmp/download/
    Extract the files using the following command.

    # gunzip -dc mysql-3.22.32.tar.gz | tar xvf -
    Change to the NEW directory which was created during the extract.

    # cd mysql-3.22.32
    Now you can run "configure" for the MySQL server. You can specify many options with the configure command. Type "configure --help" to see all options. We're using the "--prefix" option to specify the direct path to the installation location. Configure will check for your compiler and a couple of other things. If you have any errors you can check the config.cache file to see the errors.

    # configure --prefix=/usr/local/mysql
    After you are done with the configure. You can make the actual binaries by executing the following line (this will take a while).

    # make
    Now you are ready to install all the binaries. Run the following lines to install the binaries to the directory you specified with the configure "--prefix" option.

    # make install
    Now it is time to create the mysql tables used to define the permissions. Make sure you replace "new-password" with something of your choice, otherwise, new-password will be your root password.

    # scripts/mysql_install_db # cd /usr/local/mysql/bin # ./safe_mysqld & # ./mysqladmin -u root password 'new-password'
    You can ensure that MySQL is working by running some simple tests to verify that the server is working. The output should be similar to what is shown below:
    # BINDIR/mysqlshow -p
    Enter password:
    +--------------------+
    |Databases|
    +--------------------+
    |mysql|
    +--------------------+

    Once you install MySQL, it will automatically create two databases. One is the mysql table which controls users, hosts, and database permissions in the actual server. The other is a test database. We could use the test database, however, we want to give you a quick and simple overview of some of the command line options available with MySQL. Also, this will ensure that root has been set up with full access to the database server (i.e. root has permission to create databases, tables, etc.) We will create a "test2" database that we will use later for our testing after logging into the MySQL server.
    #mysql -u root -p
    Enter password:
    mysql> show databases;
    +--------------------+
    |Database|
    +--------------------+
    |mysql|
    |test|
    +--------------------+
    2 rows in set (0.00 sec)
    mysql> create database test2;
    Query OK, 1 row affected (0.00 sec)
    Now select the test2 database, and create a new table called tst_tbl, with the two following fields. Field 1, which is an id field which lets you know the id of the record. Essentially, this is just a row number for simplicity. The second field is a name field in which you will store name information about books. The formats for these fields are.. field 1 (id) is an integer (int) of length 3, and field 2 (name) is a character (char) field of length 50. We assign id to be the key for searching and indexing the data.

    y NOTE: MySQL commands are not case-sensitive. For example, CREATE and cReatE will be interpreted the same way. Also, remember to add a semi-colen after your commands.
    mysql> use test2;
    Database changed
    mysql> CREATE TABLE books (
    -> id int(3) not null auto_increment,
    -> name char(50) not null,
    -> unique(id),
    -> primary key(id)
    -> );
    Query OK, 0 rows affected (0.00 sec)


    Now we can verify that indeed everything is correct with the following commands.
    mysql> show tables;
    +------------------------------+
    |Tables in text2|
    +------------------------------+
    |books|
    +------------------------------+
    1 row in set (0.00 sec)

    mysql> describe books;
    +-------+-------------+------+------+----------+------------------------+
    |Field|Type|Null|Key|Default|Extra|
    +-------+-------------+------+------+----------+------------------------+
    |id|int(3)||PRI|0|auto_increment|
    |name|char(50)|||||
    +-------+-------------+------+------+----------+------------------------+
    2 rows in set (0.00 sec)


    Notice that the describe command basically "describes" the table layout. Pretty cool hey?!

    Ok, time for some really useful SQL commands, inserting and selecting data from the database. It's time to add several records to the new table. Remember these are simple records of book names, but once you have gained enough experience with SQL you can create really complex databases for some great e-commerce sites. Let's create two records of two fictitious books. The first record is the name of a book I plan on writing some day, "PHP 4 Newbies." The other is a useful book for Linux, "Red Hat Linux 6 Server", by Mohammed J. Kabir.
    mysql> INSERT INTO books (name) values('PHP 4 Newbies');
    Query OK, 1 row affected (0.00 sec)
    mysql> INSERT INTO books (name) values('Red Hat Linux 6 Server');
    Query OK, 1 row affected (0.00 sec)

    Now we can check the new records, and issue a select all command.
    mysql> SELECT * from books;
    +----+--------------------------------------+
    |id|name|
    +----+--------------------------------------+
    |1|PHP 4 Newbies|
    |2|Red Hat Linux 6 Server|
    +----+--------------------------------------+
    2 rows in set (0.00 sec)
    Great, the MySQL server is fully functional. We could continue to add records, but it makes no sense at this time. Notice how you did not have to specify the id number when you inserted the record in the database. This is because you created the id field with the auto_increment option enabled.

    Let's learn how do a quick delete. This is just for your info, remember that you can find everything you may need about the MySQL commands and the server at the mysql web site at http://www.mysql.com.
    mysql> delete from books where id=1;
    Query OK, 1 row affected (0.00 sec)
    mysql> select * from books;
    +----+-----------------------------------+
    |id|name|
    +----+-----------------------------------+
    |2|Red Hat Linux 6 Server|
    ++----++-----------------------------------+
    1 row in set (0.00 sec)
    Ok, exit MySQL and continue with the setup...you can play with MySQL later after you have completed all the installations and everything is working properly.

    More PHP Articles
    More By Israel Denis Jr. and Eugene Otto


     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway