Pages

Sunday 9 September 2012

Configuring Zend Framework for PHP on Windows


First download and extract the Zendframework 1.1.11.zip to C:/server and rename Zendframework 1.1.11 to Zendframework

Configuring php.ini

Find
;include_path = ".;c:\php\includes"

Replace
;include_path = ".;c:\php\includes;C:\ZendFramework\library\zend"

Adding Environment variable
  • ·         Right click My Computer | Properties|Advance Settings |Advanced |Environment Variable
  • ·         Select User Variable for Admin
  • ·         Select PATH from System Variable and add
  • ·         Add Path
C:\server\ZendFramework\library\zend

Command Prompt

Go to the bin folder of the zendframework installation path

C:\>cd  C:/server/zendframework/bin/zf

C:\>server/zendframework/bin/zf>zf show version

would show the version of the Zend framework successfully installed.

Zend Framework 1.1.11

To create Zend Project use the following command
C:\>server/zendframework/bin/zf>zf create welcome



Step By Step Installing and Configuring MySQL on Windows XP

1. Download MySQL Setup from http://dev.mysql.com/downloads
2. After downloading, Run the Setup.
3. Select Typical or Complete or General based on your personal need.
4. Most user may opt for Typical.  Check it and Click Next.
5. The Setup would run and the finally wizard would request you to
  • Configure the MySQL Now
  • Register the Product Now
 6. Check the Configure MySQL Now Checkbox and Uncheck the Registering the Product Now Checkbox.
7. This launches Microsoft Server Instance Configuration Wizard for Configuring MySQL.
8. Most user may go for Standard Configuration. Click Next.
9. Choose Install As Windows Service. Select a Service Name(MySQL is by default, so leave as it is) Check Lauch the MySQL Server Automatically as window starts up.
10.  If you wish to access MySQL from Command Prompt, Select Include Bin Directory in Windows PATH. Click Next.
11. Select Modify Security Settings Checkbox(it would be selected by default) and choose a password. You may leave it blank, if there is no security concern for you.
12. For security reasons, uncheck Enable root access from remote machine and Create An Anonymous Account.
13. Click Next to finish the setup.

To Access MySQL From Command Prompt:

To access MySQL from Windows Commond Prompt follow the steps:

  1. Go to the bin directory of where MySQL is installed in your system and type mysql 
          eg: C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql
 
     2. Type the user name and password to access mySQL.

Step By Step Installing and Configuring PHP5 Apache2.2 and MySQL5.1


Step1: Apache installation and configuration

            After all the steps of this tutorial, we'll be able to host our web site on our PC running Windows.

Download

VC9 x86 Thread Safe: php-5.3.6-Win32-VC9-x86 (zip format only) Apache Http Server 2.2.19/2.2.17
MySQL 5.1.50

Apache 2.2.19 (or 2.2.17) Install.

Run the Apache installer package, "httpd-2.2.19-win32-x86-no_ssl.msi" or "httpd-2.2.17-win32-x86-no_ssl.msi"


Click Next.

In the "Server Information" dialog box, enter

     Network Domain: localhost
     Server Name : localhost
     Administrator's Email Address: admin@mycompany.com
     Leave the default setting of for All Users, on Port 80, as a Service as it is.
     Click "Next"

 Note: The installer uses the information you enter to create a default Apache configuration file for you. You can always go back and manually change these values in your configuration file if you change your mind later.


When asked about the Setup Type, select "Typical" and click "Next".


In the Destination Folder dialog, allow the installer to install to the default folder. So, just click "Next"


Finally click the "Install" button to allow the installer to set up Apache.


When it is done, click the "Finish" button.

Once Installation is complete, verify the installation by clicking on the Apache Icon in the taskbar (far left), as shown below.

 

You can also verify your installation of Apache by opening http://localhost/ in your browser. Or you can just type in "localhost" for the URL.
 


Congratulations for a successful installation of Apache. We still have to configure Apache, but we will do it in the later steps.

