Giter VIP home page Giter VIP logo

about-lemp's Introduction

About-LEMP

การติดตั้ง LEMP โดยมีการติดตั้งโปรแกรมต่อไปนี้

L->Linux (ในทีนี้ใน Git bash) ,E->Nginx ,M->MariaDB ,P->PHP

ก่อนทำการติดตั้งโปรแกรมในลำดับถัดไป ให้สร้าง Network ด้วยคำสั่ง docker network create web_network

คำสั่งที่เกี่ยวข้องในการสร้าง Folder และ File

  cd <name folder>       // สร้าง folder นั้น
  cd ..                 //ย้อนกลับมายัง folder ก่อนหน้า
  touch <name file>     //สร้าง file .นามสกุลที่เราต้องการ
  rm <name folder>     //ลบ file หรือ folder นั้น
  ls                  //ดูข้อมูลต่างๆ ที่มีอยู่ใน folder นั้นๆ
  pwd                //ดู path ของ file หรือ folder นั้นๆ

การ Config docker-compose สำหรับใช้งาน Nginx

สร้าง Folder ชื่อ nginx_dock ภายใน Folder จะประกอบไปด้วย

  • nginx_dock
    • docker-compose.yml
    • static-html
      • index.html

File [docker-compose.yml] ของ nginx_dock

(https://github.com/keta410/About-LEMP/blob/main/nginx_dock/docker-compose.yml)

File inex.html

(https://github.com/keta410/About-LEMP/blob/main/nginx_dock/static-html/index.html)

จากนั้นทำการสั่ง docker-compose up -d ก็เป็นอันเสร็จสิ้น และทำเช่นเดียวกันในการติดตั้งโปรแกรมถัดไป

การ Config Nginx และ PHP

(สร้างแยกจาก Folder ก่อนหน้าต่างหาก)

เริ่มต้นสร้าง Folder ชื่อ [lemp_dock] ภายใน folder จะประกอบไปด้วย

  • lemp_dock
    • docker-compose.yml
    • html
      • index.php
    • nginx
      • conf
        • nginx.conf
      • conf.d
        • default.conf

File [docker-compose.yml] ของ lemp_dock

version: '3'

services:
  php:
    container_name: lemp_php
    image: php:7.4-fpm-alpine
    restart: unless-stopped
    volumes:
      - ./html/:/var/www/html
    expose:
      - "9000"

  nginx:
    container_name: lemp_nginx
    image: nginx:stable-alpine
    restart: unless-stopped
    volumes:
      - ./html/:/var/www/html

      - ./nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
      - ./nginx/conf.d:/etc/nginx/conf.d:ro

    ports:
      - "80:80"

networks:
  default:
    external:
      name:
        web_network

File [inex.php] ใน html

<?php phpinfo();?>

File [nginx.conf] ใน conf

(https://github.com/keta410/About-LEMP/blob/main/lemp_dock/nginx/conf/nginx.conf)

File [default.conf] ใน conf.d

(https://github.com/keta410/About-LEMP/blob/main/lemp_dock/nginx/conf.d/default.conf)

การ Config MariaDB

สร้าง Folder และ File เพิ่มเติมใน lemp_dock ดังนี้

  • lemp_dock
    • docker-compose.yml
    • html
      • index.php
    • nginx
      • conf
        • nginx.conf
      • conf.d
        • default.conf
    • mariadb
      • data
      • initdb
        • titanic.sql
    • php
      • Dockfile

แก้ไขข้อมูลภายใน File [docker-compose.yml] ของ lemp_dock

(https://github.com/keta410/About-LEMP/blob/main/lemp_dock/docker-compose.yml)

แก้ไขข้อมูลภายใน File [index.php] ใน html

(https://github.com/keta410/About-LEMP/blob/main/lemp_dock/html/index.php)

File [Dockerfile] ใน php

(https://github.com/keta410/About-LEMP/blob/main/lemp_dock/php/Dockerfile)

สำหรับ File [titanic.sql] ในที่นี้

(https://github.com/pitimon/xOps_Summer/tree/master/20220507/LEMP/mariadb/initdb)

เมื่อจัดการเกี่ยว File ต่างๆ เรียบร้อย ทำการสั่ง docker-compose build ตามด้วย docker-compose up -d

สำหรับในทุกขั้นตอนหลังติดตั้งโปรแกรมเสร็จ สามารถทำการตรวจสอบได้ตาม URL ที่เรากำหนดไว้

about-lemp's People

Contributors

keta410 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.