Magento 2 Nginx 配置

server {
    listen       80;
    server_name  localdomain.local;

    root   /usr/share/nginx/html/magento2/;
    index  index.php index.html index.htm;

    location / {
#Magento2
        try_files $uri $uri/ /index.php?$args;
    }

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

    location /pub/static {
        try_files $uri $uri/ @static;
    }
    location @static {
        rewrite ^/pub/static/(.*)$ /pub/static.php?resource=$1? last;
    }
...
}
访问 http://localhost/setup/index.php 进行安装

或者使用CLI方式:
./magento2/bin/magento setup:install --db-name="magento2" --db-user="dba" --db-password="1234" --db-prefix="pfx_" --admin-user="admin" --admin-password="1234" --admin-email="1234@qq.com" --admin-firstname="li" --admin-lastname="-"
如果找不到管理后台入口地址,可以通过以下指令查询:
./bin/magento info:adminuri

更换域名时需要同时修改数据库 core_config_data 表并清除cache
或者手工删除cache文件

如果出现修改了nginx配置后js css文件还是404,需要执行静态资源重部署:
./bin/magento setup:static-content:deploy