reactjs - 在 Apache Centos 中使用 Laravel API 反应应用程序部署
问题描述
我在 Laravel 中有一个带有连接 API 的反应 js 应用程序。在 localhost 中一切正常。当我试图在我的 apache 服务器中托管这个应用程序时,我遇到了一个问题。
试图实现以下配置:
- 我的反应应用程序域是www.example.com
- 我的 Laravel 应用程序域是www.example.com/api
对于上述 URL 设置
- 文档根文件夹:/var/www/html
- 反应文件夹:/var/www/html/react/build
- laravel 文件夹:/var/www/html/app/
我的虚拟主机配置是
<VirtualHost *:443>
# Client React application
DocumentRoot "/var/www/html/react/build"
ServerName example.com
SSLEngine on
# Server Laravel 7 API application
Alias /api /var/www/html/app/public/
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# Rewrite all requests in /api to server index.php
<Location /api>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /api/index.php [L]
</Location>
<Directory "/var/www/html/app/public/">
AllowOverride All
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
<virtualhost *:80>
DocumentRoot /var/www/html
</virtualhost>
在 /var/www/html/.htaccess 中创建 .htaccess
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
我收到类似“在此服务器上找不到请求的 URL”之类的错误。
请帮我。我在这个配置中做错了什么。相同的配置适用于角度。
解决方案
推荐阅读
- java - Java : variable reuse
- javascript - no resources with given url found 500 (internel server error)
- python-3.x - Moving up directory to access file not using raw path in Python
- python - Is it possible to chain multiple methods in Python on the dot (.) syntax?
- php - Appearance of user id when downloading to the file
- laravel - what that mean in laravel
- python - Can someone help me find a solution to error source in my code?
- graphics - How to get the color of a specific pixel drawn using SDL_RenderDrawPoint() on SDL2?
- python - Tensorflow preprocessing split string to chars
- python-3.x - loop over dict key-value-pair or each element in dict