AT-PHPIntership / server-practice

0 stars 2 forks source link

S2-Pham Thi Minh Hien #23

Open ghost opened 6 years ago

ghost commented 6 years ago

Bài tập Server 2

Sử dụng vagrant

Vagrant start

$ vagrant up

Khởi động máy ảo vagrant screenshot from 2018-06-17 20-35-15

$ vagrant ssh

Dùng giao thức SSH để điều khiển máy ảo vagrant screenshot from 2018-06-17 20-36-12

Vagrant stop

$ vagrant halt

Tắt máy ảo screenshot from 2018-06-17 20-41-16

Reload vagrant

$ vagrant reload

Reset lại máy ảo screenshot from 2018-06-17 20-42-27

Status

$ vagrant status

Hiển thị trạng thái của máy mà vagrant đang quản lý screenshot from 2018-06-17 20-52-28

Vagrant check version

$ vagrant version

Hiển thị phiên bản của vagrant đang cài đặt screenshot from 2018-06-17 20-54-57

Cài đặt Web Service

Install server apache 2

$ sudo apt-get install apache2

Cài đặt apache2 screenshot from 2018-06-17 21-08-46 Sửa ip cho máy ảo screenshot from 2018-06-17 21-04-24 Khởi động lại máy ảo bằng lệnh vagrant reload sau đó nhập địa chỉ ip http://192.168.33.15/ vào trình duyệt để hiển thị trang index của apache2 screenshot from 2018-06-17 21-14-38

$ sudo mkdir -p /var/www/s1.com/public_html

$ sudo mkdir -p /var/www/s2.com/public_html

Tạo cấu trúc thư mục screenshot from 2018-06-20 15-23-22

$ sudo chown -R $USER:$USER /var/www/s1.com/public_html

$ sudo chown -R $USER:$USER /var/www/s2.com/public_html

$ sudo chmod -R 755 /var/www

Cấp quyền cho 2 thư mục screenshot from 2018-06-20 15-25-53

$ nano /var/www/s1.com/public_html/index.html

Khởi tạo trang demo cho mỗi máy chủ. Thêm nội dung vào file như sau screenshot from 2018-06-20 15-31-23

screenshot from 2018-06-20 15-30-19

$ cp /var/www/s1.com/public_html/index.html /var/www/s2.com/public_html/index.html

Sao chép file này cho trang web thứ 2 screenshot from 2018-06-20 15-33-05

$ nano /var/www/s2.com/public_html/index.html

Mở file này và chỉnh sửa nội dung screenshot from 2018-06-20 15-34-30

screenshot from 2018-06-20 15-34-49

$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/s1.com.conf

Tạo file mới trên máy chủ screenshot from 2018-06-20 15-36-16

$ sudo nano /etc/apache2/sites-available/s1.com.conf

Mở tệp mới trong trình chỉnh sửa với quyền root screenshot from 2018-06-20 15-37-55 Chỉnh sửa những dòng sau

ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html

screenshot from 2018-06-20 15-41-02

$ sudo cp /etc/apache2/sites-available/s1.com.conf /etc/apache2/sites-available/s2.com.conf

Sao chép máy chủ đầu tiên và chỉnh sửa cho domain thứ 2 screenshot from 2018-06-20 15-44-39

$ sudo nano /etc/apache2/sites-available/s2.com.conf

Mở tệp và chỉnh sửa tương tự với quyền root: screenshot from 2018-06-20 15-46-28 Chỉnh sửa tương tự, thay s1 thành s2 screenshot from 2018-06-20 15-47-20

$ sudo a2ensite s1.com.conf

$ sudo a2ensite s2.com.conf

Kích hoạt máy chủ screenshot from 2018-06-20 16-19-22

screenshot from 2018-06-20 16-20-07

$ sudo service apache2 restart

Khởi động lại apache2 screenshot from 2018-06-20 16-22-24

$ sudo nano /etc/hosts

Thiết lập máy chủ screenshot from 2018-06-20 16-23-09

Truy cập vào địa chỉ s1.com và kết quả như sau

screenshot from 2018-06-20 16-31-32

Install PHP 7.2

Cài đặt PHP theo những bước sau:

$ sudo add-apt-repository ppa:ondrej/php

screenshot from 2018-06-17 21-20-44

$ sudo apt-get update

$ sudo apt install php7.2 php7.2-common php7.2-cli

screenshot from 2018-06-17 21-22-09

Run demo php file

ghost commented 6 years ago

Còn thiếu nhiều lệnh so với yêu cầu, bổ sung đầy đủ rồi anh sẽ review tiếp

ghost commented 6 years ago

Em đã chỉnh sửa xong rồi anh review lại giúp em với ạ. Em xin cảm ơn.