91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

docker-compose部署LNMP

發布時間:2020-06-29 03:18:46 來源:網絡 閱讀:492 作者:qq5bb2021f831d3 欄目:云計算

實驗前準備:
下載:
[root@localhost ~]# curl -L https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-`uname -s-uname -m` -o /usr/local/bin/docker-compose
[root@localhost ~]# chmod +x /usr/local/bin/docker-compose
[root@localhost ~]# docker-compose -v
docker-compose version 1.25.1-rc1, build d92e9bee

//導入鏡像
[root@localhost?~]#?docker??load???<??nginx.tar??&&??docker??load?<??php.7.2-fpm.tar??&&??docker?load??<??mysql-5.7.tar?

//復制配置文件
[root@localhost ~]# mkdir -p compose-lnmp/docker/
[root@localhost ~]# cd compose-lnmp/
[root@localhost compose-lnmp]# mkdir wwwroot

[root@localhost?~]#?docker?run??-itd??--name??test??nginx:latest??[root@localhost?~]#?docker??cp??test:/etc/nginx??/root/compose-lnmp/docker/??
br/>[root@localhost?~]#?docker??cp??test:/etc/nginx??/root/compose-lnmp/docker/??
br/>[root@localhost?~]#?vim??/root/compose-lnmp/wwwroot/html/index.html??
hello??LNMP!??

//添加php測試界面[root@localhost?~]#?vim??/root/compose-lnmp/wwwroot/html/test.php??
br/>[root@localhost?~]#?vim??/root/compose-lnmp/wwwroot/html/test.php??
<?php??
phpinfo();??
?>??

//設置tab鍵的空格數量[root@localhost?~]#?vim??.vimrc??
br/>[root@localhost?~]#?vim??.vimrc??
br/>[root@localhost?~]#?cat?.vimrc???

//編寫docker-compose.yml文件[root@localhost?~]#?cd??/root/compose-lnmp/??
br/>[root@localhost?~]#?cd??/root/compose-lnmp/??
version: "3.1"
services:
nginx:
container_name: nginx
image: nginx
networks:
lnmp:
ipv4_address: 172.16.10.10
restart: always
ports:

  • 80:80
    volumes:
  • /root/compose-lnmp/wwwroot/html:/usr/share/nginx/html
  • /root/compose-lnmp/docker/nginx:/etc/nginx
    mysql:
    container_name: mysql
    image: mysql:5.7
    networks:
    lnmp:
    ipv4_address: 172.16.10.20
    restart: always
    ports:
  • 3306:3306
    environment:
    MYSQL_ROOT_PASSWORD: 123.com
    php:
    container_name: phpfpm
    image: php:7.2-fpm
    networks:
    lnmp:
    ipv4_address: 172.16.10.30
    restart: always
    ports:
  • 9000:9000
    volumes:
  • /root/compose-lnmp/wwwroot/html:/usr/share/nginx/html
    networks:
    lnmp:
    driver: bridge
    ipam:
    config:
    • subnet: 172.16.10.0/24

[root@localhost ~]# echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
[root@localhost ~]# systemctl restart network

[root@localhost?compose-lnmp]#?docker-compose??up??-d??

//修改nginx配置文件,nginx和php連接[root@localhost?compose-lnmp]#?cd??docker/nginx/conf.d/??
br/>[root@localhost?compose-lnmp]#?cd??docker/nginx/conf.d/??
10行:?
???location?/?{??
????????root???/usr/share/nginx/html;??
???????index??index.html?index.htm?index.php;??//添加php解析??
}??
//打開此模塊,并更改相應信息:
30行:????
location?~?.php$?{??
????????root???????????/usr/share/nginx/html;??
????????fastcgi_pass???172.16.10.30:9000;??
????????fastcgi_index??index.php;??
????????fastcgi_param??SCRIPT_FILENAME??$document_root$fastcgi_script_name;??
????????include????????fastcgi_params;??
}??
//重啟
[root@localhost?conf.d]#?docker-compose??restart??

//php和mysql連接[root@localhost?compose-lnmp]#?cd??wwwroot/html/??
br/>[root@localhost?compose-lnmp]#?cd??wwwroot/html/??
[root@localhost?html]#?mv??phpMyAdmin-4.9.1-all-languages??phpmyadmin??

//更改nginx配置文件[root@localhost?compose-lnmp]#?cd??docker/nginx/conf.d/??
br/>[root@localhost?compose-lnmp]#?cd??docker/nginx/conf.d/??
//在27行添加
location??/phpmyadmin?{??
????root??/usr/share/nginx/html;??
????index???index.html??index.htm??index.php;?
}?
//在43行添加
location?~?/phpmyadmin/(?<after_ali>(.*).(php|php5)?$)?{??
????root???????????/usr/share/nginx/html;??
????fastcgi_pass???172.16.10.30:9000;??
????fastcgi_index??index.php;??
????fastcgi_param??SCRIPT_FILENAME??$document_root$fastcgi_script_name;??
????include????????fastcgi_params;??
}??

//重啟
[root@localhost?conf.d]#?docker-compose??restart??

//需要對php鏡像做出更改,添加php和mysql連接的模塊寫一個Dockerfile
[root@localhost?~]#?vim??Dockerfile??
br/>寫一個Dockerfile
[root@localhost?~]#?vim??Dockerfile??
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install mysqli pdo pdo_mysql
[root@localhost?~]#?docker?build??-t??phpmysql??.??

//刪除容器,更改docker-compose.yml文件,并重新運行[root@localhost?compose-lnmp]#?docker-compose??stop??
br/>[root@localhost?compose-lnmp]#?docker-compose??stop??
br/>[root@localhost?compose-lnmp]#?vim??docker-compose.yml?
image:?phpmysql??
[root@localhost?compose-lnmp]#?docker-compose??up??-d??

//修改phpmyadmin的配置文件,指定連接數據庫的IP,然后重啟[root@localhost?compose-lnmp]#?cd??wwwroot/html/phpmyadmin/??
br/>[root@localhost?compose-lnmp]#?cd??wwwroot/html/phpmyadmin/??
br/>[root@localhost?phpmyadmin]#?vim??config.inc.php??
[root@localhost?phpmyadmin]#?cd??-??
br/>$cfg['Servers'][$i]['host']?=?'172.16.10.20';??
[root@localhost?phpmyadmin]#?cd??-??
[root@localhost?compose-lnmp]#?docker-compose??restart??

//再次訪問
用戶名:root
密碼:123.com

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

新田县| 新平| 盐城市| 武鸣县| 西林县| 镇原县| 德庆县| 义马市| 苏尼特左旗| 沙湾县| 苍山县| 疏勒县| 广饶县| 遂宁市| 化德县| 虎林市| 九江市| 合川市| 白朗县| 广平县| 深泽县| 蚌埠市| 永吉县| 台中市| 木里| 九龙坡区| 南丰县| 吉木乃县| 海淀区| 宾阳县| 灌南县| 昌图县| 灵石县| 庆阳市| 浦东新区| 汾西县| 县级市| 廉江市| 巴彦淖尔市| 云阳县| 蓬溪县|