- Follow the instructions here: How To Run Your Entire Development Environment in Docker Containers on macOS
However you'll need to install MariaDB instead of MySQL 8.0 as at the time of writing MySQL doesn't run on the Mac M1 processor. (Anyway MariaDB is better). - To install MariaDB follow the instructions here: Apple M1 Chip to work with MariaDB docker image
The command to use to launch the docker MariaDB server container is:
docker run --restart always --name mysql-localhost --net dev-network -v /Users/[your_username]/Develop/mysql_data/8.0:/var/lib/mysql -v /Users/[your_username]/Develop/docker_configs/mysql:/etc/mysql/conf.d -p 3306:3306 -d -e MYSQL_ROOT_PASSWORD=[Root DB Password] mariadb
This is the command from the instructions from step 1 but specifying that we're using MariaDB instead of mysql:8.0 - At this point PHP should be working and you should be able to access the database using your database management application eg: Sequel Ace. So check that you can do this. However you'll probably find that PHP is not able to connect to the MariaDB database. So there are 2 more things that you'll need to do.
- Find the IP address of the mariaDB server:
docker inspect mysql-localhost | grep IPAddress
This is the address that you'll need to use for the server name in the mysqli_connect statement. - Create a DB user for php to use as I believe that the recent versions of MariaDB do not allow PHP to connect using the root user. See: How do I create a user with the same privileges as root in MySQL/MariaDB?
This has been a long project to develop a data driven game. Initially I wanted to the able to enter the game data using a website developed using CakePHP. The game itself would be developed in Unity 3D using the exported data. However this has now changed to the entire game being developed using CakePHP.. The posts that I've made are for things that I found difficult to solve and I've put them here for my own future reference. They are also for anyone else who might find them useful.
Saturday, January 15, 2022
Setting up Docker on Mac M1 to run Apache/PHP/Maria DB
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment