magento2: Magento 2 Installation: css/js/images not loading in php-fpm + nginx server
I am trying to install Magento2(0.1.0-alpha107 ) in my localhost powered by OSX 10.10 + brew installed php-fpm + mysql + nginx. Steps that I followed for installation:
$ 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
So far everything worked great. But when you load the frontend: http://magento2alpha.dev/ it’s showing plain text only (i.e. css/images/js are missing).
View source gives you the path like http://magento2alpha.dev/pub/static/frontend/Magento/blank/en_US/[css/images]/[css/images file] which led to the 404 page My nginx conf file looks like:
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";
}
}
I guess the issue lies in the static files rewrite. But this is what I followed from the github which is not working. Is there any workaround?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 23 (20 by maintainers)
Commits related to this issue
- Merge pull request #802 from magento-engcom/develop-prs [EngCom] Public Pull Requests: magento/magento2#8393 magento/magento2#8395 magento/magento2#8383 magento/magento2#8353 magento/magento2#... — committed to magento/magento2 by deleted user 7 years ago
- Merge pull request #802 from magento-engcom/787 MSI-787: "Disassociated Products" configurable grid doesn't show information correctly — committed to fe-lix-/magento2 by deleted user 6 years ago
- ENGCOM-5718: Customer downloadable products GraphQL #802 - Merge Pull Request magento/graphql-ce#802 from magento/graphql-ce:685-CustomerDownloadableGraphQl - Merged commits: 1. d4f0f25be66f04dc... — committed to magento/magento2 by magento-engcom-team 5 years ago
- ENGCOM-5718: Customer downloadable products GraphQL #802 — committed to magento/magento2 by lenaorobei 5 years ago
I use this config
and static files works as expected