Ionic as a web server

*爱你&永不变心* 提交于 2019-12-03 00:25:51

You gonna need send all your project files (www folder) and dependencies to an web server.

You can try.

Local

    $ cd [ionic project]
    $ ionic platform add browser
    $ cd [ionic project]/platforms/browser/

and move your www folder to your server [webapp] folder.

Server

In your server:

1.Install Node.js

  1. Install connect and serve-static

    $ cd [webapp] $ npm install connect serve-static

  2. Create server.js file

    var connect = require('connect');
    var serveStatic = require('serve-static');
    connect().use(serveStatic(__dirname)).listen(8080)
    
  3. Run serve

    $ node server.js &

Browser

Now you can go to http://yourdomain:8080/index.html

I hope this can help you :)

Great answer Carlos, it was very helpful. If you connect to your server by ssh, the node server will stop running when you quit the ssh session. To avoid this problem run "node forever start server.js" instead of "node server.js &".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!