dummy_prototype_1
是一个简单的Vue JS应用程序,在我的本地机器上运行良好。现在,我将我的应用程序上传到AWS EC2。我想在永久的网址http://3.137.154.536:8000/
上运行这个。但是,下面的代码在本地主机http://localhost:8080/
上运行服务器。如何在我的永久URL上运行这个?我是不是遗漏了什么?如果需要进一步的资料,请告诉我。我是AWS新手,请帮帮我。
ubuntu@ip-172-31-43-235:~$ ls
Codes
ubuntu@ip-172-31-43-235:~$ cd Codes
ubuntu@ip-172-31-43-235:~/Codes$ ls
dummy_backend_1 dummy_prototype_1 nodeserver_1
ubuntu@ip-172-31-43-235:~/Codes$ cd dummy_prototype_1/
ubuntu@ip-172-31-43-235:~/Codes/dummy_prototype_1$ npm run dev
> proto@1.0.0 dev /home/ubuntu/Codes/dummy_prototype_1
> cross-env NODE_ENV=development webpack-dev-server --open --hot
Project is running at http://localhost:8080/
webpack output is served from /dist/
404s will fallback to /index.html
Unable to open browser. If you are running in a headless environment, please do not use the open flag.
{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
以下是package.json:
{
"name": "proto",
"description": "Prototype",
"version": "1.0.0",
"author": "Jason",
"license": "MIT",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"@melmacaluso/vue-modal": "^2.1.0",
"firebase": "^7.14.2",
"fusioncharts": "^3.15.1-sr.1",
"vue": "^2.5.11",
"vue-fusioncharts": "^3.0.4",
"vue-router": "^3.1.6",
"vuex": "^3.3.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
}
}
发布于 2020-09-07 13:33:06
如果计划在EC2实例上承载SPA,则需要Apache这样的HTTP服务器。
dist/
文件夹。dist/
的内容上载到EC2实例上的/var/www/html
。编辑为apache添加历史模式支持配置。
对于历史模式,您需要像这样配置服务器:
<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到EC2实例
从项目根目录中运行以下命令。
scp -i /path/to/ec2key.pem -r dist/ ubuntu@ip-172-31-43-235:/var/www/html
编辑重新启动Apache2服务器
sudo service apache2 restart
https://stackoverflow.com/questions/63784375
复制相似问题