Ionic as a web server - ionic-framework

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 ?

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
Install connect and serve-static
$ cd [webapp]
$ npm install connect serve-static
Create server.js file
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080)
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 &".

Related

Install Minty npm packages for IPFS

So I am working on a M1 Mac and I want to use Minty, IPFS, & Pinata to mint some NFTs. I downloaded the IPFS binary, specifcially - https://dist.ipfs.io/go-ipfs/v0.13.1/go-ipfs_v0.13.1_darwin-arm64.tar.gz - and I was unable to have IPFS moved to the /usr/bin folder on my machine, I even tried enabling full disk access for the terminal in my settings and that did not work as I still receive a "cp: /usr/bin/ipfs: Operation not permitted" error. I was however able to move it into the /usr/local/bin directory and when I run "ipfs --version" it recognizes the command. So I cloned the Minty git repo - git clone https://github.com/yusefnapora/minty - ran the IPFS daemon, I think it starts running but I also see this in my output
IPFS is not installed.
Running IPFS and development blockchain
[ipfs] IPFS is not installed.
[ipfs] npx go-ipfs daemon exited with code 0
[eth] Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
As always any help is much appreciated.

Actions module not found when deploying through fab.dev?

I am deploying my next.js app through fab.dev to cloudflare workers and after generating the fab.zip file I'm unable to deploy it.
Here are some of the steps you can try ,
Reinstall fab actions module
npm install #fab/actions
Make sure you are running fab in bash env or any linux env
it doesnt really work well with windows powershell

Deploying Mean stack webapp on AWS

I have created a webapp based on the the Mean Stack( MongoDB, Express, AngularJS, NodeJS). I had followed this tutorial on setting up AWS: https://scotch.io/tutorials/deploying-a-mean-app-to-amazon-ec2-part-1
I got to the point where they started their server.js file by just calling node server.js. I do not have a server.js though. In webstorm I run grunt serve and it launches everything. On aws I run grunt serve and it just says cannot find bower components. I also try to run bower install and it fails saying I do not have permission but when I run sudo bower install it says bower cannot be run with sudo.
I am not sure how to solve this issue. Should I figure out how to use a server.js?
Any help wold be greatly appreciated
You can use npm start instead of node server.js, if you have initialized the app using npm init.

Phalcon: server not reachable through ip after installation

I tried to install Phalcon on CentOS 6.5. This is what I did:
Edit etc/yum.conf: remove the line ‘exclude=’ (temporarily)
Terminal:
Sudo yum update (to update everything on the system)
Yum install php-devel
Sudo yum install git
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
Add a file called phalcon.ini in /etc/php.d/ with this content:
extension=phalcon.so
Put back the original etc/yum.conf file
Reboot server.
Before I rebooted the server, "Apache is functioning normally" was displayed when I typed the IP address in my browser. Now when I got there, I get a browser message about being unable to establish a connection. When I type :2222 after the ip address, I can get access to directadmin.
What did I do wrong? (this is the second time I tried to reinstall it completely...)
Thank you very much
Phalcon should be loaded after all other PHP extensions are loaded. This has to do with the patches used by CentOS: they change the way the extensions are loaded into PHP.
I would remove extension=phalcon.so from php.ini and create /etc/php.d/zz-phalcon.ini with
extension=phalcon.so
and restart the web server.
EDIT: I explained this in details in the official forum.
You can't properly install Phalcon when using DirectAdmin.

Deploying meteor app to a webserver

Does anyone know a step by step guide to deploy the own meteor app from windows to a webspace (not xxx.meteor.com).
I've found some tools like meteor.sh, but I'm a beginner and it's difficult without a guidance and without linux (needed to execute sh-files for example)
Make your project locally
Build your project locally, you could test it using meteor run or even meteor deploy xxx.meteor.com to see if its working
Bundle your app
Use meteor bundle deploy.tar.gz to make a file called deploy.tar.gz in your meteor directory containing your project
Upload your file to your server
This depends more on how your server is/what your platform is but you can use a tool to upload it for you (e.g Transmit on mac)
Install node.js & fibers on your platform if you don't have it already
This depends alot on your server platform. Have a look at http://nodejs.org/ for more detailed instructions
Extract your bundle
If on a *nix platform you could do the below in the directory where you uploaded your bundle (explanation):
tar -xzvf bundle.tar.gz
Enter the directory and install fibers
Fibers is needed for any meteor project, it helps use synchronous style code on server side javascript:
cd bundle/programs/server/node_modules
rm -r fibers
npm install fibers#1.0.1
The first line enters the directory in your bundle where fibers is installed, the second removes it, and the third reinstalls it.
Get MongoDB on another server or use a third party service like mongohq
Meteor production deployments need another mongodb. You can either install it on another server or use a third party server. It's not recommended to install it on the same server you install meteor on.
Finally check if your project is runnable
cd ../../../
node MONGO_URL=mongodb://dbuser:dbpassword#dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js
The first line gets you back to the bundle directory and the second runs node.js on your project with the parameters that let you connect to your mongodb database.
Install something to let it run in the background
It depends on which one you want to use, foreverjs is quite easy to use
npm install forever -g
If you get an error problem try using sudo before the npm (which lets you run as a super user).
Then you can run forever:
forever start MONGO_URL=mongodb://dbuser:dbpassword#dbhost:dbport/meteor ROOT_URL=http://yourwebsite.com app.js
And its done!
Extra notes
While its not that easy to get started from scratch this should help you get started. You still need to secure your mongodb server up if you've used your own servers.
The meteor.sh script does pretty much the same as above but very quickly if you learn to use that instead it might be faster to deploy updates
You might not have wget or a couple of commands that you might need that come up and give you Unknown command errors. Have a go at running yum or apt-get and see which one of the two you might have. You can then install the required package using one of these installer tools, i.e with yum install wget
I hope this helps you, its not that easy to deploy to a server on the first shot as a couple of things might be missing (files/packages/dependencies), you might run into other problems with permissions & stuff, but you could always ask on serverfault or here on stackoverflow on what you run into.
I recommend Meteoric.
Note, that you need to run meteoric from your development machine.
Script is self explanatory and works perfect for me.