且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ionic作为Web服务器

更新时间:2023-11-27 19:37:28

你需要发送你所有的项目文件(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

  1. 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 :)