source

Xampp 액세스 금지 php

itover 2022. 12. 21. 22:31
반응형

Xampp 액세스 금지 php

저는 윈도 사용자입니다.xampp를 사용한 지 꽤 됐는데 갑자기 .php 파일이 하나도 작동하지 않아요!다음 오류 메시지가 나타납니다.


접근 금지!

요청한 개체에 액세스할 수 있는 권한이 없습니다.읽기 금지되어 있거나 서버에서 읽을 수 없습니다.

서버 오류라고 생각되는 경우 웹마스터에게 문의하십시오.

오류 403

localhost Apache/2.4.4(Win32) OpenSSL/0.9.8y PHP/5.4.16


localhost/Practice에서 .php 파일 목록을 볼 수 있습니다(Practice는 파일을 저장한 폴더입니다).파일을 클릭할 때마다 파일이 열립니다.그러나 파일 내의 '제출' 버튼을 클릭하면 이 오류가 나타납니다.도와주세요!xampp를 1.8.1에서 1.8.2로 업데이트했는데도 같은 문제가 지속됩니다!

아래 코드를 사용하여 가상 호스트 구성에 추가하십시오.은 이 행에 더하면 됩니다.httpd-vhosts.conf 삭제:

<Directory "c:/<path-to-projects>/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Require all granted
</Directory>

저는 같은 문제를 이렇게 해결했습니다.도움이 됐으면 좋겠다.

주의:

변경 후 캐시로 리다이렉트했으므로 익명으로 테스트해 주십시오.

ubuntu 운영체제를 사용하는 경우 /Practice 폴더 변경 읽기 권한의 chmod를 확인합니다.

을 엽니다. 가기 키입니다.Ctrl+Alt+T

$ cd /opt / lampp / htdocs /

및 실행 합니다.chmod 「」

예: 폴더 이름은 /opt/lampp/htdocs/practice 폴더의 practice 및 경로입니다.

Type 명령어

$ sudo chmod 777 -R Practice

가 뭐죠?chmod ★★★★★★★★★★★★★★★★★」777? 이 링크에는 http://linuxcommand.org/lts0070.php를 방문하십시오.

이 문제를 해결한 방법은 먼저 올바르게 셋업 오류 로그입니다.

<VirtualHost *:80>
    DocumentRoot "D:/websites/test/"
    ServerName test.dev
    ErrorLog "D:/websites/test/logs/error.log"
    CustomLog "D:/websites/test/logs/access.log" common
    <Directory D:/websites/test/>  
        AllowOverride none
        Require all granted  
    </Directory>
</VirtualHost>

이 오류가 "D:/website/test/logs/"에 로그인한 후 로그 폴더를 직접 만드십시오.오류 로그에 기록된 정확한 오류는 다음과 같습니다.

AH01630: 서버 구성에 의해 클라이언트가 거부되었습니다.

그래서 위의 오류에 대한 이 링크를 사용하여 해결 방법을 찾아냈습니다.

Require all granted 

필수 항목입니다.참고로 위의 샘플코드로 문제를 해결했습니다.

Mac에서의 XAMPP의 경우

sudo chmod -R 0777 /Applications/XAMPP/xamppfiles/htdocs/myprojectname

메모: 'myprojectname'을 실제 프로젝트 이름으로 변경해야 합니다.또한 프로젝트가 htdocs의 루트 디렉토리에 있는지 확인하거나 그에 따라 경로를 변경하십시오.

온라인으로 몇 시간 동안 조사를 한 후 효과가 있었던 유일한 솔루션

sudo chmod -R 0777 /opt/lampp/htdocs/projectname

을 편집합니다.C:\xampp\apache\conf\httpd.conf★★★★

AllowOverride none
Require all denied

로.

AllowOverride All
Options  All
Allow from all
Order allow,deny

Apache 재시작

저는 우분투 16.04를 사용하여 xxamp를 사용하고 있으며, 정상적으로 동작하고 있습니다.

<VirtualHost *:80>
    DocumentRoot "/opt/lampp/htdocs/"
    ServerAdmin localhost
    <Directory "/opt/lampp/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

폴더 Xampp로 합니다.xampp/apache/conf/extra/httpd-xampp.c­onf

마지막 단락을 편집합니다.

#close XAMPP sites here 
.
.
.
Deny from all
.
.

로.

