在数字海洋上部署Laravel网站,显示空白屏幕,并试图通过HTTPS加载CS和JS文件

发布于 2025-02-12 11:39:14 字数 2068 浏览 1 评论 0原文

我跟随有关Laravel应用部署的一个教程,此处 https://www.techalyst.com/posts/laravel-hosting-with-with-digital-ocean-cean-droplet-step-by-step-tep-tutorial ,并且能够在数字海洋上部署我的Laravel应用程序使用LEMP堆栈。 Laravel用作后端,而Vuejs处理前端。我还安装了nodejs(V16),然后进行NPM安装,然后进行NPM Run Prod。但是,我的应用在浏览器上显示一个空白页面,并在控制台上显示一些错误。我的nginx服务器文件看起来像这样。

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    
    root /var/www/laravel/public;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name 147.182.184.11;
    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }

    location ~ \.css {
        add_header  Content-Type    text/css;
    }

     location ~ \.js {
        add_header  Content-Type    application/x-javascript;
    }

}

我的Project文件夹生活在Var/www/laravel中,从Github推出后,我可以在目录中看到所有Laravel文件夹和文件。我已经安装了作曲家,安装了MySQL,创建了用户,授予并冲洗了特权,并按照教程中的指示创建了数据库。我还设置了.env文件并修改了必要的变量。

APP_NAME=laravel
APP_ENV=production
APP_KEY=base64:generated-key-here
APP_DEBUG=false
APP_URL=http://147.182.184.11

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=my-password

此后,我清除了缓存:

sudo php artisan config:cache
sudo php artisan route:cache

成功进行了迁移。但是,键入我的IP地址显示一个空白屏幕。在镀铬控制台上,我有这个。

GET https://147.182.184.11/css/app.css net::ERR_CONNECTION_REFUSED
GET https://147.182.184.11/js/app.js net::ERR_CONNECTION_REFUSED
GET https://147.182.184.11/images/assets/relicon.png net::ERR_CONNECTION_REFUSED

我已经搜索了网络,我发现的一些类似的问题有答案,这些答案无济于事或更改任何问题。我尚未安装SSL证书,也没有添加域名。我已经整整一天了,似乎没有什么可用。我该如何解决?任何帮助将不胜感激。

I followed through one of the tutorials on deployment of laravel app here https://www.techalyst.com/posts/laravel-hosting-with-digital-ocean-droplet-step-by-step-tutorial and was able to deploy my laravel app on digital ocean, using the LEMP stack. Laravel is used as backend while vuejs handles the front end. I also installed nodejs (v16), then did npm install and then npm run prod. However, my app shows a blank page on the browser and some errors on the console.My nginx server file looks like this;

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    
    root /var/www/laravel/public;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name 147.182.184.11;
    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }

    location ~ \.css {
        add_header  Content-Type    text/css;
    }

     location ~ \.js {
        add_header  Content-Type    application/x-javascript;
    }

}

my project folders live in var/www/laravel, and after pushing from github, i can see all my laravel folders and files in the directory. i have installed composer, installed MySql, created user, granted and flushed privileges and created the database as instructed in the tutorial. I have also set up my .env file and modified the necessary variables like so;

APP_NAME=laravel
APP_ENV=production
APP_KEY=base64:generated-key-here
APP_DEBUG=false
APP_URL=http://147.182.184.11

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=my-password

After this, i cleared the cache:

sudo php artisan config:cache
sudo php artisan route:cache

and ran migration successfully. However, typing my IP address shows a blank screen. On the chrome console, i have this;

GET https://147.182.184.11/css/app.css net::ERR_CONNECTION_REFUSED
GET https://147.182.184.11/js/app.js net::ERR_CONNECTION_REFUSED
GET https://147.182.184.11/images/assets/relicon.png net::ERR_CONNECTION_REFUSED

I have searched through the net and some similar questions i found had answers which didn't help or change anything. I have not installed SSL certificate and i have not yet added a domain name. I have been on this for a full day and nothing seems to work. How do i fix this? Any assistance will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文