Testing the LAMP I have on My Mac

Introduction


This post is deprecated


The previous post in this category was about installing LAMP on the Mac computer I use for development. Now, I want to play with this installation to make sure everything works as I would expect. Just to recap, here is what makes up my LAMP:

  • Mac OS X Version 10.7.3 Lion
  • Apache
  • PHP
  • MySQL
  • phpMyAdmin

F.Y.I.—An exact copy of the scripts for my live site are in the web root directory of my Mac inside a directory called web.

I will play with my development environment (on my Mac) by replicating my live site to it. Of course I don’t want to use the copy of the scripts which is already there on my Mac being used as a backup for my live site—so as to not mess them up.

My goal is to place copies of the scripts and database of my live site onto my Mac. We will refer to those as my test site.

The directory for the Test Site’s Scripts

I replicated the scripts I have on my live site by duplicating the folder called web ; and, renaming it web_aTestMyLAMP. Now web_aTestMyLAMP is in my Mac’s file system right next to web.

Modify the Database Access Script for My Test Site

There is a database access script in my live site for connecting to the live site’s database. The local database access script needs to be modified to access my local database.

I will show here what that script looks like. However, for security reasons, some things are altered.

<?php
// This script will connect to the database using the parameters
// specified in the variables below. If connecting or selecting
// fail an error message will be printed.

if (!isSet($jabib)) {
  $jabib = "";
}

if ($jabib != "random text which matches corresponding random text") {
  exit('<h2>You can not access this file!</h2>');
}

$hostname = "example.com";
$user = "name_of_database_user";
$password = "database_users_pw";
$database = "name_of_database";

if (!($link=mysql_connect($hostname, $user, $password))) {
  echo "Your PHP script says: Error connecting to database on the host.";
}
if (!mysql_select_db($database, $link)) {
  echo "Your PHP script says: Error selecting database on the host.";
}

?>

Which MySQL User?

I need to put the username and password into the new database access script.

I have two user accounts for MySQL on my Mac (root and samehrlabib.) I’ll use samehrlabib in my database access script—because that would simulate a typical shared web hosting environment.

What is the name of the database?

I need to put the name of the database into the new database access script.

As of right now I haven’t imported the database from my live site to my Mac’s database server. So, I don’t know what the database name is. I’m not familiar yet with the process of importing a database.


UPDATE:

name is: samehrlabib_aTestMyLAMP


Import The Database

The steps (done already):

  1. Log in to phpMyAdmin (PMA) as root.
  2. Create the database samehrlabib_aTestMyLAMP.
  3. Gave samehrlabib privileges over it.
  4. Switch users in PMA to samehrlabib.
  5. Imported the .sql dump file into samehrlabib_aTestMyLAMP.
  6. Inserted the new database name into the database access script.

Test the Site

Cross my fingers and just load the first page that pops up in my browser when I type the URL:

http://sameh-labibs-imac.local/web_aTestMyLAMP/
Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in Configure My Systems. Bookmark the permalink.

One Response to Testing the LAMP I have on My Mac

  1. Pingback: Notes about Setting up My LAMP | Sam's PHP How-To

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s