Skip navigation

Monthly Archives: May 2009

Lets learn how to enable mod_rewrite on apache2 on ubuntu linux to be able to implement SEO based links and to be able to run other .htaccess settings . TO enable mod_rewrite follow the steps as shown below.

Open your terminal window through Applications->Accessories->Terminal and type in the followg commands

1. ap2enmod rewrite

now open the /etc/apache2/sites-available/000-default

and change AllowOverride None to AllowOverride All .(this appears at around three places in the file.)

also in/etc/apache2/sites-enabled/000-default

3. Now restart your apache using /etc/init.d/apache2 restart

Now you can check for the correctness by placing a .htaccess file in the desired web root.If everything goes fine then the configurtaions are correct else please repeat the procedure again. Hope this would help you out.

Advertisements

In this post i will teach you how to install LAMP on a linux platform. I choose Ubuntu 9.04 to try with the installation.although it has also been tested on ubuntu 8.04

LAMP consist of 3 vital components 1.Apache 2.Mysql 3.PHP and in addition phpmyadmin

Apache Installation

First open the terminal console window (Applications->Accessories->Terminal). Next type in the following command

sudo apt-get install apache2

Follow the onscreen instructions and once the installation is completed type in http://localhost/ in the address bar of your browser. You should see a screes with “It Works!”. This means that the apache installtion is completed successfully.

Next ins the PHP installation.

PHP5 Installation

To install PHP5 type in the following command in the terminal window.

sudo apt-get install php5 libapache2-mod-php5

Follow the on screen instructions for the setup to complete.Once done test the php installtion by creating a php file (test.php) and placing it in the /var/www/ folder of the filesyste,. Next restart your apache using the following command

/etc/init.d/apache2 restart

Now type http://localhost/test.php in your browser address bar. If the php file is executed successfully then the php is successfully installed.

Mysql Installation

To install type in the following command in the terminal window

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Once the installtion is completed you get a window to set  the mysql roor password it looks as shown below.

mysqlroot

Now your Mysql installation is completed successfully.

We have successfully completed Installting LAMP. Now the additional and very vital tool needed for database management.phpmydmin

phpmyadmin installation

Inside the terminal window add the following command

sudo apt-get install phpmyadmin

During the installation process you will get a window asking you to choose the webserver to be used for phpmyadmin.Please select apache2 as the web server.Once done. you will have to copy the phpmyadmin folder from usr/share/phpmyadmin/ to /var/www/phpmyadmin

Once copied type in http://localhost/phpmyadmin and you get a login form . Enter the database username and password set previously and login.

If login is successfully, Then you have easily made it to the installtion. Now you have successfully installed LAMP on your Linux System.

Hope you Enjoyed reading the article and turned out to be handy. Thank you for reading.

smarty
I always had a hard time installing smarty template engine for PHP on xampp or wamp. As there are loads of articles on linux smarty installation. But I was finding it hard to find one for Windows.  Here is the detail procedure. The following article is partly adopted from http://news.php.net/php.smarty.dev/2703

1. Download smarty template engine pachake from here

2. Create a folder smarty outside www or htdocs folder and extract the content of Smarty.x.x.x tothe same  smarty folder.

for example C:\xampp\smarty

3. Now edit ypour php.ini file and edit the include library path add the location path of smarty libraries.

for example: include_path = “.;C:\xampp\smarty\libs”

4. Now we have set the library paths. Next is to set the template and cache folders.

Now create a additional smarty folder inside your www or htdocs  ( This is in different from the smarty package folder outside )  and  create two folders templates and configs inside of it.

example: C:\xampp\htdocs\smarty\templates and    C:\xampp\htdocs\smarty\configs

5. In the outside smarty folder containing the whole package create two folders templates_c and cache .

so that it reads as C:\xampp\smarty\templates_c and C:\xampp\smarty\cache.

6. Now your smarty installtion is done. to test create two scripts index.php and index.tlp . Place index.php in your root folder  and index.tpl inside of C:\xampp\htdocs\smarty\templates and copy the following code in to it.

(Please take care of the single quotes in the code below while copying it for your use)
index.php

<?php

// load Smarty library
require(‘Smarty.class.php’);

$smarty = new Smarty;

$smarty->template_dir = ‘C:/xampp/htdocs/smarty/templates’;
$smarty->config_dir = ‘C:/xampp/htdocs/smarty/config’;
$smarty->cache_dir = ‘C:/xampp/smarty/cache’;
$smarty->compile_dir = ‘C:/xampp/smarty/templates_c’;

$smarty->assign(‘name’,’memohnish!’);
$smarty->display(‘index.tpl’);

?>

index.tpl<html>
<body>
Hello, {$name}!
</body>
</html>

and run the index.php in your browser and you should see the desired output