PHP
  Home arrow PHP arrow Page 5 - The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT