PUBLISH WEBSITE RA NGOÀI INTERNET
Trước đây mình có viết bài hướng dẫn cài đặt một số dịch vụ trên VPS, nhưng mà thiếu phần cấu hình web trên môi trường internet. Nay mình sẽ hướng dẫn bạn cách thực hiện.
Nếu chưa cài đặt hoặc cài đặt thiếu các dịch vụ, bạn có thể xem lại tại đây.
Đầu tiên bạn cần trỏ domain về IP của VPS của bạn. Để làm được điều này, bạn cần liên hệ với nhà cung cấp domain để nhờ họ trỏ về giúp bạn, hoặc bạn có thể tự làm nếu có thể.
Tiếp theo bạn cấu hình website.
Bước 1: Tạo thư mục chứa source web trong: /var/www
mkdir web1.tk/public_html
mkdir web2.tk/public_html
sudo chmod -R 755 /var/www
Bước 2: Tạo thư mục sites-available và sites-enabled trong /etc/httpd
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
Bước 3: Chỉnh sửa file /etc/httpd/conf/httpd.conf, thực hiện thêm 2 dòng sau:
IncludeOptional sites-enabled/*.conf
IncludeOptional conf.d/*.conf
Bước 3: Tạo Virtual host cho từng web:
- File web1
vi /etc/httpd/sites-available/web1.conf
<VirtualHost *:80>
ServerName www.web1.com
ServerAlias web1.com
DocumentRoot /var/www/web1.com/public_html
ErrorLog /var/www/web1.com/error.log
CustomLog /var/www/web1.com/requests.log combined
</VirtualHost>
- File web2
vi /etc/httpd/sites-available/web2.conf
<VirtualHost *:80>
ServerName www.web2.com
ServerAlias web2.com
DocumentRoot /var/www/web2.com/public_html
ErrorLog /var/www/web2.com/error.log
CustomLog /var/www/web2.com/requests.log combined
</VirtualHost>
Bước 4: Kích hoạt Virtual Host
ln -s /etc/httpd/sites-available/web1.com.conf /etc/httpd/sites-enabled/web1.com.conf
ln -s /etc/httpd/sites-available/web2.com.conf /etc/httpd/sites-enabled/web2.com.conf
Bước 5: Khởi động lại dịch vụ httpd:
systemctl restart httpd
Sau đó bạn kiểm tra lại các website nhé.
- thanhtam.tk/wordpress

- traudoikienthuc.tk

Chúc các bạn thành công.