


How do I install PHP on my operating system (Windows, macOS, Linux)?
Jun 20, 2025 am 01:02 AMThe method of installing PHP varies from operating system to operating system. The following are the specific steps: 1. Windows users can use XAMPP to install packages or manually configure them, download XAMPP and install them, select PHP components or add PHP to environment variables; 2. macOS users can install PHP through Homebrew, run the corresponding command to install and configure the Apache server; 3. Linux users (Ubuntu/Debian) can use the APT package manager to update the source and install PHP and common extensions, and verify whether the installation is successful by creating a test file.
Installing PHP on your system isn't as tricky as it might sound, especially once you know the right steps for your operating system. Whether you're using Windows, macOS, or Linux, there's a straightforward way to get PHP up and running.
Install PHP on Windows: Using XAMPP or Manual Setup
The easiest way to run PHP on Windows is by installing XAMPP , which bundles PHP, Apache, MySQL, and other tools together.
- Download XAMPP from http://miracleart.cn/link/a39911c27bc4f0f6bb476b41c29f4a72
- Run the installer and choose the components you need (make sure PHP is checked)
- After installation, start Apache from the XAMPP control panel
- Place your PHP files in the
htdocs
folder inside the XAMPP directory
If you prefer a manual install:
- Download the latest PHP version from http://miracleart.cn/link/750ed96f0d56d3346cda66d24bc0cbd5
- Extract the ZIP file and place it in a folder like
C:\php
- Edit the
php.ini
file to configure settings like extensions - Add PHP to your system PATH so you can use it from the command line
Install PHP on macOS: Built-in PHP or with Homebrew
macOS used to come with PHP pre-installed, but that's no longer guaranteed depending on your macOS version.
To check if PHP is already installed:
php -v
If not, the best option is to use Homebrew :
- Install Homebrew if you haven't already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Then install PHP with:
brew install php
This method installs PHP along with commonly used extensions. You can switch between versions if needed using brew link --force
.
You'll also want to set up a local server like Apache or Nginx to serve your PHP files. Apache comes built-in with macOS, so you can enable it with:
sudo apachectl start
Install PHP on Linux (Ubuntu/Debian): Using APT Package Manager
Most Linux distributions, especially Debian-based ones like Ubuntu, make it easy to install PHP via the terminal.
Start by updating your package list:
sudo apt update
Then install PHP with:
sudo apt install php
If you're building a web app, you probably want to install common extensions too:
-
php-cli
for command-line use -
php-mysql
to connect to MySQL databases -
php-curl
,php-gd
, etc., for various features
After installing, test it by creating a basic PHP file:
echo "<?php phpinfo();" > /var/www/html/info.php
Then open your browser and go to http://localhost/info.php
. If you see a PHP info page, you're good to go.
Depending on what you're trying to do—like developing a WordPress site or working on a Laravel project—you may need additional setup, but getting PHP itself installed is usually pretty quick.
Basically that's it.
The above is the detailed content of How do I install PHP on my operating system (Windows, macOS, Linux)?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To upgrade Filebeat to the latest version in the Debian operating system, you can refer to the following steps: Method 1: Refresh the APT package index with the help of APT package management tool and enter the following command to refresh the APT package index after opening the terminal: sudoaptupdate Execute the new version of Filebeat installation and run the following command to complete the installation of the new version of Filebeat: sudoaptinstallfilebeat check the installation status After the installation is completed, you can confirm the specific version of Filebeat: filebeatversion Method 2: Manually download and install to obtain the latest version of Filebeat Go to Fil on Elastic's official website

The main difference between Java and other programming languages ??is its cross-platform feature of "writing at once, running everywhere". 1. The syntax of Java is close to C, but it removes pointer operations that are prone to errors, making it suitable for large enterprise applications. 2. Compared with Python, Java has more advantages in performance and large-scale data processing. The cross-platform advantage of Java stems from the Java virtual machine (JVM), which can run the same bytecode on different platforms, simplifying development and deployment, but be careful to avoid using platform-specific APIs to maintain cross-platformity.

The installation and configuration of MySQL can be completed through the following steps: 1. Download the installation package suitable for the operating system from the official website. 2. Run the installer, select the "Developer Default" option and set the root user password. 3. After installation, configure environment variables to ensure that the bin directory of MySQL is in PATH. 4. When creating a user, follow the principle of minimum permissions and set a strong password. 5. Adjust the innodb_buffer_pool_size and max_connections parameters when optimizing performance. 6. Back up the database regularly and optimize query statements to improve performance.

How to stop Microsoft Edge Automatically Update Microsoft Edge is the default browser that comes with Windows 11. Earlier, the Edge browser received updates as the Windows operating system was updated. However, the Edge browser based on Chromium has changed that. The browser will now automatically update in the background without your knowledge. In this article, we will explain how to stop automatic Microsoft Edge updates in Windows 11 and macOS. Related: How to disable automatic updates in Google Chrome? Check for automatic edge updates Chromium-based Edge vs. Goo based on Chromium backend code

Entering CSGO HD blockbuster mode requires four steps: 1. Update the game client to the latest version; 2. Adjust the video settings to the highest parameters; 3. Start the game and enter high-definition mode; 4. Optimize performance and test adjustments. Through these steps, you can improve the gaming experience of CSGO and enjoy a clearer picture and a more immersive gaming environment.

In the Debian operating system, the integration of Filebeat and Elasticsearch can simplify the collection, transmission and storage of log data. The following are the specific implementation steps: Step 1: The first task of deploying Elasticsearch is to complete the installation of Elasticsearch in the Debian system. You can download the corresponding version of the Elasticsearch software package from the Elastic official website and complete the installation process according to the official guidance. Download and install Elasticsearchwgethttps://artifacts.elastic.co/downloads/elasticse

VSCode solves the problems of multilingual project coding and garbled code including: 1. Ensure that the file is saved with correct encoding and use the "redetection encoding" function; 2. Set the file encoding to UTF-8 and automatically detect the encoding; 3. Control whether to add BOM; 4. Use the "EncodingConverter" plug-in to convert encoding; 5. Use the multiple workspace functions to set encoding for different sub-projects; 6. Optimize performance and ignore unnecessary file monitoring. Through these steps, the coding problem of multilingual projects can be effectively dealt with.

Java middleware is a software that connects operating systems and application software, providing general services to help developers focus on business logic. Typical applications include: 1. Web server (such as Tomcat and Jetty), which handles HTTP requests; 2. Message queue (such as Kafka and RabbitMQ), which handles asynchronous communication; 3. Transaction management (such as SpringTransaction), which ensures data consistency; 4. ORM framework (such as Hibernate and MyBatis), which simplifies database operations.
