Home arrow PHP arrow Page 5 - The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP

Game Plan - PHP

The much anticipated update to our original article on getting Apache, MySQL, Mod_SSL, and PHP to work seamlessly with each other is finally here! Ever try to get Apache, Mod_SSL, PHP, and MySQL all working in harmony on the same box? It's a very difficult task, but article author Israel Denis Jr. has come up with detailed instructions for compiling all these and getting them working together seamlessly to make the killer server software system.

  1. The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP
  2. Assumptions
  3. Prerequisites
  4. How it Works
  5. Game Plan
  6. PHP Installation (*NIX)
  7. Apache
  8. Testing Our Work: Is Apache working?
  9. Is SSL Working?
  10. Are PHP and MySQL Working Together?
  11. Conclusion
By: Israel Denis Jr. and Eugene Otto
Rating: starstarstarstarstar / 41
June 07, 2000

print this article


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:

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;
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|
1 row in set (0.00 sec)

mysql> describe books;

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;
|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;
|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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: