Monday, 24 February 2014

How To Install PHP MySQL And Laravel Framework In Windows Step By Step

How To Install PHP MySQL And Laravel Framework In Windows Step By Step


n this tutorial i will guide you through the installation of PHP and MySQL in windows , and additionally how to setup PHP framework laravel and Composer with git . php5.4 and later versions have inbuilt development server so in this tutorial i won’t be  cover all the webserver setup and all just simple php and mysql with composer and inbuilt development web-server . so lets get started .

Setup overview

  • PHP  ( Server Side Scripting Language )
  • MySQL ( Database )
  • Composer  ( Dependency manager )
  • Git  ( Version Control System )

Installation

PHP  :

 Download  PHP 

and extract the php file in  C:\php   or anywhere just remember the location , after extracting the php lets setup windows PATH variable , so we can access php from CMD ( command prompt ) .  How to setup Environment Variable in windows : just simply follow the steps
  1. open My Computer and click on propertiesproperties
  2.  click on advance system settingsadvance
  3. Click on the Environment Variables From System Properties windowWindows system environment variables
  4. Choose System variables and select PATH and click editedit
  5. Add  ”  ;  ” ( without quotes )  and add php locationdone
  6. Click OK and OK again and Press Windows + R and type CMD  and type  php -vphp windows cmdif you are getting that kind of output  , Congrats now php is installed and accessible from CMD

MySQL :

MySQL comes with windows installer but i will show you how to install using zip package . Download and extract zip in C:\MySQL  and setup environment variable exactly like how we did setup for PHP .
MySQL now secure the mysql initial user account see this guide : http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
MySQL Service in windows
if you want to start mysql when you log on then install mysql service and select automatic start ,
click on start >>all programs >> accessories > then right click and open Command prompt as admin
cd  c:\mysql\bin
C:\MySQL\bin>mysqld --install
and now open service manager and find MySQL service then click on properties set automatic start

Mysql Service
 now php and mysql is installed lets install composer  . Download windows installer and install like another windows package . just choose correct php location when installing .
Composer on windowsopen CMD and type ” composer –version ” and make sure it print version otherwise troubleshoot your installation  .

Laravel

Now lets setup laravel  ,  Laravel is php based  MVC framework  if you are confuse its like ASP MVC and Ruby On Rails framework just written in PHP . let’s install  , open CMD  and paste
composer create-project laravel/laravel TestProject
wait for time it will take some time to install all the dependencies , if you are getting openssl error then simply open php.ini file and fix extension dir path ( see the php folder that we extracted at the time of installation )
extension_dir = C:\php\ext
and change
;extension=php_bz2.dll
//to 
extension=php_bz2.dll
then try again , i am sure it gonna work . now wait until it finish setting up dependencies .
laravel project
after that lets start development  server  . open CMD cd to project root and laravel comes with a tool calle artisan
lets fire up dev server using artisan
php artisan serve
then open browser and open http://localhost:8000 , and you will see default laravel page .
Some important links