How to run a PHP and MySQL project on XAMPP
5 minute read
What you need
- A Windows laptop.
- XAMPP, which brings Apache, MySQL and PHP together. PHP 7.4 or any PHP 8 version works with our projects.
- A browser such as Chrome or Edge.
Install XAMPP the night before your defence, while you have internet. After that the project needs no internet.
The steps
- Install XAMPP and open the XAMPP Control Panel.
- Press Start beside Apache and beside MySQL. Both names turn green.
- Unzip your project. Copy its app folder into C:\xampp\htdocs and give it a short name with no spaces, for example car-wash.
- In your browser open http://localhost/car-wash/setup.php. Tick the box and press the button. This creates the database and the sample data.
- Open http://localhost/car-wash/login.php and sign in with one of the sample logins in your run instructions.
You only do the setup page once. On defence day, start Apache and MySQL and open the login page.
Common problems
- Apache will not start, or says port 80 is in use: another program is using the port, often Skype or IIS. Close it, or in the Control Panel press Config beside Apache, open httpd.conf, change Listen 80 to Listen 8080, and then use http://localhost:8080/ in the address.
- MySQL will not start: another MySQL is already running on the laptop. Stop it in Windows Services, then press Start again.
- The page shows PHP code instead of the screen: you opened the file from the folder. Type the address beginning with http://localhost/ instead.
- "Access denied" on the setup page: your XAMPP has a MySQL password. Put it in config.php, which the run instructions explain.
Showing two users at once
To show an admin and a member of staff side by side, use two different browsers, for example Chrome and Edge. Two tabs of the same browser share one sign-in, so the second sign-in would replace the first.