简体   繁体   English

Joomla示例在带有MAMP的NGINX上不起作用

[英]Joomla Examples doesn't Works on NGINX with MAMP

I have installed Joomla 3.6.5 inside my MAMP with NGINX in Mac and works perfectly,but I also installed the examples demos that Joomla have by default on the installation process and these URL's doesn't works. 我已经在Mac中使用NGINX在MAMP中安装了Joomla 3.6.5,并且可以完美运行,但是我还安装了Joomla在安装过程中默认具有的示例演示,并且这些URL不起作用。 I also read the documentation about Joomla and NGINX and apply some changes into my nginx.conf file,but it don't fix it. 我还阅读了有关Joomla和NGINX文档,并对我的nginx.conf文件进行了一些更改,但是并不能解决它。

This is my nginx.conf file located on /Applications/MAMP/conf/nginx Directory: 这是我的nginx.conf文件,位于/ Applications / MAMP / conf / nginx目录中:

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;
    #    }
    #}
}

This is the error that I have ,when I try to visit http://localhost:7888/joomla3/index.php/getting-started : 这是我尝试访问http:// localhost:7888 / joomla3 / index.php / getting-started时遇到的错误

在此处输入图片说明

The official Joomla guide no longer works and must be updated. Joomla官方指南不再有效,必须进行更新。

The problem that you're having is exactly this . 您遇到的问题就是这个 Essentially, what is happening is that nginx is not setting the value of the $_SERVER['PHP_SELF'] variable, which is heavily relied on in the Joomla core. 本质上,正在发生的事情是nginx并未设置$_SERVER['PHP_SELF']变量的值,而该变量在Joomla核心中高度依赖。 You mus set the value of PATH_TRANSLATED in your nginx.conf , which in turn will set the value of the $_SERVER['PHP_SELF'] in order to solve this problem. 您可以在nginx.conf设置PATH_TRANSLATED的值,该值将依次设置$_SERVER['PHP_SELF']的值以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM