33 lines
1.1 KiB
Bash
33 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# แก้ 403 Forbidden สำหรับ /realtimechat/ — รันบนเซิร์ฟเวอร์: sudo bash fix-403-realtimechat.sh
|
|
|
|
set -e
|
|
DIR="/var/www/html/realtimechat"
|
|
|
|
# ถ้าไฟล์อยู่ใต้ public/
|
|
if [ -d "$DIR/public" ]; then
|
|
DIR="$DIR/public"
|
|
fi
|
|
|
|
echo "แก้ permission โฟลเดอร์: $DIR"
|
|
echo "ก่อน:"
|
|
ls -la "$DIR/../" 2>/dev/null | head -5
|
|
ls -la "$DIR/" 2>/dev/null | head -5
|
|
|
|
# ให้ Nginx (www-data) อ่านได้: โฟลเดอร์ 755 ไฟล์ 644
|
|
chmod -R 755 "$(dirname "$DIR")"
|
|
chmod -R 755 "$DIR"
|
|
find "$DIR" -type f -exec chmod 644 {} \;
|
|
find "$DIR" -type d -exec chmod 755 {} \;
|
|
|
|
# ทางเลือก: ให้เจ้าของเป็น www-data (ถ้า Nginx ใช้ user นี้)
|
|
if id www-data &>/dev/null; then
|
|
chown -R www-data:www-data "$(dirname "$DIR")"
|
|
echo "ตั้ง chown www-data แล้ว"
|
|
fi
|
|
|
|
echo ""
|
|
echo "หลัง:"
|
|
ls -la "$DIR/" | head -5
|
|
echo "เสร็จ — ลองเปิด https://srv1361159.hstgr.cloud/realtimechat/ อีกครั้ง"
|