Docker deployment of nginx + php + mysql and dockernginx
System: centos7
Use root Account
Open Port 80
Firewall-cmd -- zone = public -- add-port = 80/tcp -- permanent
Install docker
Yum install docker-y
Install docker-compose
Yum install epel-release-y
Yum install-y python-pip
Pip install-U docker-compose
Deploy nginx + php + mysql
Start docker
Systemctl start docker
Cd/home
Mkdir www // website directory
Mkdir conf // configuration file
Mkdir app // The downloaded Application
// 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 php official website to download php5.4.45
Nginx official website download nginx1.12.0
Download the phpmyadmin official website and find the php version.
After downloading and decompressing the files, go to the PHP file.
Cp php. ini-development/home/conf/php. ini
Enter the 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 supports adding path_info
Fastcgi_param PATH_INFO $ fastcgi_path_info; // nginx support for adding path_info
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
Cd/home/app
Copy the file decompressed by phpmyadmin to/home/www and change it to phpmyadmin.
// Write docker-compose
Cd/home
Docker images // view the image id
Vi docker-compose.yml
Php:
Image: php image id
Ports:
-9000: 9000
Volumes:
-/Home/www:/var/www/html
-/Home/conf/php. ini:/usr/local/etc/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. conf
Links:
-Php: fpm
Privileged: true
Mysql:
Image: mysql image id
Ports:
-3306: 3306
Volumes:
-/Home/data:/var/lib/mysql
Environment:
-MYSQL_ROOT_PASSWORD = 123
Privileged: true
After docker-compose is compiled
Run
Docker-compose up-d // run the container in the background
Docker exec-it home_mysql_1 bash // enter the mysql container
Mysql-u-root-p
Password 123
Execute status
View and copy the UNIX socket address
Run use mysql
Update user set Host = '%' where User = 'root ';
Flush privileges;
Ctrl + d twice after completion
Exit container
Cd/home/conf
Vi php. ini
Search
Mysql. default
Mysqli. default
Pdo_mysql.default
Add the copied UNIX socket address after the equal sign
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 ';
After exiting, change config. sample. inc. php to config. inc. php.
Access http: // ip address/phpmyadmin/index. php from outside
Log on to mysql.