Let us use docker to quickly build a PHP development environment!
- Make sure your host env has Docker installed.
- Port 80, 3306, 6379 is idle.
- Specify the PHP project directory.
In the root directory.
cp .env.example .env
And set the MySQL database name, pwd, redis pwd, and the directory where the files are stored. User directory is suggested just like:
DIR_WWW=/Users/<Your_user_name>/datas/php/www/
DIR_REDIS_DATA=/Users/<Your_user_name>/datas/php/redis/data/
DIR_MYSQL_DATA=/Users/<Your_user_name>/datas/php/mysql/
After doing this, start pulling the mirror image to make the container.👇
docker-compose up -d
If you're developing locally:
docker-compose -f docker-compose.local.yml up -d
docker-compose stop
docker-compose down
docker exec -it ct-phpfpm bash
cd <php_directory_in_phpfpm>
composer install
docker exec it <container-name> bash
// with redis-cli
redis-cli -h 127.0.0.1 -p 6379 -a <password>
// with mysqlsh
mysqlsh -uroot -p<password> -h 127.0.0.1 --mysql
// with mysql
mysql -uroot -p<password> -h 127.0.0.1 --mysql
- .env.example - Env variable file template.
- ./Dockerfile - Phpfpm docker mirror build file.
- ./docker-compose.yml - Docker marshals file.
- ./docker-compose.build.yml - Docker marshals file.(Local building)
- ./conf/mysql/mysql.cnf - MySQL configuration.
- ./conf/nginx/nginx.conf - Nginx configuration.
- ./conf/nginx/conf.d - Nginx site configuration directory.
- ./conf/php/php.ini - PHP configuration.
- ./log/mysql - MySQL log file.
- ./log/nginx - Nginx log file.
- ./log/supervisor - Supervisor log file.
- ./files - 163 Mirrors URL.
- MYSQL_ROOT_PASSWORD MySQL root_user pwd.
- MYSQL_DATABASE MySQL database name.
- REDIS_PASSWORD Redis pwd.
- DIR_WWW WEB project directory.
- DIR_REDIS_DATA Redis data storage directory.
- DIR_MYSQL_DATA Mysql data storage directory.
- PHP 7.2 build.
- Lavarel build.