使用docker制作分布式lnmp 鏡像
LNMP 是代表 Linux 系統下的 Nginx、Mariadb、PHP 相結合而構建成的動態網站服務器架構。下面使用docker制作分布式lnmp 鏡像。
一、docker 分布式 lnmp 鏡像制作1、運行Nginx、MySQL、PHP容器#關閉防火墻及核心防護systemctl disable firewalldsystemctl stop firewalldsetenforce 0#查看3306、80及9000端口是否被占用ss -natp | grep 3306ss -natp | grep 80ss -natp | grep 9000#創建自定義網絡docker network create -d bridge --subnet 172.168.184.0/24 --gateway 172.168.184.1 lnmp#運行Nginx容器docker run -itd --name nginx --network lnmp -p 80:80 --ip 172.168.184.10 nginx:1.12.0#運行MySQL容器docker run -itd --name mysql --network lnmp -p 3306:3306 --ip 172.168.184.20 -e MYSQL_ROOT_PASSWORD=010230 mysql:5.7#運行PHP容器docker run -itd --name phpfpm --network lnmp -p 9000:9000 --ip 172.168.184.30 php:7.1-fpm
docker exec -it nginx /bin/bashecho -e 'server { listen 80; server_name localhost; location / {root /usr/share/nginx/html;index index.html index.htmi index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html {root /usr/share/nginx/html; } location ~ .php$ {root /usr/share/nginx/html;fastcgi_pass 172.168.184.30:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;includefastcgi_params; }}' > /etc/nginx/conf.d/default.confnginx -s reloaddocker exec -it phpfpm /bin/bashmkdir -p /usr/share/nginx/htmlecho '<?phpphpinfo();?>' > /usr/share/nginx/html/index.php
虛擬機輸入localhost/index.php
本機輸入 192.168.184.70/index.php (我虛擬機地址是192.168.184.70)
以上就是使用docker制作分布式lnmp 鏡像的詳細內容,更多關于docker分布式lnmp 鏡像的資料請關注好吧啦網其它相關文章!
相關文章:
1. IIS Express 取代 ASP.NET Development Server的配置方法2. IntelliJ Idea2017如何修改緩存文件的路徑3. IntelliJ IDEA設置條件斷點的方法步驟4. Python使用oslo.vmware管理ESXI虛擬機的示例參考5. Spring-Richclient 0.1.0 發布6. 淺談SpringMVC jsp前臺獲取參數的方式 EL表達式7. python flask框架快速入門8. HTML <!DOCTYPE> 標簽9. 一篇文章帶你了解JavaScript-對象10. Express 框架中使用 EJS 模板引擎并結合 silly-datetime 庫進行日期格式化的實現方法
