Ionic作为Web服务器 [英] Ionic as a web server
问题描述
我有一个Ionic项目,我希望它能像Web服务器一样工作(比如mamp + php)。
I have an Ionic project and I want it to work as if it is a web server (say mamp + php).
由于ionic能够显示一个在浏览器localy项目(使用离子服务),我很确定它能够做到这一点。我有一个简单的 ovh服务器。
Since ionic is able to display a project in browser localy (using ionic serve), I am pretty sure it is able to do that. I have a simple ovh server.
我怎么能这样做?
推荐答案
你需要发送你所有的项目文件(www文件夹)和Web服务器的依赖项。
You gonna need send all your project files (www folder) and dependencies to an web server.
你可以试试。
$ cd [ionic project]
$ ionic platform add browser
$ cd [ionic project]/platforms/browser/
并将您的www文件夹移动到您的服务器[webapp]文件夹。
and move your www folder to your server [webapp] folder.
在您的服务器中:
1.安装Node.js
1.Install Node.js
安装connect和serve-static
Install connect and serve-static
$ cd [webapp]
$ npm install connect serve-static
$ cd [webapp] $ npm install connect serve-static
创建server.js文件
Create server.js file
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080)
运行服务
Run serve
$ node server.js&
$ node server.js &
浏览器
现在您可以访问 http:// yourdomain:8080 / index.html
我希望这可以帮到你:)
I hope this can help you :)
这篇关于Ionic作为Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!