Home  >  Article  >  Backend Development  >  Mac uses MAMP as the development environment. The laravel page appears not found.

Mac uses MAMP as the development environment. The laravel page appears not found.

WBOY
WBOYOriginal
2016-09-01 00:20:161444browse

I learned laravel according to this learning document

I have typed a code on Ubuntu. The link with Id is the localhost/articles/id that is normally accessed and displays the content in the database. However, when accessing with parameters in the mamp environment url in mac, the page not found appears. I don’t know. Why

<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>

It should be that nginx.conf needs to be modified in MAMP, but I don’t know the reason

<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>

Has any expert encountered this kind of problem? ? ?

Reply content:

I learned laravel according to this learning document

I have typed a code on Ubuntu. The link with Id is the localhost/articles/id that is normally accessed and displays the content in the database. However, when accessing with parameters in the mamp environment url in mac, the page not found appears. I don’t know. Why

<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>

It should be that nginx.conf needs to be modified in MAMP, but I don’t know the reason

<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>

Has any expert encountered this kind of problem? ? ?

My understanding is that if nginx accesses php, it needs to go through php-fpm....

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn