Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic as a web server

I have an Ionic project and I want it to work as if it is a web server (say mamp + php).

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.

How could I do that ?

like image 571
Moebius Avatar asked May 17 '15 12:05

Moebius


People also ask

Can I deploy an ionic app as a website?

edit: Ionic 1.2 officially supports deployment as a website! As I stated in the comment to the only provided answer - I disagree. If you're not using any Cordova plugins then there is no problem (if you really wish to) to upload the contents of the www folder to your server, and woila - you'll have the same app.

Why ionic?

Why Ionic? Embrace the power of the web. Progressive Web Apps use modern web capabilities to deliver fast, native-app experiences with no app stores or downloads, and all the goodness of the web. An escape hatch from the App Stores.

What is the ionic dynamic content web server plugin?

This plugin allows you to start a local dynamic content web server for android and iOS devices. Stuck on a Cordova issue? Don't waste precious time on plugin issues. If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Can You host an ionic app on Firebase?

Now your Ionic app is hosted on Firebase and uses a custom URL that you purchased wherever before. Great success! If you happen to have any kind of webserver up and running (or now how to start one) it’s actually super easy to deploy your Ionic app as a website as well.


1 Answers

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

like image 159
Carlos Rojas Avatar answered Oct 17 '22 15:10

Carlos Rojas