Installing phpMyAdmin on Linux (Tutorial Contest)

lionsgatelionsgate MemberNAT Warrior
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.5-pl1, and you can get it at;

The phpMyAdmin Home Page

Grab the download, then grab a terminal window and do the following;

Change to the directory where you saved the downloaded file , such as;

$cd mydownloads <enter>

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

$su <enter>

$password <enter>


Now, lets move the file to where we need it;

#mv phpMyAdmin-2.5.5-pl1.tar.gz /usr/local/apache/htdocs <enter>

Done, now make the Apache root directory your working directory;

#cd /usr/local/apache/htdocs <enter>

Cool, now lets unpack the file;

#tar -zxf phpMyAdmin-2.5.5-pl1.tar.gz <enter>

That will take a second, then, when the machine returns the prompt, do a directory listing;

#ls <enter>

You should see a new directory which has been created called phpMyAdmin-2.5.5-pl1, assuming you do go ahead and get rid of the original file;

#rm phpMyAdmin-2.5.5-pl1.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;

#mv phpMyAdmin-2.5.5-pl1 phpmyadmin <enter>

Cool, now you've renamed the directory to something a little easier to remember, now make that your working directory;

#cd phpmyadmin <enter>

Configuration -


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;

$cfg = ''; (Default)
$cfg = 'http://www.yoursite.com/phpmyadmin/'; (Edited)

$cfg[$i] = 'root'; (Default)
$cfg[$i] = 'your_MySQL_root_user'; (Edited)

$cfg[$i] = ''; (Default)
$cfg[$i] = '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;

#mkdir /usr/local/apache/passwd <enter>

Now, lets create the file and add an allowed user;

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

#cd /usr/local/apache/conf <enter>

And again using your favorite editor, open the file named httpd.conf and find the following section;

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>


Directly under this section add the following (assuming you used the names from the example above);

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

#/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 ! Ratings through reply is appriciated.

Comments

Sign In or Register to comment.