System: CENTOS7
Using the root account
Open 80 ports
Firewall-cmd--zone=public--add-port=80/tcp--permanent
Installing Docker
Yum Install Docker-y
Installing Docker-compose
Yum Install Epel-release-y
Yum install-y Python-pip
Pip install-u docker-compose
Deploying Nginx+php+mysql
Open Docker
Systemctl Start Docker
Cd/home
mkdir www//website directory
mkdir conf//config file
mkdir app//download app
Pull the official image
Docker Pull nginx:1.12.0
Docker Pull PHP:5.4-FPM
Docker Pull mysql:5.6
Download to/home/app
Go to the PHP website to download php5.4.45
Nginx official website Download nginx1.12.0
phpMyAdmin official website Download phpmyadmin find php corresponding version
After downloading and unpacking, enter the PHP file
CP Php.ini-development/home/conf/php.ini
Enter Nginx file
CP conf/nginx.conf/home/conf/nginx.conf
Cd/home/conf
VI nginx.conf
Location/{
Root /usr/share/nginx/html;
Index index.html index.php index.htm;
}
Location ~ \.php {//Remove $
Root /var/www/html;
Fastcgi_pass fpm: 9000;
Fastcgi_index index.php;
Fastcgi_split_path_info ^ (. +\.php) (. *) $; Nginx Add path_info Support
Fastcgi_param path_info $fastcgi _path_info;//nginx Add path_info support
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
Cd/home/app
Copy phpmyadmin extracted files to/home/www and renamed to phpMyAdmin
Writing Docker-compose
Cd/home
Docker images//view image ID
VI docker-compose.yml
Php:
image:php Image ID
Ports
-9,000:9,000
Volumes
-/home/www:/var/www/html
-/home/conf/php.ini:/usr/local/etc/php/php.ini
Links
-MySQL
Privileged:true
Nginx:
Image:nginx Image ID
Ports
-80:80
Volumes
-/home/www:/usr/share/nginx/html
-/home/conf/nginx.conf:/etc/nginx/nginx.conf
Links
-PHP:FPM
Privileged:true
Mysql:
Image:mysql Image ID
Ports
-3,306:3,306
Volumes
-/home/data:/var/lib/mysql
Environment:
-Mysql_root_password=123
Privileged:true
After the Docker-compose writing is complete
Perform
Docker-compose up-d//Make container run in background
Docker exec-it home_mysql_1 Bash//enter MySQL container
Mysql-u-root-p
Password: 123
Execution status
View the UNIX socket address and copy
Execute the use MySQL
Update user Set Host = '% ' where user = ' root ';
Flush privileges;
Ctrl+d two times after completion
Exit container
Cd/home/conf
VI php.ini
Search
Mysql.default
Mysqli.default
Pdo_mysql.default
After the equals sign, add the copied UNIX socket address
Cd/home
Docker-compose restart
CD www
VI index.php
<?php
Phpinfo ();
?>
View PHP Information
CD phpMyAdmin
VI config.sample.inc.php
$cfg [' Servers '] [$i] [' host '] = 'mysql';
config.sample.inc.php renamed to config.inc.php after exiting
External access to the HTTP://IP address/phpmyadmin/index.php
Log in to MySQL to complete the success
Docker Deployment Nginx+php+mysql