승객 Apache - 금지됨 이 리소스에 액세스할 수 있는 권한이 없습니다.

승객 Apache - 금지됨 이 리소스에 액세스할 수 있는 권한이 없습니다.

Apache구성 이 막혔습니다 Passenger. 나는 해결책을 찾기 위해 며칠을 보냈습니다.나는 이 지시를 따릅니다.브라우저에 다음 메시지가 나타납니다.

Forbidden

You don't have permission to access this resource.

httpd.conf

# Use /usr/bin/node by default.
PassengerNodejs /usr/bin/node

<VirtualHost *:80>

    ServerName example.com

    RewriteEngine On 
    RewriteCond %{HTTPS} off
    RewriteCond %{SERVER_NAME} =example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

<VirtualHost *:443>

    ServerName example.com

    # Tell Apache and Passenger where your app's code directory is
        DocumentRoot /var/www/example.com
        PassengerAppRoot /var/www/example.com/

    # Tell Passenger that your app is a Node.js app
        PassengerAppType node
        PassengerStartupFile app.js

    # Relax Apache security settings
    <Directory /var/www/example.com>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        Options -MultiViews
        # Uncomment this if you're on Apache >= 2.4:
        Require all granted
    </Directory>

    CustomLog /var/log/httpd/example.com_access.log combined
    ErrorLog /var/log/httpd/example.com_error.log

    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/fullchain.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>

/var/log/httpd/example.com_error.log에서 다음을 얻습니다.

[Sat Sep 04 07:24:00.473120 2021] [autoindex:error] [pid 907862:tid 139932467173120] [client 85.89.184.79:50337] AH01276: Cannot serve directory /var/www/example.com/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive

파일 권한

drwxr-xr-x. 5 root   root  102 Sep  3 23:53 ..
drwxr-xr-x. 8 root   root  163 Sep  4 07:11 .git
-rw-r--r--. 1 root   root   35 Sep  4 07:11 .gitignore
-rw-r--r--. 1 root   root  215 Sep  4 07:11 README.md
-rw-r--r--. 1 root   root  390 Sep  4 07:11 app.js
drwxr-xr-x. 3 root   root   21 Sep  4 07:12 node_modules
-rw-r--r--. 1 root   root 2655 Sep  4 07:12 npm-shrinkwrap.json
-rw-r--r--. 1 root   root  318 Sep  4 07:11 package.json
drwxr-xr-x. 2 root   root   22 Sep  4 07:11 public

curl http://127.0.0.1:3000/Node.js/io.js + Connect.js에서 Hello를 반환합니다!

제가 확인해야 할 것이 있나요?

답변1

이 오류는 디렉터리에 기본 색인 파일이 없음을 의미하며 언급한 파일 목록을 고려하면 이는 분명히 해당되는 경우입니다.

해결책:

  1. 공용 디렉토리 내에 빈 index.html 페이지를 만듭니다.

    touch /var/www/example.com/index.html
    
  2. httpd.conf 내에서 옵션 지시문을 수정하고 인덱스를 추가합니다.

    Options -MultiViews -Indexes
    
  3. httpd 다시 시작/다시 로드

    service httpd reload
    

편집하다:

httpd.conf를 다시 보면 DocumentRoot가 공용 디렉토리의 위치를 ​​지정하지 않은 것 같습니다. 그러므로:

  1. 현재 DocumentRoot를 /var/www/example.com/public으로 바꾸십시오.
DocumentRoot /var/www/example.com/public
  1. 디렉터리 경로도 동일한 경로로 변경합니다.
<Directory /var/www/example.com/public>

자세한 내용은 다음을 참조하세요.승객 웹사이트

관련 정보