#close XAMPP sites here 
.
.
.
Allow from all
.
.

이 비디오를 봐주세요.http://www.youtube.com/watch?v=ZUAKLUZa-AU

가상 호스트가 작동을 멈추기 전에 가상 호스트에서 변경된 사항이 있습니까?

이 행을 xampp/apache/conf/extra/httpd-vhosts.conf에 추가합니다.

<VirtualHost localhost:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerAdmin localhost
    <Directory "C:/xampp/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

나는 다음과 같이 즉시 해결되었다.

  1. C:\xampp\apache\conf\extra로 이동합니다.
  2. httpd-xampp.conf 파일 내부 편집
  3. 다음과 같이 파일을 편집합니다.

cont+f로 다음 행을 찾습니다.

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
    AllowOverride AuthConfig
    Require local
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>

로컬만 변경 ----> 모두 허용되므로 다음과 같이 됩니다.

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
    AllowOverride AuthConfig
    Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>

이 후 localhost는 오류 표시를 중지하고 admin 패널을 표시합니다.이 솔루션은 비디오에서 찾았습니다.https://www.youtube.com/watch?v=MvYyEPaNNhE

htdocs 폴더를 xampp 폴더 외부로 이동한 후 문제가 발생했습니다.이 경우 httpd.conf에서 문서 루트를 변경해야 합니다.https://stackoverflow.com/a/1414/3543329 를 참조해 주세요.

저도 같은 문제가 있었어요.그래서 기억을 얻었어요어제 이 코드를 http-xampp.conf에 코멘트했습니다.

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
#        AllowOverride AuthConfig
#        Require local
#        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

따라서 localhost는 localhost를 필요로 하기 때문에 같은 네트워크(LAN/WIFI)상의 다른 시스템을 사용하여 로컬호스트에 액세스 할 수 있습니다.

그래서 그냥 이렇게 만들어요.

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
#        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

로컬 머신에서 동작하게 되어 로컬 호스트도 같은 LAN/WIFI 상의 다른 시스템을 사용하여 액세스 할 수 있게 되었습니다.

A. #LoadModule vhost_alias_module modules/mod_vhost_alias.so
B. <Directory />
    AllowOverride none
    Require all denied
</Directory>

대체 대상:

A. LoadModule vhost_alias_module modules/mod_vhost_alias.so
B:
<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

E:\xamp**apache\conf/httpd.conf*부터

어떻게든 index.php를 삭제하고 index.php를 사용하지 않고 폴더에 접속하면 동일한 오류가 발생했기 때문에 동일한 오류가 발생하였습니다.

다음 단계는 누구에게나 도움이 될 수 있다

  1. apache2 오류 로그 확인
  2. 폴더 권한에 액세스할 수 있는지 확인하십시오. 설정하지 않은 경우
  3. vhost 파일 <디렉토리 "c://"> 옵션인덱스 FollowSymLinks MultiViews Allow Over Order Deny 덮어쓰기, Allow from all require granted
  4. 마지막이지만 vhosts 파일과 실제 이름에 입력하는 mine check 폴더 이름(대문자와 소문자가 구분되는 "Pubic"은 "public" 형식과 다름)과 같이 시간을 절약할 수 있습니다.감사해요.

웨이-1

  • 이것은 내부의 특정 프로젝트/폴더에 대한 것입니다.htdocs 표시
  1. cmd/ 터미널을 열고htdocs폴더 디렉토리는 ( /opt/lampp/htdocs/ ) 이며 디렉토리 변경에는 ( cd directory_name )명령어를 사용했습니다.

    cd /opt/lampp/htdocs/

  2. 다음 명령을 실행합니다.

    sudo chmod 777 -R Project-Folder-Name

Project-Folder-Name프로젝트 폴더 이름으로 바꿉니다.

웨이-2

  • 이것은 내부의 모든 프로젝트/폴더에 대한 것입니다.lampp폴더
  1. cmd/ 터미널을 열고lampp폴더 디렉토리는 ( /opt / lampp / ) 이며, 디렉토리 변경에 ( cd directory _ name )명령어를 사용했습니다.

    cd /opt/lampp/

  2. 다음 명령을 실행합니다.

    sudo chmod 777 -R htdocs

내 경우 XAMPP에서 서버에서 로컬 호스트로 Drupal 인스턴스를 내보냈습니다.파일과 디렉토리의 소유권을 제대로 다루지 못한 것은 분명하며 Apache는 위의 오류를 발생시키고 있었다.

