Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用nginx在linux服务器上部署Laravel应用程序时出现404错误_Php_Linux_Laravel_Nginx_Deployment - Fatal编程技术网

Php 使用nginx在linux服务器上部署Laravel应用程序时出现404错误

Php 使用nginx在linux服务器上部署Laravel应用程序时出现404错误,php,linux,laravel,nginx,deployment,Php,Linux,Laravel,Nginx,Deployment,这是我班期末专题的最后一步。我遵循Digital Ocean{{}中的步骤,但在调用URL时出现404错误 以下代码是nginx配置。由于我是拉威尔的新手,我也不知道如何部署它。这也是我第一次使用服务器进行部署 # Default server configuration # server { listen 80; listen [::]:80; # SSL configuration #

这是我班期末专题的最后一步。我遵循Digital Ocean{{}中的步骤,但在调用URL时出现404错误

以下代码是nginx配置。由于我是拉威尔的新手,我也不知道如何部署它。这也是我第一次使用服务器进行部署

    # Default server configuration
    #
    server {
            listen 80;
            listen [::]:80;
 # SSL configuration
        #
         #listen 443 ssl http2;
        # listen [::]:443 ssl http2;

        access_log            /var/log/nginx/jenkins.access.log;
        error_log            /var/log/nginx/jenkins.error.log;
        #
        # 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/ssl-marikhu.com.conf;
        #include snippest/ssl-params.conf;

        root /var/www/laravel/smartroom/public;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.ngix-debian.html;

        server_name marikhu.com www.marikhu.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
  try_files $uri $uri//index.php?query_string;
                include /etc/nginx/proxy_params;
                proxy_pass          http://localhost:8080;
                proxy_read_timeout  90s;
                # Fix potential "It appears that your reverse proxy set up is b$
                proxy_redirect      http://localhost:8080 https://marikhu.com;
        }

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

    listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/marikhu.com/fullchain.pem; # managed by C$
ssl_certificate_key /etc/letsencrypt/live/marikhu.com/privkey.pem; # managed by$
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}


# 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 moodymountains.marikhu.com;
#
#       root /var/www/html;
#       index index.php;
#
}


# 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 moodymountains.marikhu.com;
#
#       root /var/www/html;
#       index index.php;
#
}


# 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 moodymountains.marikhu.com;
#
#       root /var/www/html;
#       index index.php;
#}
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}
更换此块

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
  try_files $uri $uri//index.php?query_string;
                include /etc/nginx/proxy_params;
                proxy_pass          http://localhost:8080;
                proxy_read_timeout  90s;
                # Fix potential "It appears that your reverse proxy set up is b$
                proxy_redirect      http://localhost:8080 https://marikhu.com;
        }
为此:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

保存文件,重新启动您的nginx服务器并再次尝试访问。

A来自nginx站点。@Mohammad sumon molla selim您的意思是我必须注释掉它吗包括/etc/nginx/proxy\u参数;代用通行证;代理读取超时90秒;#修复潜在问题“您的反向代理设置似乎是b$proxy\u redirect;它现在对我有效!但我只能看到欢迎视图。我无法登录并注册页面和其他页面:(其他页面返回404?