我已经在具有多个服务器块和多个域的数字海洋服务器上部署了 laravel 8 应用程序,所有其他域都可以正常工作,因为它们不是 laravel 应用程序。我按照本教程https://www.digitalocean.com/community/tutorials/automatically-deploy-laravel-applications-deployer-ubuntu
一切正常。这意味着我设法成功部署。但是当我访问域名时。它显示/目录的索引,目录为
current
, shared
,release
我也遵循了这个https://deployer.org/docs/how-to-deploy-laravel.html我必须编辑我etc/nginx/sites-available/example.co.vx
的指向current/public
文件夹。目前文件看起来像这样
##
# You should look at the following URL's in order to grasp a solid unders>
# of Nginx configuration files in order to fully unleash the power of Ngi>
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitf>
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/>
# leave it as reference inside of sites-available where it will continue >
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be m>
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed example>
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.co.vx www.example.co.vx
# 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/example.co.vx/public_html;
root /var/www/example.co.vx/public_html/current/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
# server_name example.co.vx www.example.co.vx;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
# try_files $uri /index.php$is_args$args;
try_files $uri $uri/ /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_scri>
fastcgi_param DOCUMENT_ROOT $realpath_root
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# With php-cgi (or other tcp sockets):
fastcgi_pass 127.0.0.1:9000;
}
# 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/example.co.tz/fullchain.pe>
ssl_certificate_key /etc/letsencrypt/live/example.co.tz/privkey.>
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlin>
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
我仍然有同样的问题。所以我认为这是我的 apache2 服务的问题,所以我编辑了我的 VirtaulHost 文件/etc/apache2/sites-enabled/example.co.vx.conf
,它现在看起来像这样
<VirtualHost *:8080>
ServerName example.co.vx
ServerAlias www.example.co.vx
DocumentRoot /var/www/example.co.vx/public_html/current/public
<Directory /var/www/example.co.vx/public_html/current/public>
AllowOverride All
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.co.vx [OR]
RewriteCond %{SERVER_NAME} =www.example.co.vx
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
这一切都是徒劳的,我仍然有同样的错误。
到目前为止,当我像这样导航 url 时, /var/www/example.co.vx/public_html/current/public/index.php
我可以查看页面,但它不会加载图像和其他文件和页面。
我查找了类似的问题,但没有一个能够解决我的问题。