To verify the installation, create a PHP file with the ".php" extension and add following PHP code:
<?php phpinfo(); ?>
Place this file in your web server's document root directory and access it through a browser. If the PHP code executes correctly, PHP is successfully installed on your system.
Here is an example of what you will see if PHP is installed correctly.
(Click to enlarge..)
On A Windows OS:
To install PHP on a Windows system, you can follow these steps.
First, download the Windows PHP binary package from the official PHP website. Choose the version that matches your system architecture (32-bit or 64-bit).
Extract the downloaded ZIP file to a directory of your choice, such as C:\php.
Next, rename the file "php.ini-development" to "php.ini" and open it in a text editor. Configure PHP settings according to your requirements, such as enabling extensions or specifying the error log file location.
Additionally, add the PHP directory to the system's PATH environment variable for easier command-line access. To do this, right-click on "This PC" or "My Computer," go to Properties, click on "Advanced system settings," select the "Environment Variables" button, and append the PHP directory to the "Path" variable.
Finally, restart any web server services you may have running, such as Apache or IIS, for the changes to take effect. You can then test the installation by creating a simple PHP file and accessing it through a web browser.
On a MAC:
To install PHP on a Mac, you can follow these steps.
Mac systems come with PHP pre-installed, but it's recommended to use a more up-to-date version.
You can use package managers like Homebrew or MacPorts for an easier installation process.
First, make sure you have Homebrew or MacPorts installed on your system. Then, open the terminal and update the package manager by running the respective command (e.g., "brew update" for Homebrew).
Once updated, use the package manager to install PHP by running the appropriate command (e.g., "brew install php" for Homebrew). The package manager will download and install PHP and its dependencies automatically.
After the installation is complete, you can verify PHP by opening the terminal and running the "php -v" command, which will display the installed PHP version. Additionally, you may need to configure your web server (such as Apache or Nginx) to work with PHP.
On a Linux OS.
To install PHP on a Linux system, you can follow these general steps.
First, open the terminal and update your package manager by running the appropriate command based on your Linux distribution (e.g., "sudo apt update" for Debian/Ubuntu or "sudo dnf update" for Fedora). Once the package manager is updated, you can install PHP by running the corresponding command (e.g., "sudo apt install php" for Debian/Ubuntu or "sudo dnf install php" for Fedora). The package manager will fetch the necessary PHP packages and their dependencies and install them on your system. After the installation is complete, you can verify PHP by opening the terminal and running the "php -v" command, which will display the installed PHP version. Additionally, depending on your specific requirements, you may need to install additional PHP extensions or configure your web server (such as Apache or Nginx) to work with PHP.