PHP and MySQL Setup

Setting up PHP and MySQL can be an intimidating task for novice web developers. Step-by-step instructions for installing PHP and MySQL on your local development environment are provided in this blog post. At the conclusion of this tutorial, you will have a fully functional PHP and MySQL environment on which you can build and test web applications. This guide will provide you with the knowledge and tools necessary to get started with "PHP mysqli."

To run a PHP script, you need a web server. And to work with databases, you need a database server.

So you have two options: either install PHP and MySQL separately or just install one software package like "XAMPP" that comes with all the necessary tools like a local server, a database server, etc.

In this series of PHP with mysqli tutorial, I am going to use XAMPP, which comes with both Apache and a MySQL server.

The reason I am going to use XAMPP is because of these:

XAMPP step-by-step setup guide

Download and install XAMPP from the Internet. Then open it (XAMPP Control Panel), and in the window you will see:

php mysqli setup

Click on the "Start" button next to "Apache" to start the Apache web server. Now we can execute PHP scripts.

Click on the "Start" button next to "MySQL" to start the MySQL database server. Now we can work with databases using the PHP script.

Here is the snapshot after starting both:

php mysqli setup xampp

However, you can also approach this another way to setup the PHP and MySQL environments for your system. That is, you can download and install PHP first from the website: https://www.php.net/downloads.php.

Then download and install MySQL from the website: https://dev.mysql.com/downloads/mysql/.

And finally, configure PHP to work with MySQL. So to configure PHP, in a text editor, open the php.ini file (located in your PHP installation directory). Remove the following comment:

extension=mysqli.dll
Or
extension=mysqli.so

Restart the web server after saving the changes.

One more thing that is recommended to mention before closing the discussion regarding this post is that, after downloading the PHP, select the components you want to install and launch the installer. The default settings are adequate for the majority of uses.

Then select the directory in which PHP should be installed. Usually, using the default directory is fine.

And finally, set the web server's options. You must include the following lines in your httpd.conf file if you're using Apache:

LoadModule php7_module "c:/php/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php"

Once again, I'm willing to tell you that you should prefer "XAMPP" instead of wasting time on such an installation.

Now that everything is set, it is time to create a database, which is explained in the next post or tutorial.

PHP Online Test


« Previous Tutorial Next Tutorial »


Liked this post? Share it!