- NGINX Cookbook
- Tim Butler
- 241字
- 2021-07-03 00:04:26
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.
- Microsoft Dynamics 365 Extensions Cookbook
- 編程珠璣(續)
- Ray分布式機器學習:利用Ray進行大模型的數據處理、訓練、推理和部署
- 老“碼”識途
- 基于Swift語言的iOS App 商業實戰教程
- TypeScript項目開發實戰
- 組態軟件技術與應用
- Haskell Data Analysis Cookbook
- Developing SSRS Reports for Dynamics AX
- Spring Boot實戰
- Python編程:從入門到實踐(第3版)
- Android技術內幕(系統卷)
- 循序漸進Vue.js 3前端開發實戰
- Access 2016數據庫應用與開發:實戰從入門到精通(視頻教學版)
- 新手學ASP.NET 3.5網絡開發