2004-04-02, 06:39 PM
INSTALLING phpMyAdmin
OK, lemme add a bit more for phpMyAdmin, nice little program written in PHP to admin your new mysql databases..
First things first, we need to get the latest version of phpMyAdmin, at the time this tutorial was written the latest stable version was 2.5.6, and you can get it at;
The phpMyAdmin Home page
OK open a terminal/console window..
Change to the directory where you saved the downloaded file , such as;
Code:
cd /home/square/downloads <enter>
okay, now we need to move the file to the root directory of your Apache webserver, which is usually /usr/local/apache/htdocs, also, root usually owns the Apache directory structure so you'll need to do the rest as root, so;
Code:
su <enter>
Note: no dash needed, THIS time only.
Enter your root pass then press enter.
Now, lets move the file to where we need it;
Code:
mv phpMyAdmin-2.5.6.tar.gz /usr/local/apache/htdocs <enter>
Note: you may want to su - now to grab roots profile, if you think you'll need it.
Now make the Apache root directory your working directory;
Code:
cd /usr/local/apache/htdocs <enter>
Now lets unpack the file;
Code:
tar -zxvf phpMyAdmin-2.5.6.tar.gz <enter>
That will take a second, then, when the machine returns the prompt, do a directory listing;
Code:
ls <enter>
You should see a new directory which has been created called phpMyAdmin-2.5.6, assuming you do, go ahead and get rid of the original file;
Code:
rm phpMyAdmin-2.5.6.tar.gz <enter>
Now, the new directory name is a bit long, and definatley not something you want to type in all the time, so lets make it easier;
Code:
mv phpMyAdmin-2.5.6 phpmyadmin <enter>
Cool, now you've renamed the directory to something a little easier to remember, now make that your working directory;
Code:
cd phpmyadmin <enter>
CONFIGURING phpMyAdmin
Now, what we need to do is edit the config.inc.php file so it works with your setup. So using vi, or whatever your favorite editor happens to be, open config.inc.php, find the following lines, and edit them as appropriate for your setup;
Code:
...
$cfg['PmaAbsoluteUri'] = ''; (Default)
$cfg['PmaAbsoluteUri'] = 'http://www.yoursite.com/phpmyadmin/'; (Edited)
$cfg['Servers'][$i]['user'] = 'root'; (Default)
$cfg['Servers'][$i]['user'] = 'your_MySQL_root_user'; (Edited)
$cfg['Servers'][$i]['password'] = ''; (Default)
$cfg['Servers'][$i]['password'] = 'your_password'; (Edited)
...
Thats it, save the file and close it.
Now, lets see if it works, open a browser and point it to phpMyAdmin by using your site info such as www.yoursite.com/phpmyadmin, or, localhost/phpmyadmin if you are only working locally. If all is well you should see the welcome screen for phpMyAdmin !, if you don't, then check your logs and remember, Google is your friend. If you see a page full of PHP errors, make sure you used the correct username and password when you edited the lines mentioned above.
Now, knowing what this cool program is capable of, its probably not something you want just anyone to be able to access, luckily we can take care of that very easily using Apache 's authentication process, so lets do it !
Still as root make a directory to store the password file we will be creating;
Code:
mkdir /usr/local/apache/passwd <enter>
Now, lets create the file and add an allowed user;
Code:
/usr/local/apache/bin/htpasswd -c /usr/local/apache/passwd/authpass myphp <enter>
htpasswd will prompt you for the password you would like to assign to this user, once entered, it will create the file authpass and populate it with the information for the user called myphp. You can use whatever names you like, this is only an example.
Now the final step, change to your Apache configuration directory;
Code:
cd /usr/local/apache/conf <enter>
And again using your favorite editor, open the file named httpd.conf and find the following section;
Code:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Directly under this section add the following (assuming you used the names from the example above);
Code:
<Directory "/usr/local/apache/htdocs/phpmyadmin">
AuthType Basic
AuthName "myphp"
AuthUserFile /usr/local/apache/passwd/authpass
Require user myphp
</Directory>
Thats it, save the file and close it, then restart Apache by issuing the following command;
Code:
/usr/local/apache/bin/apachectl restart <enter>
Perfect, now fire up your browser again and point it back to your phpMyAdmin site, this time you should be prompted for a username and password before being allowed access to the site. Enter the required information, and you are in business !.
That brings us to the end of this tutorial, hopefully you found this information helpful, and Good Luck !
Enjoy
Square@Efnet!#Redhat