官术网_书友最值得收藏!

How to do it...

Thankfully, Magento provides a fairly functional NGINX sample configuration (located in the root of the Magento source folder) to get started with. I've located the files within the /var/www/html directory, which will be known as MAGE_ROOT.

Magento provides a basic configuration out of the box, which only requires a few small changes. However, I prefer to use my own configuration which I find easier to follow. Here's how I do it:

server { 
    listen       80; 
    server_name  magento.nginxcookbook.com; 
    set $MAGE_ROOT /var/www/html; 
 
    access_log  /var/log/nginx/magento.access.log  combined; 
    index index.php; 
 
    root   $MAGE_ROOT/pub/; 
 
    location / { 
        try_files $uri $uri/ /index.php?$args; 
    } 
    location ~ ^/(setup|update) { 
        root $MAGE_ROOT; 
        location ~ ^/(setup|update)/index.php { 
            fastcgi_pass   unix:/var/run/php7.0-fpm.sock; 
            fastcgi_index  index.php; 
            fastcgi_param  SCRIPT_FILENAME  
$document_root$fastcgi_script_name; include fastcgi_params; } location ~ ^/(setup|update)/(?!pub/). { deny all; } location ~ ^/(setup|update)/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } location /static/ { expires max; if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$
/static.php?resource=$2 last; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/ { try_files $uri $uri/ /get.php?$args; location ~ ^/media/theme_customization/.*\.xml { deny all; } add_header X-Frame-Options "SAMEORIGIN"; } location ~ \.php$ { fastcgi_pass unix:/var/run/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name; include fastcgi_params; } }

As you can see, this is significantly more complex than a basic WordPress configuration. There are four main sections; the first is to handle the setup and updates, the second is to handle static media (for example, default Magento, CSS, and JavaScript), media files (for example, upload images), and finally how to process PHP files.

主站蜘蛛池模板: 巴楚县| 五华县| 宜良县| 西安市| 宁波市| 盘山县| 阿尔山市| 临朐县| 溧阳市| 松溪县| 新蔡县| 凤台县| 达拉特旗| 天祝| 西吉县| 汉沽区| 惠安县| 肇庆市| 蒲江县| 云安县| 广西| 武城县| 韶关市| 当涂县| 靖江市| 扬州市| 承德市| 云和县| 洛阳市| 漳平市| 宜黄县| 四子王旗| 柯坪县| 日土县| 长泰县| 军事| 云龙县| 新化县| 南汇区| 巴南区| 乌恰县|