How to Install PHP Without Apache
* Web 2.0 University is supported by it's audience. If you purchase through links on our site, we may earn an affiliate commision.
PHP can be installed independently without Apache. Here are the steps to install PHP on a Unix-based system such as Linux. If you’re using a Windows system, the steps are a bit different but the concept is the same.
## Update your package manager. Before you start, it’s a good idea to update your package manager to ensure you’re getting the latest software. On an Ubuntu system, you would use the following command:
sudo apt update
On CentOS, you would use:
sudo yum update
Install PHP.
On Ubuntu, you can install PHP with this command:
sudo apt install php
On CentOS, you would use:
sudo yum install php
Verify the installation.
You can verify your PHP installation by running:
php -v
This should display the PHP version that you’ve installed.
Please note that without a web server like Apache or Nginx, you won’t be able to serve PHP web pages. However, you can still use PHP for command-line scripts or as an interpreter for PHP files.
If you want to run PHP for web development without installing a web server, you can use PHP’s built-in server for development purposes. Navigate to your project’s directory in the terminal and then run the following command:
php -S localhost:8000
This will start a web server at localhost on port 8000, and you can access your PHP files in your web browser at that address. Please note that PHP’s built-in server should not be used for production environments; it’s designed for development use only.