# How to install PHP step by step

The [open source](https://www.ionos.com/digitalguide/server/know-how/what-is-open-source/ "What is open source?") scripting language [PHP](https://www.ionos.com/help/hosting/managing-php-versions-in-the-control-panel/what-is-php/ "What is PHP? — IONOS Help") can be installed and used on all common operating systems. If you meet all the system requirements, you can just download your desired PHP version. On Unix and Windows, it takes just three steps to install PHP.

## What you need to run PHP

Your system must meet specific **requirements** to run PHP. These may differ depending on your operating system. So before you get started installing PHP, check the system requirements. Some of them will apply to all operating systems. For example, to run PHP, you need a **web server**. You can [set up the Apache web server](https://www.ionos.com/digitalguide/server/configuration/how-to-install-an-apache-web-server/ "How to install an Apache web server") for this purpose. **In most cases, a database** such as [MySQL or MariaDB](https://www.ionos.com/digitalguide/hosting/technical-matters/mariadb-vs-mysql/ "MariaDB vs. MySQL") will also be needed.

---

### Tip

With [IONOS Web Hosting](https://www.ionos.com/hosting/web-hosting "IONOS Web Hosting") all PHP versions from version 4+ are supported for your web development goals. [Register your domain](https://www.ionos.com/domains/domain-names "Register your domain with IONOS") and benefit from an integrated wildcard SSL certificate.

---

### UNIX-based systems

Installing PHP on UNIX systems like Linux doesn’t require much additional work. [Linux](https://www.ionos.com/digitalguide/server/know-how/linux-the-cost-effective-alternative-to-windows/ "Linux – the cost-effective alternative to Windows") and the most common [Linux distributions](https://www.ionos.com/digitalguide/server/configuration/linux-distributions/ "Linux distributions") provide most of the components you need. Only an **ANSI C compiler and module-specific components** such as PDF libraries may need to be installed manually.

### Windows

To install PHP on Windows, first ensure that your Windows version is **compatible** with PHP. All versions released after Windows 2008 or Windows Vista provide basic compatibility for PHP 7.2.0+.

On Windows you need the option to deal with C code. To set this up, download **Visual C Runtime** or **C Runtime Files (CRT)**. You also need a suitable Visual Studio version. For most common PHP versions, Microsoft Visual C++ Redistributable for Visual Studio 2019 is a suitable choice.

### macOS

Provided you own a Mac, you don’t need to do anything else to install PHP. The scripting language is **included** in modern macOS versions.

## Download PHP

If your system meets the requirements, download the **PHP version of your choice**. There are several versions available for manual download from the [official PHP website](https://www.php.net/downloads "PHP website"). Download is necessary on Windows. On Linux, installation and download can be performed via the command line. On macOS, PHP is pre-installed.

Be sure to **select the right link** to download PHP for Windows.

[![Image: Screenshot of the official PHP website](https://www.ionos.com/digitalguide/fileadmin/_processed_/a/e/csm_PHP-download_3c5d78d41b.webp "Screenshot of the official PHP website")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/PHP-download.png) Use the “Windows downloads” link to install PHP on Windows. / Source: https://www.php.net/downloads       ##  Which PHP version is the correct one?

Unless you’re [learning PHP](https://www.ionos.com/digitalguide/websites/website-creation/learn-php-our-all-encompassing-php-tutorial-for-beginners/ "Learn PHP: our all-encompassing PHP tutorial for beginners") for the first time, it’s recommended to download the “**Current Stable**” version. That’s the latest PHP version out of beta which runs error-free (as far as is known). Right now, the latest stable version is [PHP 8](https://www.ionos.com/digitalguide/websites/web-development/php-8/ "PHP 8"). Although beta versions offer more features, they can be **quite buggy**. It’s best not to [update your PHP version](https://www.ionos.com/digitalguide/websites/web-development/update-php-version-and-cancel-php-extended-support/ "Update PHP version and cancel PHP Extended Support") until the end of beta testing.

If you’re installing PHP for a specific purpose, for example, for existing projects or to use the [best WordPress plugins 2022](https://www.ionos.com/digitalguide/hosting/blogs/wordpress-plugins/ "WordPress plugins"). Check which PHP version is recommended. Currently, the “**Old stable” version 7.4** is considered most compatible with WordPress.

---

### Tip

Decided to use [PHP 7](https://www.ionos.com/digitalguide/websites/web-development/how-php7-speeds-up-the-internet/ "How PHP7 speeds up the internet")? Then you can’t go wrong with system-independent [PHP 7 Hosting from IONOS](https://www.ionos.com/hosting/php-web-hosting "IONOS PHP 7 Hosting"). Older PHP versions are also supported.

---

## Install PHP on Linux step by step

You can install PHP on Linux using the terminal. The process is quick and simple. Knowing the [most important Linux terminal commands](https://www.ionos.com/digitalguide/server/configuration/linux-commands-an-overview-of-terminal-commands/ "Linux commands: An overview of terminal commands") will come in handy. The following step-by-step instructions refer to the installation of PHP under Linux distribution Ubuntu.

### Step 1: Update system and package

First, ensure that your system and all packages are **up to date**. To do this, use the following terminal commands:

```none
sudo apt-get update
sudo apt-get upgrade
```

The terminal will prompt you to enter your **password**, after which your system will be updated.

### Sep 2: Install PHP

Now, PHP needs to **be installed**. Use the following command to do so:

```none
sudo apt-get install php
```

Installation must be confirmed **manually in the terminal** and is then executed automatically.

[![Image: Screenshot of Ubuntu terminal after entering the installation command for PHP](https://www.ionos.com/digitalguide/fileadmin/_processed_/b/3/csm_PHP-installation-bestaetigen_53505eb475.webp "Screenshot of Ubuntu terminal after entering the installation command for PHP")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/PHP-installation-bestaetigen.png) Confirm installation of PHP in the terminal.       ###  Step 3: Check PHP version

Once you’ve installed PHP, you can easily check which **version** you’re using:

```none
php -v
```

### An alternative under Ubuntu is to install LAMP stack

Depending on purpose, you may want to download and install a **LAMP server**. This way you get the PHP, Apache web server and MySQL all in one. Use the following commands:

```none
sudo apt install tasksel
sudo tasksel install lamp-server
```

After you’ve installed the Tasksel setup tool, the second command installs the [LAMP server](https://www.ionos.com/digitalguide/server/know-how/lamp-servers-the-solution-for-dynamic-websites/ "LAMP servers – the solution for dynamic websites") including PHP in a single step.

[![Image: Screenshot of Ubuntu terminal after entering the installation command for Tasksel and the LAMP server](https://www.ionos.com/digitalguide/fileadmin/_processed_/5/1/csm_Installation-Tasksel_8a931e1058.webp "Screenshot of Ubuntu terminal after entering the installation command for Tasksel and the LAMP server")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/Installation-Tasksel.png) The terminal prompts you to confirm installation of Tasksel by pressing the “Y” key.       ##  Special features of other Linux distributions

Generally, **installation of PHP isn’t all that different between the various Linux distributions**. But there are some small differences.

### Debian

The installation of PHP under Debian will work using the above commands. In addition to the **apt-get** command, there’s the **aptitude** command. This is a package manager that provides a menu interface, but doesn’t differ much from apt-get otherwise.

The command to install PHP using aptitude is:

```none
sudo aptitude install php
```

### CentOS

The Linux distribution CentOS uses a different package manager, **yum**, and thus requires slightly different commands to install PHP. But the steps you use to install PHP are otherwise **identical**.

First, update your system and packages:

```none
sudo yum install epel-release
sudo yum update
```

Installing PHP uses a similar command to Ubuntu:

```none
sudo yum install php
```

## How to install PHP on Windows

You’ve got several options to install PHP on your Windows system. Besides manual configuration with the Internet Information Service (IIS), you can download the **Microsoft Web Platform Installer** and add PHP via the graphical user interface.

### Step 1: Download Microsoft Web Platform Installer

Download [Microsoft Web Platform Installer](https://docs.microsoft.com/en-us/iis/install/web-platform-installer/web-platform-installer-direct-downloads "Download WebPI"). Follow the steps as prompted in the installation program.

### Step2: Adding PHP to Web Platform Installer

Open the application and click on the “Products” tab. In the search box at the top left, you can **search for your favorite PHP version**. Select it from the list. To ensure PHP is listed under the “**Documents to install**” button click “Add”.

[![Image: Screenshot of the “Products” tab in the Microsoft Web Platform Installer with “Add” option](https://www.ionos.com/digitalguide/fileadmin/_processed_/5/e/csm_PHP-beim-web-plattform-installer-hinzufuegen_8aade40fd2.webp "Screenshot of the “Products” tab in the Microsoft Web Platform Installer with “Add” option")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/PHP-beim-web-plattform-installer-hinzufuegen.png) Find your favorite PHP version and click “Add”.       ###  Step 3: Install PHP

PHP is now shown in the list of your documents to be installed. Clicking “Install” at the bottom right will begin **automatic installation of the PHP version** you’ve selected. Restart your computer to complete installation.

[![Image: Screenshot of “Products” tab in the Microsoft Web Platform Installer with “Install” option](https://www.ionos.com/digitalguide/fileadmin/_processed_/a/f/csm_PHP-installieren_5193e2a71c.webp "Screenshot of “Products” tab in the Microsoft Web Platform Installer with “Install” option")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/PHP-installieren.png) Install your chosen PHP version by clicking the “Install” button.       ###  Alternative under Windows — XAMPP

Like on Linux, PHP can be used on Windows by installing everything you need for the LAMP stack. You can use the **XAMPP** program to do this.

---

### Tip

Find out what you need for installation in our [XAMPP tutorial](https://www.ionos.com/digitalguide/server/tools/xampp-tutorial-create-your-own-local-test-server/ "XAMPP tutorial: create your own local test server").

---

## Install PHP on macOS

Since PHP is pre-installed on macOS, you don’t need step-by-step instructions. To use PHP on macOS, just remove the comment symbol in two lines of the **Apache configuration file** that are significant for the setup of PHP.

You can usually find the configuration file via the ***/private/etc/apache/httpd.conf*** path. Once you’ve opened the file with an editor of your choice, look for the following two lines:

```none
# LoadModule php7_module libexec/httpd/libphp7.so
# AddModule mod_php7.c
```

By removing the hashtag, you resolve the comment status of the two lines of code so that they can be read by the interpreter. Note that the **PHP version number may differ depending on which macOS version** you use.


This is a markdown version of: [https://www.ionos.com/digitalguide/websites/web-development/install-php/](https://www.ionos.com/digitalguide/websites/web-development/install-php/) for AI/LLM consumption.