nginx解析不到laravel/public裡的index.php檔案

來源:互聯網
上載者:User
我將/etc/nginx/sites-available/default裡面把root路徑改成裡/var/www/html/laravel/public了,但是運行結果是403,一開始以為是檔案夾許可權不夠,照著網上說都storage和vendor都許可權都可以讀寫裡還是不行。 哪位大神幫我看看啊!
下面是我的nginx設定檔:

server {    listen 80 default_server;    listen [::]:80 default_server;    # SSL configuration    #    # listen 443 ssl default_server;    # listen [::]:443 ssl default_server;    #    # Note: You should disable gzip for SSL traffic.    # See: https://bugs.debian.org/773332    #    # Read up on ssl_ciphers to ensure a secure configuration.    # See: https://bugs.debian.org/765782    #    # Self signed certs generated by the ssl-cert package    # Don't use them in a production server!    #    # include snippets/snakeoil.conf;    root /var/www/html/laravel/public;    # Add index.php to the list if you are using PHP    index index.html index.htm index.nginx-debian.html;    server_name _;    location / {        # First attempt to serve request as file, then        # as directory, then fall back to displaying a 404.        try_files $uri $uri/ =404;    }    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000    #    location ~ \.php$ {        include snippets/fastcgi-php.conf;        #   With php7.0-cgi alone:    #    fastcgi_pass 127.0.0.1:9000;    #   With php7.0-fpm:        fastcgi_pass unix:/run/php/php7.0-fpm.sock;    }    # deny access to .htaccess files, if Apache's document root    # concurs with nginx's one    #    location ~ /\.ht {        deny all;    }}# Virtual Host configuration for example.com## You can move that to a different file under sites-available/ and symlink that# to sites-enabled/ to enable it.##server {#    listen 80;#    listen [::]:80;##    server_name example.com;##    root /var/www/html/laravel/public;#    index index.html;##    location / {#        try_files $uri $uri/ =404;#    }#}

回複內容:

我將/etc/nginx/sites-available/default裡面把root路徑改成裡/var/www/html/laravel/public了,但是運行結果是403,一開始以為是檔案夾許可權不夠,照著網上說都storage和vendor都許可權都可以讀寫裡還是不行。 哪位大神幫我看看啊!
下面是我的nginx設定檔:

server {    listen 80 default_server;    listen [::]:80 default_server;    # SSL configuration    #    # listen 443 ssl default_server;    # listen [::]:443 ssl default_server;    #    # Note: You should disable gzip for SSL traffic.    # See: https://bugs.debian.org/773332    #    # Read up on ssl_ciphers to ensure a secure configuration.    # See: https://bugs.debian.org/765782    #    # Self signed certs generated by the ssl-cert package    # Don't use them in a production server!    #    # include snippets/snakeoil.conf;    root /var/www/html/laravel/public;    # Add index.php to the list if you are using PHP    index index.html index.htm index.nginx-debian.html;    server_name _;    location / {        # First attempt to serve request as file, then        # as directory, then fall back to displaying a 404.        try_files $uri $uri/ =404;    }    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000    #    location ~ \.php$ {        include snippets/fastcgi-php.conf;        #   With php7.0-cgi alone:    #    fastcgi_pass 127.0.0.1:9000;    #   With php7.0-fpm:        fastcgi_pass unix:/run/php/php7.0-fpm.sock;    }    # deny access to .htaccess files, if Apache's document root    # concurs with nginx's one    #    location ~ /\.ht {        deny all;    }}# Virtual Host configuration for example.com## You can move that to a different file under sites-available/ and symlink that# to sites-enabled/ to enable it.##server {#    listen 80;#    listen [::]:80;##    server_name example.com;##    root /var/www/html/laravel/public;#    index index.html;##    location / {#        try_files $uri $uri/ =404;#    }#}

root下面一行的index後面加入一個index.php

問題找到了, 還是設定檔寫錯了

root /var/www/html/laravel/public;    # Add index.php to the list if you are using PHP    index index.html index.htm index.nginx-debian.html ;  ------>這裡面要加上index.php    server_name _;------------>這裡要把網域名稱寫成127.0.0.1或者local    但是後來我測試裡下用底線 貌似也是可以正常顯示的
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.