To install PHP in Linux, you can follow these steps:
- Update the package manager’s package list by running the following command:
sudo apt update
- Install the PHP package by running the following command:
sudo apt install php
This will install the latest version of PHP, as well as any necessary dependencies.
- To verify that PHP has been installed successfully, you can run the following command:
This will output the version of PHP that has been installed.
- To use PHP with a web server such as Apache or Nginx, you will also need to install and configure the web server. For more information, consult the documentation for your chosen web server.
Alternatively, you can use a package manager such as
dnf on CentOS or Fedora systems, or
pacman on Arch Linux systems, to install PHP. Consult the documentation for your package manager for more information.