Configuring phpMyAdmin

Posted on October 17, 2008
Filed Under PHP, SQL | Leave a Comment

Installing phpMyAdmin is simple as extracting to the www folder, but I install it in a different way, I extract phpMyAdmin in Program Files folder, and configure Apache to map /myadmin to the extracted folder, and make that only accessible by the local machine for security purpose.

1
2
3
4
5
6
7
8
9
Alias /myadmin/ "C:/Program Files/phpMyAdmin-2.11.9.2/"
 
<Directory "C:/Program Files/phpMyAdmin-3.0.0">
    Options Indexes MultiViews
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

In the phpMyAdmin copy the config.sample.inc.php to config.inc.php and change the first server configuration to authenticate via configuration file so that I don’t have to enter the user name and password again and again and hide the mysql database as I don’t really need access to that.

1
2
3
4
5
6
7
8
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['user'] = "root";
$cfg['Servers'][$i]['password'] = "xxxxxx";
$cfg['Servers'][$i]['hide_db']  = "mysql";
$cfg['Servers'][$i]['extension'] = 'mysql';

Enabling mod_rewrite in Apache 2

Posted on August 24, 2008
Filed Under Apache, PHP, Windows | Leave a Comment

Enable the mod_rewrite module by uncommenting it from the httpd.conf file.

1
LoadModule rewrite_module modules/mod_rewrite.so

Enable .htaccess configurations by setting AllowOverride to All for the DocumentRoot directory.

1
2
3
4
5
6
7
8
9
10
11
12
<Directory "C:/www">
    Options Indexes FollowSymLinks
 
    # AllowOverride controls what directives may be placed 
    # in .htaccess files. It can be "All", "None", or any 
    # combination of the keywords: 
    # Options FileInfo AuthConfig Limit
    AllowOverride All
 
    Order allow,deny
    Allow from all
</Directory>

Using mod_rewrite with PHP

Posted on August 24, 2008
Filed Under Apache, PHP | Leave a Comment

I used apache mod_rewrite to create user friendly and search engine optimized urls for sri-lankan.net. Here is how I did it.

Using the following .htaccess configuration, I redirected all the requests to index.php.

1
2
3
4
5
6
7
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And decide what to show the user by checking $_SERVER[’REQUEST_URI’]…

1
2
3
4
<?
$url = $_SERVER['REQUEST_URI'];
$parts = explode('/', $url);
?>

Change timezone of PHP

Posted on February 9, 2008
Filed Under PHP | Leave a Comment

If you wanna change the timezone of a PHP script, set the timezone environmental variable in your PHP code as simple as shown bellow.

1
2
3
<?
putenv("TZ=Asia/Colombo");
?>
  • About

    This is an area on your website where you can add text. This will serve as an informative location on your website, where you can talk about your site.