【问题标题】:Joomla Examples doesn't Works on NGINX with MAMPJoomla 示例不适用于带有 MAMP 的 NGINX
【发布时间】:2017-08-23 13:21:21
【问题描述】:

我已经在 Mac 中使用 NGINX 的 MAMP 中安装了 Joomla 3.6.5 并且运行良好,但我还在安装过程中安装了 Joomla 默认具有的示例演示,这些 URL 不起作用。我还阅读了documentation about Joomla and NGINX 并将一些更改应用到我的 nginx.conf 文件中,但它没有修复它。

这是我位于 /Applications/MAMP/conf/nginx 目录下的 nginx.conf 文件:

user                         myuser staff;
worker_processes             2;

events {
    worker_connections       1024;
}

http {
    include                  mime.types;
    default_type             text/html;
    gzip on;

    gzip_comp_level 6;
    gzip_min_length 1100;
    gzip_buffers 4 8k;
    gzip_types               text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;

    sendfile                 on;
    client_max_body_size 200M;

    server {
        listen               7888 default_server; 

        server_name localhost;
        server_name_in_redirect off;

        access_log           /Applications/MAMP/logs/nginx_access.log;
        error_log            /Applications/MAMP/logs/nginx_error.log;
        # MAMP DOCUMENT_ROOT !! Don't remove this line !!
        root                 "/Applications/MAMP/htdocs";
        index index.php index.html index.htm  default.html  default.htm;

        location / {
            #index            index.html index.php;
            #try_files $uri $uri/ /index.php?$args;
            try_files $uri $uri/ /index.php?q=$request_uri;
        }

        location ~* /MAMP[^-]*(.*)$ {
            root             /Applications/MAMP/bin;
            index            index.php;

            location ~ \.php$ {
                try_files        $uri =404;
                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include          fastcgi_params;
            }
        }

        location ~* /phpMyAdmin(.*)$ {
            root             /Applications/MAMP/bin;
            index            index.php;

            location ~ \.php$ {
                try_files        $uri =404;
                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include          fastcgi_params;
            }
        }

        location ~* /phpPgAdmin(.*)$ {
            root             /Applications/MAMP/bin;
            index            index.php;

            location ~ \.php$ {
                try_files        $uri =404;
                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include          fastcgi_params;
            }
        }
        # deny running scripts inside writable directories
        location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                return 403;
                error_page 403 /403_error.html;
        }

        location ~* /phpLiteAdmin(.*)$ {
            root             /Applications/MAMP/bin;
            index            index.php;

            location ~ \.php$ {
                try_files        $uri =404;
                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include          fastcgi_params;
            }
        }

        location ~* /SQLiteManager(.*)$ {
            root             /Applications/MAMP/bin;
            index            index.php;

            location ~ \.php$ {
                try_files        $uri =404;
                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include          fastcgi_params;
            }
        }

        location ~* /adminer(.*)$ {
            root             /Applications/MAMP/bin;
            index            adminer.php;

            location ~ \.php$ {
                try_files        $uri =404;
                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include          fastcgi_params;
            }
        }

        location /icons {
            alias /Applications/MAMP/Library/icons;
            autoindex on;
        }

        location /favicon.ico {
            alias /Applications/MAMP/bin/favicon.ico;
            # log_not_found off;
            # access_log off;
        }

        location ~ \.php$ {

            try_files        $uri =404;
            fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
            fastcgi_index index.php;
            fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include          fastcgi_params;
            include fastcgi.conf;
        }

        location ~ /\. {
            deny all;
        }
        # caching of files 
        location ~* \.(ico|pdf|flv)$ {
                expires 1y;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
                expires 14d;
        }
        # location ~* \.(gif|jpg|png|pdf)$ {
        #   expires          30d;
        # }

        # location = /robots.txt {
        #   allow all;
        #   log_not_found off;
        #   access_log off;
        # }

        # location ~* \.(txt|log)$ {
        #   allow 127.0.0.1;
        #   deny all;
        # }

        # location ~ \..*/.*\.php$ {
        #   return 403;
        # }

        location /nginx_status {
            stub_status      on;
            access_log       off;
            allow            127.0.0.1;
            deny             all;
        }
    }

    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

这是我尝试访问http://localhost:7888/joomla3/index.php/getting-started时遇到的错误:

【问题讨论】:

    标签: php nginx joomla mamp joomla3.0


    【解决方案1】:

    官方 Joomla 指南不再有效,必须更新。

    您遇到的问题正是this。本质上,正在发生的事情是 nginx 没有设置 $_SERVER['PHP_SELF'] 变量的值,该变量在 Joomla 核心中非常依赖。您必须在nginx.conf 中设置PATH_TRANSLATED 的值,然后再设置$_SERVER['PHP_SELF'] 的值以解决此问题。

    【讨论】:

    • 你好兄弟,我很抱歉这个答案迟到了,但这些月我一直很忙,我试图在 MAMP 中设置 PATH_TRANSLATED 再次编辑我的 nginx.conf 和我的 fastcgi_params 但我再次失败了问题仍然存在,您能否详细解释一下,我该怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    • 2016-07-19
    • 1970-01-01
    相关资源
    最近更新 更多