Sunday 3 June 2012

Smarty Template Installation

Smarty Template Step By Step Tutorial

I had a hard time installing smarty template engine for PHP on Windows. Here is the detail/simple procedure I found after a lots of testing. Basically installing Smarty is simple but no one had given prerequisite for installation. I feel PHP and Wamp Server installation as the prerequisite for Smarty. Once your PHP and Wamp is ready your job is very simple with smarty.

Note: Before installing smarty template install PHP and Wamp Server for details check my post for PHP and Wamp  with out  proper installation of PHP and Wamp Server Smarty wouldn't provide the desired results.
  1. Prepare directory for practice, example D:\wamp\www\test\smarty (it is must that you install wamp on D or E colon in your windows 7 Machine).
  2. Download file Smarty Template. You can download from their site at smarty.php.net. Place within practice directory. Thus, we will get (example), www\test\smarty\Smarty-3.1.8.tar.gz
  3. Extract the smarty compressed file. we will get folder named "Smarty-3.1.8.".
  4. Rename that folder to"Smarty".
  5. Create two folders named: template and templates_c. Now, you get structure like this:

we try to test it. We want to create a page to show simple hello text. Let's do it.

WAMP Server Installation Guide for Windows 7 32/64 Bit Machine

WAMP (Windows, Apache, mySQL, PHP) is all in one package, which installs the basic programs, you will need to get a localhost running and to be able to build and run PHP scripts.

WampServer Official Site

This awesome server can be found for download at official web page WampServer. Let’s Run through the Installation first and then I’ll go in to detail about the administration.

Step 1

