Skip to content

PlusMagi's Blog By Pitt Phunsanit

Plus emotional magic to the knowledge of logic.

  • หน้าแรก
  • About’s Pitt
Close Button

Apache: passwordApache: password

2017-07-152017-07-15| phunsanitphunsanit| 0 Comment | 00:00

บางส่วนของเว็บไม่ต้องการที่จะให้บุคคลทั่วไปเข้าถึงส่วนต่าง ๆ เช่น หน้า phpMyAdmin หรือ download files

  1. เปิดไฟล์ .htaccess ใน folder ที่ต้องการจะล็อกและเพิ่มข้อความ เช่น โดย /etc/phpmyadmin/.htpasswd คือที่จะบันทึก username และ pasword เอาไว้ save โดย CTRL+X และ Y
    <VirtualHost *:80>
    ...
    	<Directory "/var/www/html">
    ...
    		AuthType Basic
      AuthName "Restricted Content"
      AuthUserFile /etc/phpmyadmin/.htpasswd
      Require valid-user
    ...
     </Directory>
    ...
    </VirtualHost>
    
  2. ไปที่ folder ที่เก็บไฟล์เว็บไซต์หรือโฟลเดอร์ที่ต้องการ เช่น
    cd /etc/phpmyadmin/
  3. สร้างไฟล์รหัสผ่านโดยใช้คำสั่ง
    sudo htpasswd -c /etc/phpmyadmin/.htpasswd {username}
    เช่น
    sudo htpasswd -c /etc/phpmyadmin/.htpasswd GNzw95GDqH7d
    ระบุรหัสผ่านและยืนยันรหัสผ่าน
  4. สร้าง user เพิ่มเติมโดยไม่มี -c เช่น
    sudo htpasswd /etc/phpmyadmin/.htpasswd pitt
    จนกว่าจะครบ
  5. ไฟล์ /etc/phpmyadmin/.htpasswd จะเก็บข้อมูลในรูปแบบ 1 ชื่อผู้ใช้ 1 บรรทัด username:encrypt password. ปลอดภัยแน่นอน
  6. restart apache ใหม่โดย
    sudo systemctl restart apache2
  7. เรียก URL ตามที่ใส่รหัสผ่านไว้ เช่น http://127.0.0.1/phpmyadmin จะเห็นว่ามี message ขึ้นมาถามชื่อผู้ใช้และรหัสผ่าน

อ่านเพิ่มเติม

  • htpasswd – Manage user files for basic authentication
  • How To Set Up Password Authentication with Apache on Ubuntu 14.04
  • NGINX: password
Read MoreRead More

Posts pagination

ก่อนหน้า 1 … 458 459 460 … 877 ถัดไป

Projects

  • Statement columns mapping Helper
  • Plusmagi Search
  • jQuery Plus Repeater

Recent Posts

  • MariaDB: Character Set และ Collation
  • laravel: breeze, Jetstream, spatie ต่างกันอย่างไร
  • Bcrypt: Password Hashing
  • Monolithic Architecture
  • Spring Security: SecurityConfig

Archives

Categories

  • AI (4)
  • Businesses (3)
  • Design (30)
    • UX/UI (3)
  • Histories (8)
  • Life (47)
    • Books (20)
      • สืบสวน (4)
    • ECO (3)
    • Sci-Fi (2)
    • พุทธ (3)
  • Network (288)
    • Android (13)
      • F-Droid (7)
    • Apache Apache HTTP Server (17)
    • Docker (28)
    • Homebrew (14)
    • IIS (7)
    • IOT (4)
    • Linux (92)
    • macOS (67)
      • OrbStack (10)
    • Nginx (26)
    • RabbitMQ (4)
    • Samba (5)
    • Shell Script (28)
    • SSH (11)
    • Windows (97)
      • PowerShell (19)
      • WSL (21)
  • Programming (602)
    • API (17)
      • REST (5)
      • Swagger (6)
    • C# (15)
      • .NET Core EF (3)
    • CI/CD (3)
    • Database (162)
      • DBeaver (3)
      • RDBMS (144)
        • DB2 (2)
        • MariaDB (18)
        • MySql (56)
        • Oracle Database (4)
          • 10g (2)
        • PostgreSQL (3)
        • SQL Server (83)
          • ADS (3)
          • SMO (4)
          • SSMS (8)
          • T-SQL (26)
    • Flutter (2)
    • GIT (22)
    • Java (44)
      • JasperReports (3)
      • Joget (19)
      • Spring Boot (14)
    • Node.js (1)
    • PowerBuilder (11)
      • PowerBuilder 8 (10)
    • Python (8)
    • Rust (1)
    • Testing (7)
      • Automated Testing (4)
        • Playwright (2)
        • Selenium (2)
    • UML (1)
    • Version Control (1)
    • Web (279)
      • CSS (16)
        • Bootstrap (3)
        • Tailwind CSS (3)
      • HTML (23)
      • JavaScript (108)
        • AG Grid (1)
        • Angular (1)
        • jQuery (64)
          • DataTables (14)
        • React (2)
        • Tabulator (11)
        • TypeScript (10)
        • Vue.js (3)
      • PHP (161)
        • CodeIgniter (11)
        • Laravel (33)
          • Laravel 11 (10)
          • Laravel 5 (19)
        • PrestaShop (1)
        • Yii (19)
          • Yii 2 (16)
      • SEO (2)
      • WordPress (20)
  • Programs (80)
    • Bitwarden (5)
    • Excel (8)
    • Figma (7)
    • Google Chrome (6)
    • Mozilla Firefox (9)
    • Oh My ZSH (4)
    • Stalwart (5)
    • USB Boot (7)
  • Q & A (8)
  • Security (29)
  • Tips & Tricks (72)
    • iPhone (7)
      • Jailbreaking (2)
  • Uncategorized (1)
  • กฎหมาย (3)
  • คณิตศาสตร์ (4)

Sirat WordPress Theme By VWThemes

Scroll Up