为什么子域在 Ubuntu nginx 服务器中不起作用?

时间:2021-04-11 16:23:31

标签: laravel ubuntu nginx server

在我的 ubuntu nginx 服务器的根文件夹中有一个正在运行的 Laravel 应用程序。现在我正在尝试创建一个子域并在那里运行另一个 Laravel 应用程序。例如,

  1. findosman.xyz(root,运行 Laravel 应用程序)
  2. api.devport.findosman.xyz(另一个 Laravel API)

这是我目前的配置; 在/etc/nginx/sites-available/api.devport.findosman.xyz

server {
        listen 80;
        listen [::]:80;

        root /var/www/api-devport;

        index index.php index.html index.htm;

        server_name api.devport.findosman.xyz;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

        }

        location ~ /\.ht {
                deny all;
        }
}

这是/etc/nginx/sites-enabled/api.devport.findosman.xyz

server {
        listen 80;
        listen [::]:80;
        root /var/www/api-devport;
 index index.php index.html index.htm;

        server_name api.devport.findosman.xyz;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        }

        location ~ /\.ht {
                deny all;
        }
}

/var/www/api-devport 中,我目前只有一个 index.php 文件,其中只有 <?php echo "hello world"?>

根文件夹项目运行良好。但无论我在哪里尝试访问 devport.findosman.xyz,它都显示无法访问该站点。

如何克服这个问题?提前致谢。

0 个答案:

没有答案