Hiển thị trạng thái của máy mà vagrant đang quản lý
Vagrant check version
$ vagrant version
Hiển thị phiên bản của vagrant đang cài đặt
Cài đặt Web Service
Install server apache 2
$ sudo apt-get install apache2
Cài đặt apache2
Sửa ip cho máy ảo
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
Bài tập Server 2
Sử dụng vagrant
Vagrant start
$ vagrant up
Khởi động máy ảo vagrant
$ vagrant ssh
Dùng giao thức SSH để điều khiển máy ảo vagrant
Vagrant stop
$ vagrant halt
Tắt máy ảo
Reload vagrant
$ vagrant reload
Reset lại máy ảo
Status
$ vagrant status
Hiển thị trạng thái của máy mà vagrant đang quản lý
Vagrant check version
$ vagrant version
Hiển thị phiên bản của vagrant đang cài đặt
Cài đặt Web Service
Install server apache 2
$ sudo apt-get install apache2
Cài đặt apache2 Sửa ip cho máy ảo 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
$ 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
$ 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
$ 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
$ 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
$ nano /var/www/s2.com/public_html/index.html
Mở file này và chỉnh sửa nội dung
$ 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ủ
$ 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 Chỉnh sửa những dòng sau
$ 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
$ 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: Chỉnh sửa tương tự, thay s1 thành s2
$ sudo a2ensite s1.com.conf
$ sudo a2ensite s2.com.conf
Kích hoạt máy chủ
$ sudo service apache2 restart
Khởi động lại apache2
$ sudo nano /etc/hosts
Thiết lập máy chủ
Truy cập vào địa chỉ s1.com và kết quả như sau
Install PHP 7.2
Cài đặt PHP theo những bước sau:
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt install php7.2 php7.2-common php7.2-cli
Run demo php file
Install MySQL
sudo apt-get install mysql-server
Cài đặt MySQL