- ButlerCC Webhosting
- Recommended PHP Core and date directives for test server
- Check Your PHP Settings with XAMPP:
- Where Is My php.ini File?
- Tips Before Editing php.ini File
- Modify php.ini for XAMPP 7.4.8
- Deploy a webserver with XAMPP on Windows for PHP development
- In-depth guide to quickly deploy a webserver with XAMPP on Windows for your PHP development projects.
- Tutorial Starts Install and configure XAMPP on Windows
- Prerequisites
- Download XAMPP on Windows
- Option 1: Latest stable PHP versions
- Option 2: Other PHP versions
- Install XAMPP on Windows – Full installation
- Launching XAMPP webserver
- Install XAMPP on Windows – Portable version
- Download the XAMPP portable version
- Extract the downloaded XAMPP portable version
- Run the setup_xampp.bat file
- How to start PHP development in XAMPP
- Making XAMPP installation available on Internet
- Change XAMPP installation PHP version
- Other tutorials you might like
ButlerCC Webhosting
This guide is intended to help you configure PHP for your local test server, and includes details for configuring PHP in XAMPP for both Windows and Mac OSX. Before you configure your php.ini file, you should first check your current settings and note the settings you need to change.
Recommended PHP Core and date directives for test server
This table contains the recommended test server settings for PHP Core and Date directives for XAMPP (both Win and Mac).
Directive | Local Value |
---|---|
allow_url_fopen | On |
allow_url_include | Off |
display_errors | On |
error_reporting | 32767 |
file_uploads | On |
log_errors | On |
short_open_tag | Off |
upload_tmp_dir | (Win) C:\xampp\tmp (OS X) /Applications/XAMPP/xamppfiles/temp |
date section Default timezone | America/Chicago |
Check Your PHP Settings with XAMPP:
- Open your XAMPP Control Panel (Manager-OSX) and Start the Apache server.
- In a browser, type http://localhost in the address bar to open the XAMPP dashboard page.
- Click PHPInfo in top navigation bar to display your current settings. The PHP Core and Date directives sections are the ones to focus on.
- Compare your Core and date values to those in the recommended test server settings for PHP Core table and note the ones that need to be changed. Your PHP directives should look similar to the old screenshot below.
- Open XAMPP Control Panel and Stop Apache server before editing PHP directives.
Where Is My php.ini File?
- In XAMPP (Windows), the php.ini file is in the C:\xampp\php folder.
- In XAMPP (Mac OSX), the php.ini file is in the /Applications/XAMPP/xamppfiles/etc folder.
Tips Before Editing php.ini File
Important points BEFORE editing your php.ini file:
- IMPORTANT! Open your XAMPP control panel and Stop Apache server before editing the php.ini file.
- Make a backup copy of the php.ini file before editing in case anything goes wrong (Name the backup copy php.ini.bak or something similar).
- The php.ini file is huge—use a text editor with line numbering, like Brackets (or Notepad++ for Win).
- Lines that begin with a semicolon (;) are comments and are ignored by PHP.
Modify php.ini for XAMPP 7.4.8
In this version of the php.ini file, there are only two directives that must be modified. (Three directives in Mac OS X) However, you should still verify all the following directives are correct in your php.ini file. Directives in the following table are organized by line number.
- Open your php.ini file in Brackets (or other text editor with line numbering) and make the necessary changes.
- (Mac OS X only) Line 228 (short_open_tag) should be as follows:
short_open_tag = Off - Line 463 or 516 (error_reporting) should be as follows: (Note: the value is case sensitive so be sure to type in all caps. Use the pipe character SHIFT + \ for separator.)
error_reporting = E_ALL | E_STRICT - Line 1969 or 1040 (date.timezone) should be as follows:
date.timezone = America/Chicago - Save and close the php.ini file.
- In XAMPP Control Panel, restart your Apache server.
- To check the changes to your PHP configuration settings, type http://localhost in address bar of a browser to open the XAMPP dashboard.
- In the XAMPP dashboard, click PHPinfo link to display your current settings. Compare your values to the Recommended PHP Core directives table.
- When your php.ini file is configured correctly, you’re ready to work on projects in your htdocs directory.
- c:\xampp\htdocs (Win)
- /Applications/xampp/htdocs (Mac OSX)
- (Optional) If you want to use PHP includes and site root relative links in your projects, review Setup Virtual Hosts with XAMPP.
Disclaimers: Butler is an “Equal Opportunity Employer/Program” and “Auxiliary Aids and Services are available upon request.”
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Deploy a webserver with XAMPP on Windows for PHP development
In-depth guide to quickly deploy a webserver with XAMPP on Windows for your PHP development projects.
This in-depth guide will help you on installing XAMPP on Windows to begin your PHP development and deployment on the local machine quickly. There will be tutorials for both installation types, full & portable installation. Note: XAMPP is meant for local development and local deployment only, therefore not for production as many default XAMPP configurations are unoptimized and might cause performance issues as well as security issues for a production site. We will have future articles on how to configure XAMPP for better running in a production environment. Stay tuned!
Tutorial Starts Install and configure XAMPP on Windows
Prerequisites
- XAMPP requires at least from Windows 2008 to run.
- Visual C++ Redistributable required. You can download and install it on the official download page:
Visual Studio Tools download page > Other Tools, Frameworks, and Redistributables > Microsoft Visual C++ Redistributable for Visual Studio 2022.
Download XAMPP on Windows
First, we will have to download XAMPP with the PHP version we wanted. Navigate to official XAMPP download website:
Option 1: Latest stable PHP versions
On the download page, pick a XAMPP for Windows with the PHP version you wanted. Normally, the listed versions here are the most latest, stable versions that XAMPP has them bundled. Of course, we can change the PHP version later, so this is the default recommended option.
Option 2: Other PHP versions
If you want to download a custom XAMPP bundle with another PHP version of your choice, click the More Downloads link, which will take you to browse all XAMPP versions and add-ons.
On the next page, click XAMPP Windows:
On the XAMPP Windows version browsing page, pick a PHP version that you want to have XAMPP bundled with.
For example, the version we picked is PHP 8.1.2. You will see a couple of download types:
Choose a version based on your preferences:
- Recommended: For the full installation, download the normal installer’s .exe version (without portable ), which the software will automatically configure everything for you.
In this example, the recommended file is xampp-windows-x64-8.1.2-0-VS16-installer.exe . - For the portable version, choose the installer with xampp-portable-windows in name. It can be either in .zip or .exe file type depends on your choice.
After downloading the XAMPP installation, we can start install on Windows based on the version type.
Install XAMPP on Windows – Full installation
Run the installation .exe file, click Next on the first panel. On the next panel, choose the components you wanted to install with XAMPP. Normally, these are our recommendation for a good basic PHP development with XAMPP on Windows:
Overall, the basic recommended components contain:
- Apache (required by default) for the web server
- MySQL (recommended) for the database server
- PHP (required) for our PHP development
- phpMyAdmin for easy database interaction
- Fake Sendmail to catch mails sent by general PHP development tasks
Extra components you can consider to install include FileZilla FTP Server, Mercury Mail Server for FTP & Mail server, Tomcat for a Java HTTP server, and Webalizer for analytics.
With basic PHP development, these can be left out and can be installed later. Overall, XAMPP on Windows is meant for only PHP development, not for production, so let’s only keep the basic recommended components installed.
After picking the components, click Next and choose the installation directory. It is highly recommended to install on other drives than the system drive (C drive).
Pick the language on the next panel, and on the Bitnami for XAMPP option, it’s a handy tool to quickly install popular PHP platforms as WordPress, Joomla, etc. to your XAMPP installation. Upon clicking Next, XAMPP will be installed on your Windows computer.
After finished the installation, you can choose to start the XAMPP Control Panel. Let’s do it.
Launching XAMPP webserver
On the XAMPP Control panel, click Start on the Apache module row, which will start the Apache Webserver.
On the first run, Windows Firewall will ask for your permission to allow network access to XAMPP’s Apache Webserver. Normally it’s safe to do so in Private networks, which is only accessible on your trusted networks.
If you see this, Apache webserver is successfully started.
Go to the web browser, navigate to http://localhost , if you see this page, XAMPP is successfully installed with Apache running as a web server.
Install XAMPP on Windows – Portable version
For XAMPP on Windows portable installation, the process is a little bit different as we don’t have to run the installation package.
Download the XAMPP portable version
Follow the same download tutorial as with the installation version, but choose the file with xampp-portable in name.
Extract the downloaded XAMPP portable version
Extract the downloaded zip package into a directory you want to run XAMPP. You might have to rename or move the extracted directory name for it to be shorter.
Run the setup_xampp.bat file
Next, run the file setup_xampp.bat and it will automatically register and configure the paths for your XAMPP portable installation.
*Make sure Visual C++ Redistributable is installed first, or else you will see an error displayed here.
If this window displays, your XAMPP portable has been successfully installed and configured.
Again, you can start using XAMPP by running the xampp-control.exe file, similar to the Full installation method.
How to start PHP development in XAMPP
You can start your PHP development right away by editing the files in XAMPP by navigating to the folder [XAMPP installation folder]\htdocs , which contains all of the files for the webserver served by XAMPP.
Making XAMPP installation available on Internet
As we have noted, it is not recommended to use XAMPP other than local machine development. However, in case you still want it to be publicly visible on the internet for development purposes, or you might have correctly configured it, here is the guide.
The main point here is to create a Windows Firewall rule to allow XAMPP to be able to communicate with your Internet connection. By default, XAMPP might try to create the rules automatically for you (when you see the Windows Security Alert dialog), however, there might be times it doesn’t, and this is the solution.
Note: You might also have to configure your other firewall or antivirus programs to allow the ports created by XAMPP, and port-forwarding will be necessary too, we won’t go into details here and will try to make articles on this topic later.
First, open Windows Defender Firewall:
Right-click Inbound Rules > New Rule…
Choose Program on the first dialog if you want XAMPP to have full control over the ports (recommended by default). Otherwise, if you only want some ports to be allowed, choose Port.
If you choose Program:
- Pick the httpd.exe file in [XAMPP installation]\apache\bin\ folder:
- On the next Action step, choose Allow the connection.
- On the Profile step, choose the network you want to apply the rule to.
- Give it a name in the final Name step, eg. HTTP Server .
After finished, we will have the rule created. Below is the default rule created by XAMPP:
If you choose Port instead of Program, the process is not much different, on the Protocol and Ports step, you can pick TCP and enter 80 into Specific local ports (default recommended HTTP port), or other ports of your choice.
Change XAMPP installation PHP version
We have a detailed guide on how to change your PHP version of the XAMPP installation:
The tutorial is now over. We hope you can get XAMPP on Windows installed quickly to start your PHP development. We look forward to releasing many other helpful tutorials for PHP development on Windows systems.