首页 > 后端开发 > php教程 > Mac 用MAMP当开发环境 laravel页面出现not found

Mac 用MAMP当开发环境 laravel页面出现not found

WBOY
发布: 2016-09-01 00:20:16
原创
1505 人浏览过

我是按照这篇学习文档学习laravel的

在Ubuntu上已经敲过一边代码了,链接中带Id是正常访问的localhost/articles/id 显示数据库里的内容,但是在mac中的mamp环境url中带参数访问 就会出现页面 not found不知道为什么

<code>@section('content')
    <article class="format-image group">
        <h2 class="post-title pad">
            <a href="/articles/%7B%7B%20%24article->id%20%7D%7D" 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>
登录后复制
登录后复制

有没有哪位大神遇到过这类问题???

回复内容:

我是按照这篇学习文档学习laravel的

在Ubuntu上已经敲过一边代码了,链接中带Id是正常访问的localhost/articles/id 显示数据库里的内容,但是在mac中的mamp环境url中带参数访问 就会出现页面 not found不知道为什么

<code>@section('content')
    <article class="format-image group">
        <h2 class="post-title pad">
            <a href="/articles/%7B%7B%20%24article->id%20%7D%7D" 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....

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板