Magento là một nền tảng mã nguồn mở cho phép bất cứ ai có thể xây dựng một cửa hàng thương mại điện tử trực tuyến, linh hoạt và làm việc đầy đủ. Nó có một giao diện quản trị trực quan, addons/plugins mạnh mẽ và nó là công cụ tìm kiếm thân thiện. Cấu hình Nginx cho Magento khá dễ dàng và nhanh chóng để kiểm tra. Tôi sẽ giả sử bạn có Nginx và PHP-FPM cấu hình để làm việc với socket, nếu không, bạn nên cần thay đổi dòng fastcgi_pass_unix tới 127.0.0.1:9000, đó là cổng mặc định và interface php-fpm lắng nghe. Bạn có thể thay đổi domain.com với tên miền riêng của bạn và thư mục root đến thư mục root thực sự của trang web của bạn. Tạo ra một tập tin mới cấu hình virtual host cho Magento hoặc có thể chỉnh sửa tập tin đã có sẵn: Mã: vim /etc/nginx/conf.d/yoursite.com.conf Lưu ý: hãy nhớ thay đổi yoursite.com cho tên trang web thực sự của bạn, và tinh chỉnh thiết lập này khi bạn cần. Sau đó dán đoạn này bên trong: Mã: server { listen 80; server_name domain.com www.domain.com; root /var/www/domain.com; location / { index index.html index.php; ## If missing pass the URI to Magento's front handler try_files $uri $uri/ @handler; expires max; ## Enable max file cache } ## These locations need to be denied location ^~ /app/ { deny all; } location ^~ /includes/ { deny all; } location ^~ /lib/ { deny all; } location ^~ /media/downloadable/ { deny all; } location ^~ /pkginfo/ { deny all; } location ^~ /report/config.xml { deny all; } location ^~ /var/ { deny all; } ## Allow admins only to view export directory ## Set up the password for any username using this command: ## htpasswd -c /etc/nginx/htpasswd magentoadmin location /var/export/ { auth_basic "Restricted"; auth_basic_user_file htpasswd; ## Defined at /etc/nginx/htpassword autoindex on; } ## Disable .htaccess and other hidden files location /. { return 404; } ## Magento uses a common front handler location @handler { rewrite / /index.php; } ## Forward paths like /js/index.php/x.js to relevant handler location ~ .php/ { rewrite ^(.*.php)/ $1 last; } ## php-fpm parsing location ~ .php$ { ## Catch 404s that try_files miss if (!-e $request_filename) { rewrite / /index.php last; } ## Disable cache for php files expires off; ## php-fpm configuration fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_param HTTPS $fastcgi_https; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; ## Store code is located at Administration > Configuration > Manage Stores in your Magento Installation. fastcgi_param MAGE_RUN_CODE default; fastcgi_param MAGE_RUN_TYPE store; ## Tweak fastcgi buffers, just in case. fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } } Hãy nhớ thay đổi giá trị domain.com theo tên domain thực sự của bạn và thư mục root theo đúng đường dẫn thư mục root của trang web của bạn. Sau khi thực hiện, reload Nginx để áp dụng các thay đổi: Mã: service nginx reload Chú thích: Nếu bạn đang sử dụng Fooman Speedster bạn sẽ cần phải thêm đoạn mã sau đây đến khối server. Mã: rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last; rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last; location /lib/minify/ { allow all; }