You will find two options for the selection of WampServer for your windows 7 after clicking on
Download link at the main navigation of WampServer official site.









  • Download WampServer 2.2E (64 bit)
  • Download WampServer 2.2E (32 bit)

  • My windows 7 is 32 bit and PHP version is 5.4, so I will proceed with the download of WampServer 2.2 E 32 bit version.
    Note: select wamp server based on the PHP Version


    Step 2:

    Click on Save button, WampServer is starting to download after clicking on the save button. You can save WampServer file in any location in your hard drive. In case of this installation, the default downloads folder is chosen.


    Step 3

    Downloading of WampServer 2.2E  is complete, and you will notice WampServer icon in your chosen location for download. In my case, the icon is seen in the downloads folder.


    Step 4

    It is the time to install WampServer on our machine. Double click on the downloaded exe.You will receive a Security Warning after opening WampServer file. It is absolutely normal to run WampServer setup on windows.


    Step 5

    You will see a standard setup wizard of windows after clicking Run button on security warning dialog.


    Step 6

    You have to agree the license of WampServer before selecting installation destination at your windows machine.

    Step 7

    It is very important step of WampServer installation. I will recommend to install WampServer in the drive other than Windows 7 installation. For example, Suppose your Windows 7 is installed in C drive , you should install WampServer in D, E or any other location in hard drive other than C drive.
    I am going to install WampServer in D drive. Now you can click on Next button after selecting installation location for WampServer



    Step 8

    When you click on the Next button then a Select Additional Tasks dialog will appear on your screen. You can check following options (if needed),
    • Create a Quick Launch icon
    • Create a Desktop icon
    In my case, I went with the defaults (checked state).
    You will be at “Ready to Install” window after clicking Next button in the below dialog.



    Step 9

    Setup is now ready to begin installing WampServer on your computer. Click on Install button to start installation of WampServer


    Step 10

    Now your WampServer is starting to install in your computer.


    Step 11

    You will receive a dialog for choosing your default browser for WampServer. You can choose your favorite browser for WampServer as default, or simply click “Open” if you are not sure about the installation or executable files of your favorite browser. WampServer will choose “Internet Explorer” as default choice.


    Step 12

    WampServer installation has completed now and setup will guide you for configurations in the next steps.


    Step 13

    Now, you are in SMTP server configuration dialog. You can specify the SMTP server and the address email to be used by PHP when using the function mail(). I will recommend the following values,
    • SMTP: localhost
    • Email: Your email address.
    Click “Next” after putting the values, relevant to you, for the installation final dialog.





    Step 14

    You have successfully installed WampServer  along with Apache, MySql, PHP, phpMyAdmin and SqlBuddy in your computer.
    Click “Finish” to start WampServer along with other services. Leave “Launch WampServer 2 now” check-box checked to start WampServer automatically after installation.


    Step 15

    Now you can see WampServer icon on the taskbar. WampServer icon has three color states.
    • Red
    • Amber
    • Green
    Red:
    WampServer red icon indicates that WampServer is Offline and no related services have been started yet i.e Apache, PHP and MySql.


    Amber:
    WampServer  amber icon indicates that WampServer is still not ready and any service among Apache, PHP and MySql is still not ready to start.



    Green:
    WampServer is working normal along with all services and your development server is ready to use.



    Note that if the Wampserver icon is not green in the task bar, further steps of working with smarty wouldn't provide the desired results. So, the Wampserver must be fixed before proceeding ahead.

    If the Wampserver icon is not in green in the task bar, open the icon and click Start All Services to see the Wampserver icon turn green in task bar

    Step 16

    Once the Wampserver icon is green in taskbar, It is time to test our WampServer with the installed services of Apache, PHP, MySql and phpMyAdmin. Please follow the steps to test WampServer in Windows 7.
    • Be sure, WampServer icon is green in taskbar
    • Open your favorite browser
    • Type, http://127.0.0.1/ OR http://localhost/
    • Hit Enter

    You will get a error it will show you only your IIS7 icon.



    Now to get your Wamp Server welcome screen you have to follow the steps given below to allocate a port (8080) for Wamp Server to be functional through IIS.

    Step17

    Start the IIS Management Console; just open up the start menu, enter iis and hit Enter. There, navigate to the Sites/Default Web Site/. You can see the Actions panel on the right hand side click on the Bindings


    Now click on the edit button.


    Now add 8080 to the Port as shown below and click ok.


     Now press restart below the Manage Websites in Actions panel on the right hand side .


    Step 18

    It is time to test again our WampServer. Please follow the steps to test WampServer inWindows 7.
    • Be sure, WampServer icon is green in taskbar
    • Open your favorite browser
    • Type, http://127.0.0.1/ OR http://localhost/
    • Hit Enter



    You have successfully installed WampServer on your computer if you have seen the welcome screen of WampServer. You can read Server Configuration at WampServer welcome screen.
    • Apache Version: 2.2.17
    • PHP Version: 5.3.4
    • Loaded Extensions: Loaded extensions of PHP
    • MySql Version: 5.1.53 – It will be Mysql 5.5.8 for 32-bit platform.

    Installing PHP in windows-7


    Installing PHP in windows-7

    Installing PHP on Windows 7 is quite a simple affair. If you follow the steps exactly as described in this tutorial you will have PHP up and running without any problems.

    Step 1:

    Install PHP for Windows using the Microsoft Web Platform Installer and click on Install PHP 5.3.5



    Sep2: Now go to http://www.php.net/downloads.php  scroll down to Windows Binaries and click on


    On clicking the url specified in the above step, the following page will open :


    In the above page, click and Download  the latest non-thread-safe ZIP archive

    Unzip the downloaded archive to C: folder. Then, rename the unzipped folder as PHP as shown below.





    Step 3: create a copy of php.ini-development and rename it as php.ini.


    Step 4: Now open php.ini and change cgi.force_redirect = 0
    And also check cgi.fix_pathinfo = 1, fastcgi.impersonate = 1



    and set extension_dir appropriately:



    Step 5: As we installed PHP for windows on Step 1 now will cross check it. Go to Start/Control Panel/Programs/Turn Windows Features on or off and check on the Internet Information Services entry. Expand  the World Wide Web Services/Application Development Features/CGI node and also Web Management Tools/IIS Management Console.




    Step 6: Now, start the IIS Management Console; just open up the start menu, enter iis and hit Enter. There, navigate to the Sites/Default Web Site/Handler Mappings node and double-click on the "Handler Mappings" entry.


    Step 7: As a result of this, the Actions panel on the right hand side changes. You now see an option called Add Module Mapping. Clicking on it opens up a dialog which you fill out as you can see in the following figure (you may need to adapt the path used to your local system).


    Step 8: If you do not see the FastCgiModule entry, you probably forgot to check the CGI node when installing IIS. Otherwise, close the Add Module Mapping dialog by clicking on OK. You need to confirm that you want to create a FastCGI application; click Yes.


    Step 9: Finally, create a .php script and put it in the root folder of the IIS site (by default C:\Inetpub\wwwroot; note that you may need additional rights to write into that directory), e.g. phpinfo.php with a simple <?php phpinfo(); ?>  call in it. Call this script using http://localhost/phpinfo.php, and you may get internal server error.

    Step 10: If you get error message then go to start menu, enter iis and hit Enter. There, navigate to the Sites/Default Web Site/PHP Manager node and double-click on the "PHP Manager" entry.


    You can see a warning of not an optimal PHP configuration.


      click on the View recommendations and select all the recommendations and click ok.



    Step 11: check the URL now http://localhost/phpinfo.php and you are done!