這篇文章將為大家詳細(xì)講解有關(guān)win10 docker-toolsbox如何搭建php開發(fā)環(huán)境,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)企業(yè)建站,十多年網(wǎng)站建設(shè)經(jīng)驗,專注于網(wǎng)站建設(shè)技術(shù),精于網(wǎng)頁設(shè)計,有多年建站和網(wǎng)站代運營經(jīng)驗,設(shè)計師為客戶打造網(wǎng)絡(luò)企業(yè)風(fēng)格,提供周到的建站售前咨詢和貼心的售后服務(wù)。對于網(wǎng)站設(shè)計制作、做網(wǎng)站中不同領(lǐng)域進(jìn)行深入了解和探索,創(chuàng)新互聯(lián)在網(wǎng)站建設(shè)中充分了解客戶行業(yè)的需求,以靈動的思維在網(wǎng)頁中充分展現(xiàn),通過對客戶行業(yè)精準(zhǔn)市場調(diào)研,為客戶提供的解決方案。
下載鏡像
docker pull MySQL:5.7 docker pull php:7.2-fpm docker pull nginx docker pull redis:3.2
設(shè)置共享文件
宿主機創(chuàng)建目錄
E:\wnmp\mysql57\conf E:\wnmp\mysql57\log E:\wnmp\php72\conf E:\wnmp\php72\conf E:\wnmp\nginx\conf E:\wnmp\nginx\conf E:\wnmp\www
vmware設(shè)置文件共享
如圖
設(shè)置完成在Docker Quickstart Termina 執(zhí)行 docker-machine restart default
安裝Mysql
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name mysql57 mysql:5.7
復(fù)制配置文件
PS C:\Windows\system32> docker cp mysql57:/var/log/mysql E:\wnmp\mysql57\log PS C:\Windows\system32> docker cp mysql57:/etc/mysql E:\wnmp\mysql57\conf
重新安裝mysql并指定配置文件
PS C:\WINDOWS\system32> docker stop mysql57 mysql57 PS C:\WINDOWS\system32> docker rm mysql57 mysql57 PS C:\WINDOWS\system32> docker run -d -v /wnmp/mysql57/log:/var/log/mysql/ -v /wnmp/mysql57/conf:/etc/mysql/ -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name mysql57 mysql:5.7
初始化數(shù)據(jù)庫
docker exec -ti mysql57 /bin/bash mysql_secure_installation #查看Mysql狀態(tài) root@d7bd0712bcf8:/# mysql -uroot -proot mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.28 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
安裝PHP
PS C:\WINDOWS\system32> docker run -d -v /wnmp/www:/var/www/html -p 9000:9000 --link mysql57:mysql --name php72 php:7.2-fpm
復(fù)制配置文件
PS C:\Windows\system32> docker cp php72:/usr/local/etc E:\wnmp\php72\conf PS C:\Windows\system32> docker cp php72:/usr/local/var/log E:\wnmp\php72\log PS C:\Windows\system32> docker cp php72:/var/www/html E:\wnmp\www
重新安裝PHP并指定配置文件
PS C:\WINDOWS\system32> docker stop php72 php72 PS C:\WINDOWS\system32> docker rm php72 php72 docker run -d -v /wnmp/php72/conf/etc:/usr/local/etc -v /wnmp/php72/log:/usr/local/var/log -v /wnmp/www:/var/www/html -p 9000:9000 --link mysql57:mysql --name php72 php:7.2-fpm # 查看PHP版本 PS C:\Windows\system32> docker exec -ti php72 /bin/bash root@742150f14d8a:/var/www/html# php -v PHP 7.2.23 (cli) (built: Oct 5 2019 00:31:47) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies Ngixn
安裝
PS C:\WINDOWS\system32> docker run -d -p 80:80 --link php72:phpfpm --name nginx nginx:latest
復(fù)制配置文件
PS C:\Windows\system32> docker cp nginx:/etc/nginx/ E:\wnmp\nginx\conf PS C:\Windows\system32> docker cp nginx:/var/log/nginx/ E:\wnmp\nginx\log
重新安裝并指定配置文件
PS C:\WINDOWS\system32> docker stop nginx nginx PS C:\WINDOWS\system32> docker rm nginx nginx PS C:\WINDOWS\system32> docker run -d -p 80:80 -v /wnmp/www:/var/www/html -v /wnmp/nginx/conf/nginx:/etc/nginx/ -v /wnmp/nginx/log:/var/log/nginx/ --link php72:phpfpm --name nginx nginx #瀏覽器訪問 http://192.168.99.100/ 驗證成功 Redis docker run -p 6379:6379 -d redis:3.2 redis-server
PHP擴展安裝
redis PS C:\Windows\system32> docker exec -ti php72 /bin/bash root@742150f14d8a:/var/www/html# pecl install -o -f redis #安裝完成,加入Ini配置 此時docker下的redis配置 在 E:\wnmp\php72\conf\etc\php\conf.d\docker-php-ext-sodium.ini # 重啟php
配置測試域名
#E:\wnmp\nginx\conf\nginx\conf.d目錄下新建test.conf
#E:\wnmp\www目錄新建test目錄。目錄下新建index.php 輸出phpinfo;
server {
listen 80;
server_name test.com;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/html/test;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html/test;
fastcgi_pass 192.168.99.100:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
#nginx重新加載配置 或者重啟。
#本地host解析域名test.com 訪問 顯示phpinfo正常以上為所有安裝配置以及測試。當(dāng)然最后我們需要將這些docker容器加入到自動啟動中
docker container update --restart=always php72 docker container update --restart=always mysql57 docker container update --restart=always nginx docker container update --restart=always redis
關(guān)于“win10 docker-toolsbox如何搭建php開發(fā)環(huán)境”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
分享題目:win10docker-toolsbox如何搭建php開發(fā)環(huán)境
本文URL:http://chinadenli.net/article12/jpssdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、靜態(tài)網(wǎng)站、微信公眾號、小程序開發(fā)、網(wǎng)站維護(hù)、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)