Section 0: Module Objectives or Competencies
Course Objective or Competency |
---|
The student will be able to set up their own local development environment include an Apache web server, PHP, MariaDB, and phpMyAdmin. |
Section 1: Overview
In order to develop our database project most conveniently, you'll set up your own development environment.
This development environment will consist of the following package:
- The Apache web server processes incoming requests from users and sends back pages of a web sites.
- MariaDB is a database management system, and is the open source version of MySQL.
- PHP is an environment for running server side PHP scripts that allow you to create highly functional websites, dynamic web applications, save data to a database and request data from there.
-
phpMyAdmin is an administration tool for MySQL and MariaDB that runs on PHP.
- With phpMyAdmin, you can view databases, create new databases and tables, populate and delete them, make backup copies of databases and restore from backups.
- Alternatives are MySQL Workbench and Heidi.
In the following sections we'll explain how to download and install each of these packages.
I strongly recommend that you also install a text editor like Notepad++, and some of the upcoming steps assume that you have done so.
Section 2: Set Up Apache Web Server
Begin by navigating to the Apache Lounge and downloading Apache.
- Just above the "binaries" section, download Visual C++ Redistributable Visual Studio 2015-2022: vc_redist_x64 or vc_redist_x86.
-
Once the download is complete, you can install the C++ Redistributable immediately.
- Double click the VC_redist zip file.
- In the pop-up window, agree to the terms and conditions and click Install.
- It asks that you restart your computer before using the software. You can do it now or later.
- In the "binaries" section, choose the Win64 or Win32 version of the zip files (the first for 64-bit systems, and the second for 32-bit).
Double click the downloaded apache httpd zip file and extract it to to C:\.
Using Windows File Explorer, navigate to the C:\Apache24\conf folder, right click on http.conf, and select "Edit with Notepad++".
- Use Ctrl+F to search for #ServerName www.example.com:80.
- Delete the leading #, and change www.example.com to localhost.
- The final line should read ServerName localhost
- Save the file.
Open the Command Prompt as an Administrator (here's how).
- In the command window, type or paste cd C:\Apache24\bin and hit Enter.
- Then type or paste httpd.exe -k install
- If the result resembles the following, everything is fine:
Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started. - Now you need to start the Apache service by typing or pasting httpd.exe -k start in the command window.
- Do not close the command window.
- In your browser's address bar, enter or paste (or click this link) http://localhost and if the resulting page says "It works!" then you have successfully installed Apache!
Section 3: Set Up MariaDB
Begin by navigating to the MariaDB Foundation. Scroll down until you see the MariaDB Server 10.9.3. The defaults should be fine if you are using Windows. Click the Download button and have it save the .msi file.
- When the download is complete, double click the .msi file to start the Setup Wizard.
- In the Setup Wizard, click Next to begin the setup process.
- In screen 2, check the box to accept the terms and then click Next.
- In screen 3, under third party tools click the arrow next to HeidiSQL and select "Entire feature will be unavailable" to avoid installing HeidiSQL and click Next. (You can use HeidiSQL if you wish, but I will not be able to provide any assistance with it.)
- In screen 4, enter a password for root (and make a note of it), click "Use UTF8" and then click Next.
- In screen 5, the "Default instance properties" should be fine, so click Next.
- In the penultimate screen, click Install to finally begin the installation process.
- Finally, click the Finish button in the final screen and you have completed the MariaDB installation.
Section 4: Set Up PHP
Begin by navigating to the PHP site and scrolling down to the VS16 x64 Thread Safe section or VS16 x86 Thread Safe section. Download VS16 x64 Thread Safe or VS16 x86 Thread Safe zip file (Do not download the Debug Pack or the Non Thread Safe version).
- When the download is complete, extract "php-8.1.10-Win32-vs16-x64.zip" to C:\PHP
- In Windows File Explorer, navigate to C:\PHP and rename php.ini-development to php.ini
-
Right click php.ini and select "Open with Notepad++"
- In Notepad++ search for ;extension_dir = "ext" and edit it to delete the leading ; and change the text to extension_dir = "C:\PHP\ext"
-
While in Notepad++, enable some extensions by searching for the following strings, and
deleting the ; at the beginning of each line.
- ;extension=mbstring
- ;extension=mysqli
- ;extension=openssl
- ;extension=pdo_mysql
- In Windows File Explorer, navigate to C:\Apache24\conf\.
-
Right click httpd.conf and select "Open with Notepad++"
-
Insert the following lines after all the LoadModule lines (approximately line 186):
LoadModule php_module C:/PHP/php8apache2_4.dll
DirectoryIndex index.html default.php index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP"
- Save the file.
-
Insert the following lines after all the LoadModule lines (approximately line 186):
-
Return to (or reopen) the command window.
- In the command window, type or paste cd C:\Apache24\bin and hit Enter.
- Then type or paste httpd.exe -k restart in the command window to restart the Apache service.
-
Next, create a new file in Notepad++ and type or paste the following:
<?php
Save the file as info.php in the C:\Apache24\htdocs folder
phpinfo();
?> - In your browser's address bar, enter or paste (or click this link) http://localhost/info.php and if the resulting page displays a table of PHP details, then you have successfully installed PHP!
Section 5: Set Up phpMyAdmin
Begin by navigating to the phpMyAdmin site and near the top right corner click the green Download button (I selected 5.1.3) and click Save.
- When the download is complete, extract the "phpMyAdmin-5.2.0-all-languages.zip" file to C:\Apache24\htdocs
- When the extraction is (eventually) complete, use Windows File Explorer to navigate to C:\Apache24\htdocs and then rename the folder phpMyAdmin-5.2.0-all-languages to phpMyAdmin
- In your browser's address bar, enter or paste (or click the following link) http://localhost/phpMyAdmin and if the resulting page should be the login page for phpMyAdmin. (I recommend bookmarking this link.)
- Enter root as the username, and the password you created earlier as the password.
- You can now access phpMyAdmin to create, delete, query, and modify databases.
- You have now finished setting up your own localhost!