PHP Install

To start using PHP, you need to install it on your system. You can set up PHP manually or use pre-packaged environments like XAMPP, WAMP, or MAMP.

1. Installing PHP on Windows

Follow these steps to install PHP on Windows:

  1. Download the latest PHP version from the official PHP website.
  2. Extract the downloaded ZIP file to C:\php.
  3. Add C:\php to the Windows system PATH environment variable.
  4. Verify the installation using the command:
php -v

2. Installing PHP on macOS

macOS includes PHP by default, but you can install the latest version using Homebrew:

brew install php

3. Installing PHP on Linux

Use the following commands to install PHP on Linux:

# Ubuntu/Debian
sudo apt update
sudo apt install php

# CentOS/RHEL
sudo yum install php

4. Checking PHP Installation

After installation, verify PHP by running:

php -v

5. Creating a PHP Info File

Create a simple PHP file to check if PHP is working correctly:

<?php
phpinfo();
?>

Save the file as info.php and place it in your web server’s root directory (e.g., htdocs for XAMPP or www for WAMP). Then, open your browser and visit:

http://localhost/info.php

Conclusion

Now you have PHP installed and ready to use. You can start writing PHP scripts and develop dynamic web applications.