>  기사  >  백엔드 개발  >  Mac은 MAMP를 개발 환경으로 사용합니다. laravel 페이지를 찾을 수 없습니다.

Mac은 MAMP를 개발 환경으로 사용합니다. laravel 페이지를 찾을 수 없습니다.

WBOY
WBOY원래의
2016-09-01 00:20:161444검색

이 학습문서를 참고하여 라라벨을 배웠습니다

Ubuntu에서 코드를 입력했습니다. ID가 있는 링크는 localhost/articles/id에 대한 일반적인 액세스이며 데이터베이스의 내용을 표시합니다. 그러나 Mac에서 mamp 환경 URL에 매개변수를 사용하여 액세스하면 페이지가 표시되지 않습니다. 발견이 나타나는 이유를 모르겠습니다.

<code>@section('content')
    <article class="format-image group">
        <h2 class="post-title pad">
            <a href="/articles/{{ $article->id }}" rel="bookmark"> {{ $article->title }}</a>

> *这个A标签里面带的id*

        </h2>
        <div class="post-inner">
            <div class="post-content pad">
                <div class="entry custome">
                    {{ $article->content }}
                </div>
            </div>
        </div>
    </article>
@endsection</code>

MAMP에서 nginx.conf를 수정해야 할 것 같은데 이유를 모르겠습니다

<code>user                         root admin;
worker_processes             2;

events {
    worker_connections       1024;
}

http {
    include                    mime.types;
    default_type             text/html;
    gzip                     on;
    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;

    server {
        listen               80 default_server;

        # MAMP DOCUMENT_ROOT !! Don't remove this line !!
        root                 "/Applications/MAMP/htdocs/laravel/public";

        access_log           /Applications/MAMP/logs/nginx_access.log;
        error_log            /Applications/MAMP/logs/nginx_error.log debug;

        location / {
            index            index.html index.php;
        }
    
        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;
            }
        }
        
        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 /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_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include          fastcgi_params;
        }

        location ~ /\. {
            deny all;
        }

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

이런 문제를 겪은 전문가가 있나요? ? ?

답글 내용:

이 학습문서를 참고하여 라라벨을 배웠습니다

Ubuntu에서 코드를 입력했습니다. ID가 있는 링크는 localhost/articles/id에 대한 일반적인 액세스이며 데이터베이스의 내용을 표시합니다. 그러나 Mac에서 mamp 환경 URL에 매개변수를 사용하여 액세스하면 페이지가 표시되지 않습니다. 발견이 나타나는 이유를 모르겠습니다.

<code>@section('content')
    <article class="format-image group">
        <h2 class="post-title pad">
            <a href="/articles/{{ $article->id }}" rel="bookmark"> {{ $article->title }}</a>

> *这个A标签里面带的id*

        </h2>
        <div class="post-inner">
            <div class="post-content pad">
                <div class="entry custome">
                    {{ $article->content }}
                </div>
            </div>
        </div>
    </article>
@endsection</code>

MAMP에서 nginx.conf를 수정해야 할 것 같은데 이유를 모르겠습니다

<code>user                         root admin;
worker_processes             2;

events {
    worker_connections       1024;
}

http {
    include                    mime.types;
    default_type             text/html;
    gzip                     on;
    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;

    server {
        listen               80 default_server;

        # MAMP DOCUMENT_ROOT !! Don't remove this line !!
        root                 "/Applications/MAMP/htdocs/laravel/public";

        access_log           /Applications/MAMP/logs/nginx_access.log;
        error_log            /Applications/MAMP/logs/nginx_error.log debug;

        location / {
            index            index.html index.php;
        }
    
        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;
            }
        }
        
        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 /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_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include          fastcgi_params;
        }

        location ~ /\. {
            deny all;
        }

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

이런 문제를 겪은 전문가가 있나요? ? ?

제가 이해한 바에 따르면 nginx가 php에 액세스하려면 php-fpm을 거쳐야 합니다....

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.