LNMP 是代表 Linux 系統下的 Nginx、Mariadb、PHP 相結合而構建成的動(dòng)態(tài)網(wǎng)站服務(wù)器架構。下面使用docker制作分布式lnmp 鏡像。
#關(guān)閉防火墻及核心防護 systemctl disable firewalld systemctl stop firewalld setenforce 0 #查看3306、80及9000端口是否被占用 ss -natp | grep 3306 ss -natp | grep 80 ss -natp | grep 9000 #創(chuàng )建自定義網(wǎng)絡(luò ) 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/bash echo -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; include fastcgi_params; } }" > /etc/nginx/conf.d/default.conf nginx -s reload docker exec -it phpfpm /bin/bash mkdir -p /usr/share/nginx/html echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php
虛擬機輸入localhost/index.php
本機輸入 192.168.184.70/index.php (我虛擬機地址是192.168.184.70)
以上就是使用docker制作分布式lnmp 鏡像的詳細內容,更多關(guān)于docker分布式lnmp 鏡像的資料請關(guān)注腳本之家其它相關(guān)文章!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站