Configuring PHP Development Environment in Windows
Configuring PHP Development Environment in Windows
This tutorial shows you two ways of configuring your PHP development environment on the Windows operating system. The first and most convenient way is to install and configure an AMP (Apache, MySQL, PHP) package. This tutorial shows you how to install the XAMPP package. The second way is to install and configure each component separately. Contents
o o o
Installing and Configuring the XAMPP Package Checking XAMPP Installation Installing and Enabling the XDebug Debugger
o o o o o
Apache HTTP Server PHP Engine MySQL Database Server XDebug Setting Up the Environment
To follow this tutorial, you need the following software and resources.
Version Required PHP download bundle Version 5. Included in XAMPP-Windows. Apache HTTP Server 2.2 is recommended. Included in XAMPP Windows. MySQL Server 5.0 is recommended. Included in XAMPP Windows.
A database server
Typically, development and debugging is performed on a local web server, while the production environment is located on a remote web server. Setting up a remote web server is described in Deploying a PHP Application on a Remote Web Server Using the NetBeans IDE. This tutorial has you set up a local web server. PHP support can be added to a number of local web servers (IIS, Xitami, and so on), but most commonly Apache HTTP Server is used. Apache HTTP server is included in the XAMPP AMP package used in this tutorial. For information on installing and configuring Apache HTTP server standalone, click here.
Required Software
To create, run, and debug your PHP projects you need the following software:
The NetBeans IDE for PHP. Downloads are available here. A web server. Typically development and debugging is performed on a local web server, while the production environment is located on a remote web server. The current version enables using a local server. Using a remote server with FTP access will be supported in future versions. PHP support can be added to a number of web servers (IIS, Xitami, and so on), but most commonly Apache HTTP Server is used. Click here for information on how to install and configure Apache 2.2.
The PHP engine. The supported version is PHP5. Downloads are available here. The PHP debugger. The NetBeans IDE for PHP allows you to use XDebug, but using a debugger is optional. The recommended version is XDebug 2.0 or higher as it is compatible with PHP5. A database server. You can use various database servers while one of the most popular ones is the MySQL server. Downloads are available here. Note: The recommended version of the product is MySQL Server 5.0. The provided documents describe the work with this version.
After the installation, you need to set up the environment that all the software components work properly with each other. You can use a Package, that contains the required software, or install each component separately.
2.
On Microsoft Vista, the User Access Control feature blocks the PHP installer from updating the Apache httpd configuration. Disable UAC while you are installing XAMPP. See Microsoft support for more information. You are given the option to install the Apache server and the MySQL database server as services. If you install the Apache Server and MySQL as services, you will not have to start them manually through the XAMP Control Panel. Note that you have the option to install or uninstall these services in the XAMPP Control Panel.
3.
4.
If you are using the self-extracting archive, after the archive is extracted, run the file setup-
xampp.bat to configure the components of the package. (The XAMPP installer runs this file
automatically.)
5.
After configuration, open the XAMP Control Panel. (You can open it manually by running the file XAMPP_HOME/xampp-control.exe or from the Xampp Control Panel icon that is automatically placed on your desktop.) When you open the XAMPP Control Panel, note that the modules that are installed as services are already running. Warning: On Windows Vista sometimes xampp-control.exe will not run. You can run xampp-
start.exe instead. Warning: The winmysqladmin.exe file, which is launched by the Admin button for MySQL,
does not work. A cascade of error messages appears, which can only be stopped by manually terminating thewinmysqladmin process. You cannot launch winmysqladmin.exe from the command line, either. See http://bugs.xampp.org/view.php?id=71.
6.
The Svc checkboxes indicate that a module is installed as a Windows service and will start automatically on system startup. You can install or uninstall Windows services by selecting or unselecting the Svc checkbox. Uninstalling a Windows service does not uninstall the module, but it does require you to start the module manually. The XAMPP control panel includes buttons for stopping and starting modules and opening their administration consoles.
2.
To ensure that the Apache and MySQL servers have been installed as system services, restart your operating system, run the browser, and enter the http://localhost URL again. The XAMPP welcome page opens. Note that the XAMPP welcome page includes a menu in the left margin through which you can check the status of XAMPP components and run phpinfo(), among other useful features. phpinfo() returns a screen with configuration information about your XAMPP
components.
1.
Download the latest thread-safe XDebug compatible with your version of PHP. The download links are listed under Releases. Copy the .dll file to your XAMP_HOME/php/ext directory. (XAMPP_HOME refers to your XAMPP or XAMPP Lite installation directory, such as C:\Program
Files\xampp or C:\xampplite.)
2.
Locate and open the active php.ini file for your XAMPP. This is located by default in the XAMPP_HOME/apache/bin directory. Confirm which php.ini file is active by running phpinfo() and searching for Loaded Configuration File.
3.
Because Zend optimizer blocks XDebug, you need to disable Zend optimizer. In the active php.ini file, locate the following lines and delete them or mark as comments (To be safe, search for and comment out all properties related to Zend):
4. [Zend] 5. ;zend_extension_ts = "C:\Program Files\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll" 6. ;zend_extension_manager.optimizer_ts = "C:\Program Files\xampplite\php\zendOptimizer\lib\Optimizer" 7. ;zend_optimizer.enable_loader = 0 8. ;zend_optimizer.optimization_level=15 9. ;zend_optimizer.license_path = 10. To attach XDebug to the PHP engine, uncomment the following lines in the php.ini files (directly
beneath the [Zend] section, add them if not there). Some additional notes have been added.
11.[XDebug] ; Only Zend OR (!) XDebug 12.zend_extension_ts = "./php/ext/php_xdebug<-version-number>.dll" 13.; XAMPP and XAMPP Lite 1.7.0 and later come with a bundled xdebug at <XAMPP_HOME>/php/ext/php_xdebug.dll, without a version number. xdebug.remote_enable=1 xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 14.; Port number must match debugger port number in NetBeans IDE Tools > Options > PHP xdebug.remote_handler=dbgp xdebug.profiler_enable=1 xdebug.profiler_output_dir="<XAMPP_HOME>\tmp"
Set the xdebug.remote_enable property to 1, not "true" or any other value. Note: Make sure the paths you specify match the location of the corresponding files as determined during your installation.
15. Save php.ini. 16. Run the XAMPP Control Panel Application and restart the Apache server.
See our wiki and the XDebug documentation for more information on how to configure XDebug.
1. 2. 3. 4. 5. 6. 7. 8.
Locate and open XAMPP_HOME\php\php.ini for editing. This is the only php.ini file in XAMPP 1.7.2. Find and uncomment the line zend_extension = "XAMPP_HOME\php\ext\php_xdebug.dll". Find and uncomment the line xdebug.remote_host=localhost. Change the value of the setting from localhost to 127.0.0.1. Find and uncomment the line xdebug.remote_enable = 0. Change 0 to 1. Find and uncomment the line xdebug.remote_handler = "dbgp". Find and uncomment the line xdebug.remote_port = 9000. Save php.ini. Run the XAMPP Control Panel Application and restart the Apache server.
See our wiki and the XDebug documentation for more information on how to configure XDebug.
http://localhost/
The Apache welcome test page opens:
Troubleshooting
By default, the Apache server listens to port 80. This port can be already used by other services, for example Skype. To solve the issue, change the port which the server listens to:
1. 2.
Open the Apache web server configuration file httpd.conf. By default the file is located in C:\Program Files\Apache Software Foundation\Apache<version>\conf\ Locate the line Listen 80 and change the port number, for example 8080. Save the file.
3.
Restart the Apache web server. To check that the web server works, run the browser and enter the URL and specify the port number explicitly: http://localhost:8080
4.
You can also stop the processes that possibly listen to port 80. In the Task Manager, select the relevant file name and click End Process. Find more information on installing and configuring the server here.
o o
Foundation\Apache<version>\htdocs\test.php
Run the browser and enter the following URL: http://localhost:<port>/test.php.
Troubleshooting
If the page does not open: 1. 2. Restart the Apache server. Check that the Apache server configuration file httpd.conf contains the following lines:
3.
AddType Application/x-httpd-php .php LoadModule php5_module "c:/php/sapi/php5apache2_2.dll" 4. If the lines are missing, add them, save httpd.conf, and restart Apache.
5. Refresh the http://localhost:<port>/test.php page.
2.
xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 ; Port number must match debugger port number in NetBeans IDE Tools > Options > PHP xdebug.remote_handler=dbgp
Click here for more information on how to configure XDebug. Note: Make sure the paths you specify match the names and locations of the corresponding files as determined during your installation. 3. To be sure that previously installed PHP engine supports using the MySQL database server: a. b. c. Click Start > Control Panel. On the Control Panel, choose Add or Remove Programs. On the Add or Remove Programs panel, select the PHP <version number> area and click Change. The PHP Setup Wizard starts. Click Next. d. e. On the Change, repair or remove installation panel, choose Change and click Next. On the Web Server Setup panel, choose the version of the Apache server - in our example it is Apache 2.2.x Module. Click Next.
f.
On the Apache Configuration Directory panel, specify the directory where the Apache configuration file httpd.conf is located. Click Next.
g.
On the Choose Items to Install panel, expand the Extensions node and choose the MySQL and MySQLi items. Click Next.
h. i.
On the Ready to change PHP <version number> panel, click Change. On the Completed the PHP <version number> Setup Wizard panel, click Finish.
http://netbeans.org/kb/docs/php/configure-php-environmentwindows.html#installPHPEngine