Configuring Apache, MongoDB, and PHP on Windows 11 involves several steps. Before you proceed, ensure that you have the necessary software installed on your system. Here’s a step-by-step guide:
1. Install Apache:
- Download the latest version of Apache HTTP Server from the official Apache website (https://httpd.apache.org/download.cgi).
- Run the installer and follow the on-screen instructions. During installation, you’ll be prompted to set up the server domain and port.
- After installation, start the Apache server and check if it’s running by accessing http://localhost in your web browser.
2. Install PHP:
- Download the latest version of PHP for Windows from the official PHP website (https://windows.php.net/download/).
- Extract the downloaded ZIP file to a directory of your choice.
- Rename the file
php.ini-developmenttophp.iniand make necessary configuration changes in this file according to your needs. Ensure that you uncomment theextension_dirdirective. - Add the PHP directory to the system’s PATH variable.
- Restart the Apache server to apply the PHP configuration.
3. Install MongoDB:
- Download the MongoDB Community Server from the official MongoDB website (https://www.mongodb.com/try/download/community).
- Run the installer and follow the installation instructions. During installation, you can choose to install MongoDB as a service.
- After installation, start the MongoDB service.
4. Configure Apache to Work with PHP:
1 – Open the Apache configuration file (httpd.conf), which is usually located in the Apache conf directory.
2 – Add the following lines to the configuration file to enable PHP:
LoadModule php_module "path/to/php7apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/path/to/php"
3 – Save the configuration file and restart the Apache server.
5. Test the Configuration:
1 – Create a new PHP file (e.g., index.php) in your Apache document root directory (usually “htdocs”).
2- Add the following PHP code to test the setup:
<?php
phpinfo();
?>
3- Access this file in your browser (http://localhost/index.php) and check if it displays PHP information.
6. Test MongoDB Connection:
- Create a new PHP file with MongoDB connection code to ensure that PHP can communicate with MongoDB.
- Test the file in your browser and check for any errors.
By following these steps, you should have Apache, PHP, and MongoDB configured and working together on your Windows 11 system.