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:
- Download the latest PHP version from the official PHP website.
- Extract the downloaded ZIP file to
C:\php
. - Add
C:\php
to the Windows system PATH environment variable. - 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.