처음에 파일 및 디렉토리의 소유권은 다음과 같습니다.

여기에 이미지 설명 입력

내 파일에 읽기 권한을 부여하고 내 디렉토리에 대한 권한을 실행하려면 모든 사용자가 읽기, 쓰기 및 실행할 수 있도록 다음을 수행합니다.

sudo chmod 777 -R

그러나 이는 서버로 다시 이행되어 보안상의 허점이 발생할 수 있기 때문에 이상적인 솔루션은 아닙니다.

다음 블로그에 스크립트가 있습니다.https://www.drupal.org/node/244924

#!/bin/bash

# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:

  1) Path to your Drupal installation.
  2) Username of the user that you want to give files/directories ownership.
  3) HTTPD group name (defaults to www-data for Apache).

Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=www-data
HELP
exit 0
}

if [ $(id -u) != 0 ]; then
  printf "**************************************\n"
  printf "* Error: You must run this with sudo or root*\n"
  printf "**************************************\n"
  print_help
  exit 1
fi

drupal_path=${1%/}
drupal_user=${2}
httpd_group="${3:-www-data}"

# Parse Command Line Arguments
while [ "$#" -gt 0 ]; do
  case "$1" in
    --drupal_path=*)
        drupal_path="${1#*=}"
        ;;
    --drupal_user=*)
        drupal_user="${1#*=}"
        ;;
    --httpd_group=*)
        httpd_group="${1#*=}"
        ;;
    --help) print_help;;
    *)
      printf "***********************************************************\n"
      printf "* Error: Invalid argument, run --help for valid arguments. *\n"
      printf "***********************************************************\n"
      exit 1
  esac
  shift
done

if [ -z "${drupal_path}" ] || [ ! -d "${drupal_path}/sites" ] || [ ! -f "${drupal_path}/core/modules/system/system.module" ] && [ ! -f "${drupal_path}/modules/system/system.module" ]; then
  printf "*********************************************\n"
  printf "* Error: Please provide a valid Drupal path. *\n"
  printf "*********************************************\n"
  print_help
  exit 1
fi

if [ -z "${drupal_user}" ] || [[ $(id -un "${drupal_user}" 2> /dev/null) != "${drupal_user}" ]]; then
  printf "*************************************\n"
  printf "* Error: Please provide a valid user. *\n"
  printf "*************************************\n"
  print_help
  exit 1
fi

cd $drupal_path
printf "Changing ownership of all contents of "${drupal_path}":\n user => "${drupal_user}" \t group => "${httpd_group}"\n"
chown -R ${drupal_user}:${httpd_group} .

printf "Changing permissions of all directories inside "${drupal_path}" to "rwxr-x---"...\n"
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;

printf "Changing permissions of all files inside "${drupal_path}" to "rw-r-----"...\n"
find . -type f -exec chmod u=rw,g=r,o= '{}' \;

printf "Changing permissions of "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n"
cd sites
find . -type d -name files -exec chmod ug=rwx,o= '{}' \;

printf "Changing permissions of all files inside all "files" directories in "${drupal_path}/sites" to "rw-rw----"...\n"
printf "Changing permissions of all directories inside all "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n"
for x in ./*/files; do
  find ${x} -type d -exec chmod ug=rwx,o= '{}' \;
  find ${x} -type f -exec chmod ug=rw,o= '{}' \;
done
echo "Done setting proper permissions on files and directories"

또한 다음 명령을 실행해야 합니다.

sudo bash /Applications/XAMPP/xamppfiles/htdocs/fix-permissions.sh --drupal_path=/Applications/XAMPP/xamppfiles/htdocs/rkmission --drupal_user=daemon --httpd_group=admin

내 경우 Apache가 실행되고 있는 사용자는 '데몬'입니다.localhost를 통해 php 파일에서 다음 php 스크립트를 실행하는 것만으로 사용자를 식별할 수 있습니다.

<?php echo exec('whoami');?>

다음은 Drupal에 대한 올바른 파일 권한을 가진 사용자입니다.

여기에 이미지 설명 입력

서버가 다시 전송되면 다시 변경해야 할 수 있습니다.

언급URL : https://stackoverflow.com/questions/17816732/xampp-access-forbidden-php

반응형