在apache服务器中部署vue

发布于 2025-01-10 08:37:54 字数 1319 浏览 1 评论 0原文

我在将 vue 应用程序部署到 apache2 时遇到问题。我在这个服务器中有后端(backand是用.Net编写的)。我的后端应用程序名为 my-finecard.online。对于这个后端,我做了 api.conf 并且 api conf 看起来像:

<VirtualHost *:*>
  RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost my-finecard.online:80>
  ProxyPreserveHost On
  ProxyPass / http://127.0.0.1:5000/
  ProxyPassReverse / http://127.0.0.1:5000/
  ServerName my-finecard.online
  ServerAlias my-finecard.online
  
  ErrorLog ${APACHE_LOG_DIR}api-error.log
  CustomLog ${APACHE_LOG_DIR}api-access.log common
</VirtualHost>

另外对于我的前端,我更改了我的 /etc/apache2/apache2.conf 并将字符串添加到这个conf中:

<Directory /var/www/html>
  Options Indexes FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>

因此我做了 .htaccess 文件并添加到字符串的文件中:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

我有这样的 dist 文件夹,它在 npm run build 之后生成:

总之,当我启动服务器时,然后转到 url: https://my-finecard.online/ 我有 404 错误。我该如何纠正这个问题?

I have trouble with deploying vue app to apache2. I have backend in this server(backand has written in .Net). And my backend app named my-finecard.online. For this backend I did api.conf and the api conf looked like:

<VirtualHost *:*>
  RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost my-finecard.online:80>
  ProxyPreserveHost On
  ProxyPass / http://127.0.0.1:5000/
  ProxyPassReverse / http://127.0.0.1:5000/
  ServerName my-finecard.online
  ServerAlias my-finecard.online
  
  ErrorLog ${APACHE_LOG_DIR}api-error.log
  CustomLog ${APACHE_LOG_DIR}api-access.log common
</VirtualHost>

Also for my frontend I change my /etc/apache2/apache2.conf and added to this conf that strings:

<Directory /var/www/html>
  Options Indexes FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>

Therefore I did .htaccess file and added to the file that strings:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

I have dist folder like this which genered after npm run build:

In conclusion, when i start my server, and go to url: https://my-finecard.online/
I have the 404 error. How I could correct the problem?

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

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

发布评论

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