Setting up a local development environment with Apache, PHP, and MariaDB/MySQL on Windows allows you to develop and test web applications efficiently. This article will guide you through the installation and configuration process step-by-step.
C:\Apache24
C:\Apache24\conf\httpd.conf
file in a text editor.ServerRoot
directive to: ServerRoot "C:/Apache24"
Listen
directive to the desired port, e.g.,: Listen 80
ServerName
directive to: ServerName localhost:80
bin
directory: cd C:\Apache24\bin
httpd.exe -k install
httpd.exe -k start
C:\PHP
.php.ini-development
to php.ini
.php.ini
in a text editor and uncomment extension_dir = "ext"
extension=mysqli
Environment Variables
.System variables
, select Path
and click Edit
.C:\PHP
to the list.C:\Apache24\conf\httpd.conf
file in a text editor.LoadModule php_module "C:/PHP/php8apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP"
httpd.exe -k restart
php.ini
file in a text editor.extension=mysqli
and extension=pdo_mysql
pdo
only if you want to use PDO for connecting with mysqlhttpd.exe -k restart
info.php
in the C:\Apache24\htdocs
directory.info.php
<?php
phpinfo();
?>
Connect to MariaDB/MySQL
db_test.php
in the C:\Apache24\htdocs
directory.db_test.php
:<?php
$mysqli = new mysqli("localhost", "root", "your_password", "mysql");
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
echo "Connected successfully";
?>
Connected successfully
is displayed.You have successfully installed and configured Apache, PHP, and MariaDB/MySQL on your Windows machine. This setup will provide you with a robust local development environment for your web projects
Thankyou for reading!
© 2024 Khaalis Technologies. All Rights Reserved. Designed by HTML Codex