php - Nginx 上的 Magento - 配置

标签 php magento nginx tinymce

<分区>

我正在开发用于运行 Magento 的 nginx.conf,该网站大部分都可以运行,magento 使用 php-fpm 运行。

但它的某些部分仍然无法正常工作,我已经尝试了网络上的每个 wiki、博客等。

我的问题是,我在 CMS 页面和 block 上有一个 Javascript 弹出窗口,主要是 tiny_mce 所见即所得编辑器,(/js/tiny_mce/plugins/advimage/image.htm 等)他们打开一个 页面未找到

我不知道该怎么做才能让这个编辑器正确显示。

另外,下载器不显示。

似乎它们中的每一个都在与 root 不同的文件夹中使用自己的 index.php,所以我应该将索引更改为那个吗?

喜欢 $document_root/downloader/index.php 吗?

最佳答案

我强烈建议您阅读并关注 nginx primer by Martin Fjordvald .

我对 Magento 使用以下配置。它不仅效果很好,它还关闭了图像等的 access_log,并且有一个特殊的 php-fpm 配置。请注意,服务器根是在服务器 block 中指定的。多个配置文件在位置 block 中错误地指定了它。

Magento nginx 配置文件: (一定要相应地替换所有路径和域名)

server {
    listen 80;
    #listen 443 default ssl;
    server_name DOMAIN.COM;
    #rewrite requests to www
    rewrite ^ $scheme://www.DOMAIN.COM$request_uri permanent;
}

server {
    listen 80;
    #listen 443 default ssl;
    #ssl_certificate /path/to/ssl.crt;
    #ssl_certificate_key /path/to/ssl.key;

    server_name www.DOMAIN.COM;
    # most likely /var/www/...
    root /path/to/files;

    include /etc/nginx/restrictions.conf;

    location / {
        index index.php;
        if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
            access_log off;
            expires max;
        }
        try_files $uri $uri/ @handler;
    }

    # protect directories
    location /app/ {
        deny all;
    }
    location /includes/ {
        deny all;
    }
    location /lib/ {
        deny all;
    }
    location /lib/minify/ {
        allow all;
    }
    location /media/downloadable/ {
        deny all;
    }
    location /pkginfo/ {
        deny all;
    }
    location /report/config.xml {
        deny all;
    }
    location /var/ {
        deny all;
    }

    location /var/export/ {
        # restrict access to admins
        auth_basic "Restricted";
        auth_basic_user_file htpasswd;
        autoindex on;
    }

    location @handler {
        rewrite ^(.*) /index.php?$1 last;
    }

    # include php specific configuration
    include /etc/nginx/php.conf;
}

这是一个 php-fpm 特定的配置文件,它拦截错误代码并正确分割路径信息,因此您可以访问 PHP 中的正确路径部分。由于性能改进,我还使用 Unix 套接字而不是端口。另请注意,您无需重复已在 fastcgi_params 中指定的 fastcgi_params。

fastcgi_intercept_errors on;

# this will allow Nginx to intercept 4xx/5xx error codes
# Nginx will only intercept if there are error page rules defined
# -- This is better placed in the http {} block as a default
# -- in that virtual host's server block

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # A handy function that became available in 0.7.31 that breaks down 
    # The path information based on the provided regex expression
    # This is handy for requests such as file.php/some/paths/here/ 

    include fastcgi_params;

    fastcgi_index index.php;
    fastcgi_pass unix:/var/run/phpfpm.sock;
}

我的 fastcgi_params 配置文件针对小型服务器(<1GB RAM)进行了优化。请务必根据您的服务器性能进行调整:

fastcgi_param    QUERY_STRING        $query_string;
fastcgi_param    REQUEST_METHOD        $request_method;
fastcgi_param    CONTENT_TYPE        $content_type;
fastcgi_param    CONTENT_LENGTH        $content_length;

fastcgi_param    SCRIPT_FILENAME        $document_root$fastcgi_script_name;
fastcgi_param    SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param    REQUEST_URI        $request_uri;
fastcgi_param    DOCUMENT_URI        $document_uri;
fastcgi_param    DOCUMENT_ROOT        $document_root;
fastcgi_param    SERVER_PROTOCOL        $server_protocol;

fastcgi_param    GATEWAY_INTERFACE    CGI/1.1;
fastcgi_param    SERVER_SOFTWARE        nginx/$nginx_version;

fastcgi_param    REMOTE_ADDR        $remote_addr;
fastcgi_param    REMOTE_PORT        $remote_port;
fastcgi_param    SERVER_ADDR        $server_addr;
fastcgi_param    SERVER_PORT        $server_port;
fastcgi_param    SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param    REDIRECT_STATUS        200;

fastcgi_connect_timeout 90;
fastcgi_send_timeout 180;
fastcgi_read_timeout 360;
fastcgi_buffer_size 1024k;
fastcgi_buffers 8 512k;
fastcgi_busy_buffers_size 1024k;
fastcgi_temp_file_write_size 1024k;
fastcgi_intercept_errors on;
fastcgi_pass_header *;

关于php - Nginx 上的 Magento - 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7640267/

相关文章:

php - 不知道如何将图像差异添加到 HTML 表的 php/sql 填充中

magento - magento安装过程中文件的权限

php - 如何在 Magento 中手动更新库存数量

magento - 何时不使用 local.xml 在 magento 中进行主题开发

node.js - https nginx 403 禁止

php - 使用 Nginx 在 OpenCart 上的多个商店和子域上启用 SEO URL

laravel - 502错误的网关Docker + Laravel

php - 使用悬停超时导航表行时清除隐藏值

php - 通过 PHP 连接到 MySQL 的 JSON Web 钩子(Hook)

javascript - 如何在我的自定义网站中添加 CSS 和 HTML 编辑器?