Cài đặt và cấu hình WAMP Server bảo mật, tối ưu cho AppGini

Bắt đầu bởi admin, T06 30, 2025, 11:29 CHIỀU

Chủ đề trước - Chủ đề tiếp theo

admin

Cài đặt và cấu hình WAMP Server bảo mật, tối ưu cho AppGini


Mục đích:
Hướng dẫn cài đặt WAMP Server chuẩn, tối ưu và an toàn cho môi trường phát triển AppGini nội bộ, hỗ trợ hiển thị danh sách project, cấu hình phpMyAdmin bảo mật và giao diện landing page thân thiện.

index desktop.jpg

index from lan.jpg


1. Tải về các công cụ cần thiết

✔ Visual C++ Redistributable (All-in-One): 
https://www.techpowerup.com/download/visual-c-redistributable-runtime-package-all-in-one/

✔ WAMP Server: 
https://sourceforge.net/projects/wampserver/files/latest/download

✔ Notepad++: 
https://github.com/notepad-plus-plus/notepad-plus-plus/releases


2. Cài đặt WAMP Server

  • Giải nén file Visual-C-Runtimes-All-in-One*.zip, chuột phải vào install_all.bat → chọn Run as administrator.
  • Cài wampserver3.3.7_x64.exe bình thường → chọn "No" khi được hỏi.
  • Sau khi cài xong, khởi động WAMP → đợi icon chuyển màu xanh là OK.
  • Cài đặt Notepad++


3. Cấu hình PHP (file php.ini)

Mở file tại:
C:\wamp64\bin\php\php8.3.14\php.ini

Tìm và sửa các dòng sau:

display_errors = On
post_max_size = 100M
upload_max_filesize = 100M
date.timezone = "Asia/Ho_Chi_Minh"

Tùy chọn này cho phép AppGini upload các file có dung lượng tối đa là 100MB, mỗi lần post tối đa 100MB, múi giờ Việt Nam và không hiển thị lỗi ra trình duyệt web.

4. Cấu hình Apache

✔ Mở file: 
C:\wamp64\bin\apache\apache2.4.62.1\conf\extra\httpd-vhosts.conf

Thay bằng nội dung sau:

<VirtualHost _default_:80>
  ServerName localhost
  DocumentRoot "${INSTALL_DIR}/www"
  DirectoryIndex index.php index.html index.htm

  <Directory />
    Require all denied
    Options None
    AllowOverride None
  </Directory>

  <Directory "${INSTALL_DIR}/www/">
    Options +FollowSymLinks +Indexes
    AllowOverride All
    Require all granted
  </Directory>

  <Directory "${INSTALL_DIR}/apps/phpmyadmin5.2.1/">
    Require local
  </Directory>
</VirtualHost>

✔ Mở file: 
C:\wamp64\bin\apache\apache2.4.62.1\conf\httpd.conf 
Chỉnh sửa:

ServerSignature Off
ServerTokens Prod


5. Đặt mật khẩu cho MySQL root

Mở: WAMP > MySQL > MySQL Console

mysql console.jpg

Khi được hỏi mật khẩu → nhấn Enter (vì mặc định chưa có mật khẩu) 
Sau đó gõ lệnh sau:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourStrongPassword';
FLUSH PRIVILEGES;

Thay "YourStrongPassword" bằng mật khẩu của bạn.
Áp dụng tương tự cho MariaDB nếu dùng.


6. Cấu hình phpMyAdmin (config.inc.php)

Mở file:
C:\wamp64\apps\phpmyadmin5.2.1\config.inc.php

Tìm và sửa (2 lần cho 2 CSDL MySQL và MariaDB):

$cfg['Servers'][$i]['AllowNoPassword'] = false;

Khi truy cập phpMyAdmin sẽ yêu cầu nhập username/password. User là root và mật khẩu mà bạn đã thiết lập ở bước 5.

Link truy cập phpmyadmin: http://localhost/phpmyadmin

7. Tạo giao diện trang chủ App Gallery

  • Xoá toàn bộ nội dung mặc định trong thư mục C:\wamp64\www
  • Tạo file index.php với giao diện đẹp sử dụng Tailwind CSS
  • Tự động liệt kê danh sách project và phân quyền theo IP:
    • Nếu truy cập từ máy cài WAMP → thấy phpMyAdmin + project
    • Nếu truy cập từ LAN → chỉ thấy project

Tải file index.zip trong phần đính kèm > giải nén và chép vào thư mục C:\wamp64\www\


8. Khởi động lại toàn bộ dịch vụ

Vào biểu tượng WAMP ở thanh taskbar → chọn: Restart All Services


9. Lưu ý bảo mật

  • Không để tài khoản root không có mật khẩu.
  • Hạn chế phpMyAdmin chỉ cho truy cập từ localhost.
  • Ẩn thông tin version Apache bằng cách tắt ServerSignature và ServerTokens.
  • Không public WAMP ra internet trừ khi cấu hình firewall/nginx reverse proxy an toàn.


Mọi thắc mắc – góp ý – bổ sung xin gửi vào chủ đề này!