• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Setting Up PHP and MySQL Development Environment on Windows 7
 

Setting Up PHP and MySQL Development Environment on Windows 7

on

  • 18,593 views

This is a step by step way of installing Apache HTTP Server, MySQL Server and PHP pre-processor on Windows 7.

This is a step by step way of installing Apache HTTP Server, MySQL Server and PHP pre-processor on Windows 7.

Statistics

Views

Total Views
18,593
Views on SlideShare
18,591
Embed Views
2

Actions

Likes
0
Downloads
215
Comments
0

1 Embed 2

https://twitter.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Setting Up PHP and MySQL Development Environment on Windows 7 Setting Up PHP and MySQL Development Environment on Windows 7 Document Transcript

    • Setting Up PHP and MySQLDevelopment Environment on Windows 7 By: Julian V. Jupiter www.jupitersnotebook.blogspot.com www.facebook.com/julianjupiter www.twitter.com/dealwithjulez
    • This is a step by step way of installing Apache Web Server, MySQL database and PHP pre-processor on Windows7.What You Need To Know To Get StartedApache HTTP Server is the famous Web server nowadays. It is available for a wide variety of operating systemssuch as UNIX, Linux, Solaris, BSD, Windows, Mac OS, etc. Apache is developed and maintained by opencommunity of developers under the hood of Apache Software Foundation (www.apache.org).PHP (www.php.net) is the most popular scripting language on the web. PHP is a server-side language as opposedto JavaScript which runs on client side (user agent, e.g. Web browser). It is embedded into HTML and puts thetools for creating dynamic websites in the hands of the people. PHP is penetrating Web technology so that anumber of websites now are developed with PHP. Originally, it stands for Personal Home Page and was createdby Rasmus Lerdorf in 1995. However, the main implementation of PHP is now produced by The PHP Groupsponsored by Zend Technologies, the company founded by Zeev Suraski and Andi Gutmans, two Israelidevelopers at the Technion IIT. They redesigned the parser in 1997 and formed the base of PHP 3; they alsochanged the languages name to the recursive acronym PHP: Hypertext Preprocessor. PHP is free softwarereleased under the PHP License. PHP is penetrating the Web technology so that a number of websites now arecreated with PHP. It as an alternative to other scripting languages or tools such as that of Oracle’s JSP andMicrosoft’s ASP.NET.MySQL (www.mysql.com) database server is the worlds most popular open-source DBMS. Like Apache and PHP,MySQL is a free software, but under the license of GNU General Public License (GPL). It is originally owned andsponsored by MySQL AB, a single-profit Swedish company , acquired by Sun Microsystems which in turn wasacquired by Oracle Corporation.
    • Apache InstallationSoftware: httpd-2.2.22-win32-x86-openssl-0.9.8t.msi1. Double-click, or right-click installer and click Install.2. Click Next.3. Click I accept the terms in the license agreement.
    • 4. Click Next.5. Type in localhost for Network Domain and Server Name; type in also Email Address for AdministratorsEmail Address. By default, for All Users, on port 80, as a Service – Recommended is checked. It is therecommended option. Using port 80 lets you use only domain name or IP address without appending the port,hence localhost instead of localhost:80, and so is yahoo.com instead of yahoo.com:80. Other than this portnumber, you need to append the port like localhost:8080, 127.0.0.1:8081, etc. Click Next.
    • 6. Check Typical and click Next.7. Click Next. Do not change installation directory unless you have reasonable preference.
    • 8. Click Install.9. Wait while the software is being installed.
    • 10. Click Finish.11. Apache is now installed, and included in Windows menu.
    • 12. To test if Apache is running, open your favorite browser (mine is of course Firefox), type localhost in theaddress and hit Enter. Browser should open something like “It works!” Good job! You can also use computer local name in replace to localhost; open Computer properties, click Advanced system settings, look for Full computer name: under Computer Name tab. Oppps! Theres more. You can also use the default IP address of any local computer – 127.0.0.1. And finally, you can mimmick a FULLY QUALIFIED DOMAIN NAME (FGDN) that you want in the form of www.mydomainname.com. Go to C:WindowsSystem32driversetc and open hosts file in you favorite text editor (Notepad, Notepad++). Yes. It doesnt have file extension like .txt or .odt. Now add the following on the last line and save the file: 127.0.0.1 www.mydomainname.com Opening IP address (127.0.01), computer name, or the fake FQDN should open the same page as localhost.
    • 13. Go to Apache HTTP Server menu when starting, restarting or stopping the server or you can click the Apacheicon on Windows tray bar:
    • 14. Default Web documents directory is C:Program FilesApache Software FoundationApache2.2htdocs.This can be changed depending on your preference through httpd.conf configuration file of the server which islocated on the menu or in C:Program FilesApache Software FoundationApache2.2conf directory.Congratulations!Apache alone is enough to run HTML/CSS/JavaScripts and all other client-side scripts as Web browser does.
    • PHP Installation and Configuration for ApacheSoftware: php-5.4.0-Wind32-VC9-x89.zipNote: zipped (.zip) package is highly recommended than installer (.msi).1. Extract or decompress php-5.4.0-Win32-VC9-x89.zip to C: drive. Or extract to any directory and copy it to C:drive. Folder should be renamed to php so that we will have C:php.2. PHP folder contains dev, ext, and extras folders. It also contains files such as glib-2.dll, php.exe,php5apache2_2.dll, and a lot more:
    • 3. Look for the file php.ini-development (for development purpose) or php.ini-production (for productionpurpose) from php folder and copy to the same folder. Rename it to php.ini and open with your favorite text editor,e.g. Notepad and Notepad++. Note: Click Yes if there prompts "If you change a file name extension, the filemight become unusable. Are you sure you want to change it?"4. Open php.ini and look for display_errors = Off. With this directive set to off, errors that occur during the execution ofscripts will no longer be displayed as a part of the script output, and thus, will no longer be exposed to remote users. Withsome errors, the error message content may expose information about your script, Web server, or database server that maybe exploitable for hacking. Production sites should have this directive set to Off.
    • For development purposes, this directive should be set to On.5. Open httpd.conf on C:Program FilesApache Software FoundationApache2.2conf, or to easily open this file,click Edit the Apache httpd.conf Configuration File under Start>All Programs> Apache HTTP Server 2.2>ConfigureApache Server. Add PHP module to last line of list of modules on Apache configuration file. PHP module can befound on the top level of PHP directory. Since the Apache version is 2.2.x or 2.2.22, we are going to usephp5apache2_2.dll module. Add LoadModule php5_module “C:/php/php5apache2_2.dll”. Take note: use “/” and not “”.6. Look for the line DirectoryIndex index.html which can be found on <IfModule dir_module> section. Change it to DirectoryIndex index.php index.html. Apache will serve the file index.php (or the index.html if the former is not present) if a directory is requested. index.php must come first otherwise index.html will be opened if both exist.
    • 7. Look for the following lines under <IfModule mime_module> section: AddType application/x-compress .Z AddType application/x-gzip .gz .tgz Add AddType application/x-httpd-php .php to the next line. At the last line, add PHPIniDir <php.ini directory> in order for the Apache to look up php.ini configuration. Save the file.8. Restart the Apache Server. Every time you make any changes to php.ini or httpd.conf you have to restart theserver.9. To test if Apache and PHP work together, make a PHP file with the following codes on your text editor and savewith the desired name and with .php extension. In my case, phpinfo.php. <?php phpinfo(); ?>
    • Save this file to the top level of your document directory htdocs (you should have permission) or you can create a folder to place to it. Open http://localhost/phpinfo.php with your favorite Web browser. You can change localhost as discussed in Apache Installation. It should open the following:Congratulations.Apache and PHP alone are enough to run PHP scripts. However, if your PHP application includes database functionalities,you will need to install DBMS like MySQL.
    • MySQL Installation and Configuration for PHPSoftware: mysql-5.5.25-win32.msi1. Double-click installer or right-click and click Install.2. When installer opens, click Next.3. Check I accept the terms in the License Agreement and click Next.
    • 4. Choose setup type depending on your needs. Typical installs the most common program features;recommended for most users. Custom allows users to choose which program features will be installed and wherethey will be installed; recommended for advanced users. Complete will install all program features; it requires themost disk space. (Mine is Complete)5. Click Next.
    • 6. Just click Next when more windows open up.
    • 7. The following step completes MySQL setup. Check Launch the MySQL Instance Configuration Wizard to startinstance configuration. Configuration wizard is necessary for creating user, password and other settings. Leaving itunchecked will do otherwise but you can later invoke instance configuration MySQLInstanceConfig.exe fromC:Program FilesMySQLMySQL Server 5.5bin. Click Finish.8. Click Next when configuration wizard fires up.
    • 9. Select configuration type. I chose Standard Configuration. Click Next.10. Check Install As Windows Service, select Service Name from the drop-down list, and check Launch the MySQLautomatically and Include Bin Directory in Windows PATH. Click Next.
    • 11. Check Modify Security Settings and enter root password. By default, MySQL has root user which consists allthe privileges. Note: root acts as superuser that manages all the server resources and therefore it isrecommended that you create another user for day-to-day data management for your applications; consult MySQLdocumentation available from its Website. Click Next.12. Click Execute.
    • 13. Click Finish.14. MySQL Server is now installed, and included in Windows menu.
    • 15. To start using MySQL, click MySQL 5.5 Command Line Client from the menu.
    • Since we checked Include Bin Directory during the instance configuration, we can also open MySQLconsole by opening cmd/command and type in mysql -u root -h localost -p.
    • To exit from MySQL console, just type in exit and hit Enter or simply click button of the cmd.16. After MySQL has been installed, we need to configure PHP and enable MySQL extension. There are two ways to connect PHP with MySQL (I prefer the second approach): a. Copy mysql.dll and/or mysqli.dll from C:phpext to the top level directory of PHP installation, C:php. Open php.ini and look for php_mysql and php_mysqli under the list of extensions. Uncomment php_mysql and php_mysqli, save the file and restart Apache server: b. Open php.ini and look for extension_dir = "ext"
    • Change this line to extension_dir = “<extension directory>” where extension directory is the directory of the extensions to be loaded such as mysql.dll and/or mysqli.dll. The directory is C:phpext. Note: instead of changing the same line, I would copy and edit it. Uncomment php_mysql and php_mysqli, save the file and restart Apache server:17. To check if PHP connection with MySQL works fine, reload phpinfo.php on the browser. You should now seemysql and mysqli support entries.
    • You can also test by running the following codes: <?php $host = localhost; $user = root; //we will use root user since we have not created new user $pwd = admin012345; $con = mysql_connect($host, $user, $pwd); if($con) echo “Connection successful!”; else die(“Connection failed!”); mysql_close($con); ?> Save the file as mysql_test.php in htdocs and run on the browser: http://localhost/mysql_test.php. Your browser should render the following:Congatulations!!! Now that you have already installed PHP, you may now take the power of PHP and MySQL Webdevelopment.