Prestashop 설치 중 Nginx 403 Forbiden

Prestashop 설치 중 Nginx 403 Forbiden

Nginx를 웹 서버로 사용하여 Centos 7 서버에 Prestashop을 설치하려고 합니다.

내가 취한 단계는 다음과 같습니다.

wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip

unzip prestashop_1.7.4.2.zip  ((gives 3 files, including prestapshop.zip))

unzip prestapshop.zip -d /var/www/example.com/public_html

chmod 755 /var/www/example.com/public_html/ -R

chown nginx:nginx * /var/www/example.com/public_html -R

그런데 접근하려고 하면https://example.com나는403 금지응답.

여기 나의/etc/nginx/sites-available/example.com.conf파일 내용:

 server{
   root /var/www/example.com/public_html;

   server_name example.com www.example.com MY_SERVER_IP;

   location / {
      index index.html index.htm;
      #try_files $uri $uri/ =404;
   }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
      root html;
   }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
 server{
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot



   listen 80;

   server_name example.com www.example.com MY_SERVER_IP;
    return 404; # managed by Certbot


}

도와주셔서 감사합니다.

건배

추신:나는 그 모든 명령을 루트로 실행했습니다.

p.s2:내 example.com.conf 파일의 Certbot 부분은 Certbot(SSL 인증서를 설치하는 소프트웨어)에 의해 자동으로 추가되었습니다.

또한 내 웹사이트에 액세스하려고 시도한 후 나타나는 nginx 오류 로그는 다음과 같습니다.

2018/08/30 05:53:04 [error] 27114#0: *6 directory index of "/var/www/example.com/public_html/install/" is forbidden, client: MY_SERVER_IP, server: lemeilleur$
2018/08/30 05:53:56 [error] 27114#0: *9 directory index of "/var/www/example.com/public_html/install/" is forbidden, client: MY_SERVER_IP, server: lemeilleur$
2018/08/30 06:30:26 [error] 27114#0: *12 directory index of "/var/www/example.com/public_html/install/" is forbidden, client: MY_SERVER_IP, server: lemeilleu$

( "lemeilleu"는 내 웹사이트 URL의 일부이지만 lemeilleu$가 무엇에 해당하는지 모르겠습니다)

출력ls -Z /var/www/example.com/public_html/

drwxr-xr-x nginx nginx ?                                admin
drwxr-xr-x nginx nginx ?                                app
-rwxr-xr-x nginx nginx ?                                autoload.php
drwxr-xr-x nginx nginx ?                                bin
drwxr-xr-x nginx nginx ?                                cache
drwxr-xr-x nginx nginx ?                                classes
-rwxr-xr-x nginx nginx ?                                composer.lock
drwxr-xr-x nginx nginx ?                                config
drwxr-xr-x nginx nginx ?                                controllers
-rwxr-xr-x nginx nginx ?                                docker-compose.yml
drwxr-xr-x nginx nginx ?                                docs
drwxr-xr-x nginx nginx ?                                download
-rwxr-xr-x nginx nginx ?                                error500.html
-rwxr-xr-x nginx nginx ?                                images.inc.php
drwxr-xr-x nginx nginx ?                                img
-rwxr-xr-x nginx nginx ?                                index.php
-rwxr-xr-x nginx nginx ?                                init.php
drwxr-xr-x nginx nginx ?                                install
-rwxr-xr-x nginx nginx ?                                INSTALL.txt
drwxr-xr-x nginx nginx ?                                js
-rwxr-xr-x nginx nginx ?                                LICENSES
drwxr-xr-x nginx nginx ?                                localization
drwxr-xr-x nginx nginx ?                                mails
drwxr-xr-x nginx nginx ?                                modules
drwxr-xr-x nginx nginx ?                                override
drwxr-xr-x nginx nginx ?                                pdf
-rwxr-xr-x nginx nginx ?                                robots.txt
drwxr-xr-x nginx nginx ?                                src
drwxr-xr-x nginx nginx ?                                themes
drwxr-xr-x nginx nginx ?                                tools
drwxr-xr-x nginx nginx ?                                translations
drwxr-xr-x nginx nginx ?                                upload
drwxr-xr-x nginx nginx ?                                var
drwxr-xr-x nginx nginx ?                                vendor
drwxr-xr-x nginx nginx ?                                webservice

그리고 마지막으로,/etc/php-fpm.d/www.conf파일:

user = nginx

group = nginx

listen.owner = nginx

listen.group = nginx

listen = 127.0.0.1:9000

답변1

마침내 이 문제에 대한 해결책을 찾았습니다. 달릴 때도nginx -t, 모든 것이 정상이라면 실제로 nginx.conf 콘텐츠와 관련이 있다는 의미는 아닙니다(또는yoursite.com.conf콘텐츠).

따라서 내 문제는 Nginx 및 403 Forbiden 메시지를 접할 때 가장 흔하게 발생하는 문제였습니다. 즉, 내 .conf 파일에서 알 수 있듯이 해당 줄이 index index.html index.htm;제대로 배치되지 않았고 전역이어야 하므로 외부 및 위에 있습니다.위치레이어는 다음과 같습니다:

 server{
   root /var/www/example.com/public_html;

   server_name example.com www.example.com MY_SERVER_IP;

   index index.php index.html index.htm;

   location / {
      #try_files $uri $uri/ =404;
   }

관련 정보