문제

OSX 10.10 + Brew가 설치된 php-fpm + mysql + nginx를 기반으로 하는 로컬 호스트에 Magento2(0.1.0-alpha107)를 설치하려고 합니다.
설치를 위해 따라온 단계:

  • mkdir /path/to/magento2 && cd /path/to/magento2
  • git clone git@github.com:magento/magento2.git .
  • composer install
  • cd setup
  • composer install
  • php -f index.php install --base_url=http://magento2alpha.dev/ --backend_frontname=admin --db_host=localhost --db_name=magento2alpha --db_user=root --db_pass=root --admin_firstname=Raj --admin_lastname=KB --admin_email=magepsycho@gmail.com --admin_username=admin --admin_password=pass123 --language=en_US --currency=USD --timezone=America/Chicago

지금까지 모든 것이 훌륭하게 작동했습니다.하지만 프런트엔드를 로드할 때: http://magento2alpha.dev/일반 텍스트만 표시됩니다(예:CSS/이미지/js가 누락되었습니다).
소스 보기는 다음과 같은 경로를 제공합니다. http://magento2alpha.dev/pub/static/frontend/Magento/blank/en_US/[css/images]/[css/images file] 404 페이지로 연결됩니다.
내 nginx conf 파일은 다음과 같습니다.

server {
    listen 80;
    server_name magento2alpha.dev;
    root /Users/Raj/Sites/magento/magento2alpha;

    location /setup {
        try_files $uri $uri/ @setuphandler;
    }

    # Rewrite Setup's Internal Requests
    location @setuphandler {
        rewrite /setup /magento/magento2alpha/setup/index.php;
    }

    location / {
        index index.php index.html;
        try_files $uri $uri/ @handler;
    }

     # Rewrite Internal Requests
     location @handler {
        rewrite / /magento/magento2alpha/index.php;
     }

     # Rewrite magento2 static files
     #location /pub/static {
     #   rewrite ^/pub/static/(.*)$ /magento/magento2alpha/pub/static.php?resource=$1? last;
     #}

     location /pub/static {
          try_files $uri $uri/ @static;
     }

     location @static {
           rewrite ^/pub/static/(.*)$ /magento/magento2alpha/pub/static.php?resource=$1? last;
     }

     #location ~ .php/ {
     #    rewrite ^(.*.php)/ $1 last;
     #}

    location ~ \.php$ { ## Execute PHP scripts
        try_files $uri =404;
        expires        off;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_read_timeout 900s;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;

        ## Magento 2 Developer mode
        fastcgi_param MAGE_MODE "developer";
    }
}

문제는 정적 파일을 다시 작성하는 데 있다고 생각합니다.그러나 이것은 내가 작동하지 않는 github에서 따라온 것입니다.해결 방법이 있나요?

도움이 되었습니까?

해결책 2

마지막으로, Nginx Conf 파일을 수정하여 다음과 같이 작업해야합니다. (Ref : https://githolow.com/magento/magento2/issues/802 )

server {
    listen 80;
    server_name magento2alpha.dev;
    root /Users/Raj/Sites/magento/magento2alpha;

    location /setup {
        try_files $uri $uri/ @setuphandler;
    }

    # Rewrite Setup's Internal Requests
    location @setuphandler {
        rewrite /setup /setup/index.php;
    }

    location / {
        index index.php index.html;
        try_files $uri $uri/ @handler;
    }

     # Rewrite Internal Requests
     location @handler {
        rewrite / /index.php;
     }

     location /pub/static {
          try_files $uri $uri/ @static;
     }

     location @static {
           rewrite ^/pub/static/(.*)$ /pub/static.php?resource=$1? last;
     }

     location ~ \.php$ { ## Execute PHP scripts
        try_files $uri =404;
        expires        off;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_read_timeout 900s;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;

        ## Magento 2 Developer mode
        fastcgi_param MAGE_MODE "developer";
        fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
        fastcgi_param  PHP_VALUE "memory_limit=256M \n max_execution_time=18000";
     }
}
.

내가 알아 차리는 것은 다음과 같습니다. NginX의 conf.d에서 가상 호스트 특정 구성을 생성하는 경우 sites-enabled Dir을 유지하는 것보다 더 자원이 비싸고 느립니다.


[편집]
미안해, XdeBug는 NginX conf가 아닌 느린이 아닌

다른 팁

현재 존재하지 않는 /pub/static에서 요청 된 모든 파일은 Magento를 통해 라우팅해야합니다.현재 /pub/static.php를 통해 수행됩니다.

/pub/static/.htaccess 에서이 재 작성을 볼 수 있습니다

RewriteEngine On
# Remove signature of the static files that is used to overcome the browser cache
RewriteRule ^version.+?/(.+)$ $1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* ../static.php?resource=$0 [L]
.

NGINX 구성을보고 있습니다.이 항목은 다음과 같이 설명했습니다.

 # Rewrite magento2 static files
 #location /pub/static {
 #   rewrite ^/pub/static/(.*)$ /magento/magento2alpha/pub/static.php?resource=$1? last;
 #}
.

아마도 이러한 라인을 실행할 수있게 만드는이 문제가 해결 될 것이라고 나는 Nginx 구성에 대해 매우 익숙하지 않지만이 과 같은 것이

location / {
    if (!-e $request_filename){ 
        rewrite ^(.*)$ /../static.php?resource=$0 last;
    }
}
.

출처: https://magento.stackexchange.com/a/64808/3326

프로덕션 모드가 아닌 경우 Magento 2는 일부 정적 리소스에 대한 심볼릭 링크를 생성하려고 시도합니다.다음을 수행하여 해당 동작을 변경할 수 있습니다.

열어라 app/etc/di.xml 그리고 찾아 virtualType name="developerMaterialization" 부분.해당 섹션에서 항목을 찾을 수 있습니다. name="view_preprocessed" 수정하거나 삭제해야 하는 항목입니다.내용을 변경하여 수정할 수 있습니다. Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink 에게 Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

아래의 파일을 삭제하세요. pub/static 기존 심볼릭 링크를 제거합니다.삭제하지 않도록 주의하는 것이 좋습니다. .htaccess 파일.

이렇게 하면 심볼릭 링크 오류가 해결됩니다.

이것은 지금까지 가장 좋은 대답입니다

내용을 변경하여 수정할 수 있습니다. Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

Magento 2 설치를 실행 한 후에 비슷한 문제가 있었으며 설치가 실제로 정적 파일을 전개하지 못했습니다.부트 스트랩 등 많은 관리 파일에 대해 404를 받았습니다. IT는 사이트 루트에서 명령을 실행하여 정적 파일 배포를 강제하도록 명령했습니다.

php bin/magento setup:static-content:deploy -f
.

Frontend 테마 및 AdminHTML 백엔드 용 정적 자산을 다시 사용할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top