Simple one-line solution to installing and setting up PHP, Apache, and MySQL on any operating system.
- Download and install Docker Desktop
- Have Docker running
- Have git installed and setup (see Your Identity for setup)
I highly suggest you keep your own repo so you have your own version control and a backup of your code. So if you don't have a github account, now is your time to make one.
- Fork this repository
- Navigate to where you want to store your code in terminal and clone your new repository with
git clone <repoURL>
(you can find this url by clicking the gree "Code" button) - Once your repo is done downloading, navigate inside of it using
cd <name-of-repo>
- Run
docker compose up
- Once docker finishes, your site will be live at
localhost:8000
That's it! You're done.
Whenever you need to shutdown the container, do control + C
in the terminal running it, and to reboot it use docker compose up
.
Now that docker is setup and running, you'll want to open a VSCode instance inside your repo.
Navigate to index.php
this is where you will be coding.
To use MySQL to create tables and data, you'll need to get inside the docker container to access MySQL. Open Docker Desktop and select the 3 dots beside db
and "Open in terminal"
From inside you can run mysql -uroot -ppassword
to access your instance of MySQL, in index.php
mysqli is currently looking for a database called test
, why don't we make that database as practice.
- Create database with
CREATE DATABASE test;
- Select your database with
USE test;
- Create new table following this guide
Upon refreshing your browser you should see that the database connected successfully, now follow this guide to start using mysqli!