在apache服务器中部署vue
我在将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论