Step 2: PHP 5.3.6 installation and configuration


    Extract PHP package
    Now it's time to install PHP5. Open the zip file & extract all your files to C:\php. Navigate to C:\php

    Make php.ini file
    Rename php.ini-development to php.ini

    Edit the php.ini file
        Edit 1
        Find extension_dir = "./" and replace it with

extension_dir = "C:/php/ext"

        Edit 2
        We're going to uncomment by removing the ";" from the extension to activate it.

Here are the extensions to be uncommented.
Search for each one them and remove the semicolon ";"

    ;extension=php_gd2.dll

    ;extension=php_mbstring.dll

    ;extension=php_mysql.dll

    ;extension=php_mysqli.dll

The First extension enables the Image GD library of PHP.
The Second enables mbstring.
The Third and forth enables us to use MySQL database.
Save the php.ini file.

    Setup PHP Environment
    Let's setup the PATH environment variable.
    Start->Control Panel->System->Advanced System Settings
    then go to the Advanced tab, click on the Environmental Variables button,
    then scroll down in system variables to find PATH,
    Edit it Add C:\php;

    Restart the System
    You must reboot a windows system after setting the Path variable.
    If you move on past that point without rebooting apache may have trouble finding your MySQL extensions.
    Now we have PHP configured.

    Let's move on to configuring Apache.

Step3: Configuring Apache
Go to C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\

You may need to turn off UAC for editing.

    httpd.conf Editing

Edit 1:

Uncomment:

#LoadModule rewrite_module modules/mod_rewrite.so

=>

LoadModule rewrite_module modules/mod_rewrite.so

Edit 2:

Add the following below the previous edit

#PHP5

LoadModule php5_module "C:/php/php5apache2_2.dll"

PHPIniDir "C:/php"

Edit 3:

Search for

AddType application/x-gzip .gz .tgz

Add the following lines below it. These lines define a MIME (Multipurpose Internet Mail Extensions) type for files ending with a file extension of .php and .phps so they will be processed by the PHP parser on request.

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

Edit 4:

Search for DirectoryIndex index.html
Replace it with

DirectoryIndex index.html index.php

Edit 5:

Uncomment:

#Include conf/extra/httpd-vhosts.conf

=>

Include conf/extra/httpd-vhosts.conf 

    Virtual Hosting Setup (optional )

    You are about to make our server to host your domain for Apache Development project.  You can name your own but here I am going to use apache.dev as a domain name.  So, after we finished this step, we'll be able to type in our URL on the web browser:
    http://www.apache.dev/,
    then we get our home page from the http server installed on our machine.
    But we need to setup the directory structure to realize the Virtual Hosting.

Directory Tree Setup

Make directories:

C:/server/www/apache.dev/public_html

httpd-vhosts.conf Editing

Open the file in:

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\extra

Replace the contents with

<virtualhost *:80>

DocumentRoot "C:/server/www/apache.dev/public_html"

ServerName Apache.dev

ServerAlias www.apache.dev

<directory "C:/server/www/apache.dev/public_html">

AllowOverride All

Options Indexes FollowSymLinks

Order allow,deny

Allow from all

</directory>

</virtualhost>

Apache Webserver Restart

Let's restart Apache server and check if it restarted successfully.
.
Note: Configuring httpd-vhosts.conf is optional. You can place the php filesin httpdocs folder.

Testing PHP with Apache

In the previous step 3, we made directory structure, C:\server\www\apache.dev\public_html\. This is where you will be putting all your html and script files and our webserver will use those files.Let make a php file and name it index.php and put it inside the C:\server\www\apache.dev\public_html\ directory.

<?php phpinfo(); ?>

Then type http://localhost/index.php as URL for your browser. Then, you'll get the information about the PHP you've just installed.


Making Windows recognize http://www.apache.dev

This step is not necessary, but it's a nice feature to add. To make Windows recognize your domain on Apache webserver,  we need to edit hosts file in C:\Windows\System32\drivers\etc directory.

Add the following two lines to the hosts file.

127.0.0.1      apache.dev

127.0.0.1      www.apache.dev

Then type in apache.dev or www.apache.dev as an URL, then you'll get the same php information as when you type in localhost as an URL.