How to configure PHP with the Apache Web Server

0 votes
With the help of code, can you tell me how to configure PHP with the Apache Web Server?
Dec 17, 2024 in PHP by Ashutosh
• 33,370 points
• 2,680 views

1 answer to this question.

0 votes

To configure PHP with the Apache Web Server, follow these steps based on your operating system:

1.Linux (Ubuntu-based systems):

Install Apache, PHP, and MySQL using the command:

sudo apt-get install apache2 php libapache2-mod-php php-mysql

Start Apache and MySQL services:

sudo systemctl start apache2

sudo systemctl start mysql

Ensure that PHP is properly configured by editing the php.ini file located in /etc/php/X/apache2/ (where X is the PHP version)​

2.Windows:

Download and install Apache HTTP Server.

Install PHP and extract it to a folder (e.g., C:\php).

Modify the Apache httpd.conf file to load PHP as a module by adding:

LoadModule php_module "C:/php/php8apache2_4.dll"

AddHandler application/x-httpd-php .php

PHPIniDir "C:/php"

Test the configuration by restarting Apache and creating a index.php file in the Apache web directory (usually C:/Apache24/htdocs) with the following content to display the PHP version:

<?php

  echo 'PHP version is ' . phpversion();

?>

Restart Apache and verify the setup by visiting localhost in a web browser

answered Dec 17, 2024 by Navya

Related Questions In PHP

0 votes
1 answer

How can I use Sockets.io on the client side and communicate with a PHP based application on the server?

Hello @kartik, For 'long-lived connection' , you can ...READ MORE

answered Aug 24, 2020 in PHP by Niroj
• 82,800 points
• 5,288 views
0 votes
1 answer

How to check if the request is an AJAX request with PHP?

Hello @kartik, Try below code snippet if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) ...READ MORE

answered Oct 29, 2020 in PHP by Niroj
• 82,800 points
• 16,875 views
0 votes
0 answers

PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client

I'm running MySQL version 8 on PHP ...READ MORE

Jun 18, 2022 in PHP by narikkadan
• 86,360 points
• 2,423 views
0 votes
1 answer

How to Validate Form Data With PHP?

Hey @kartik, The first thing we will do ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,800 points
• 6,015 views