Reputation: 223
I am a little lost in this moment. It is my first time with nodejs (I have more experience with Php/Apache). Recently a client gave me access to a bitbucket repository where he had the code of one application on nodejs. My final goal is to install that application on a Linux dev server.
Reading a little on the internet, I launch a Ubuntu 16.04 Instance on AWS. I installed Node.js and npm like this:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install python-software-properties python g++ make
sudo apt-get install nodejs-legacy
And if I run these commands, it returns my the versions:
node --version
v4.4.5
npm --version
2.15.5
So, my question is... now what? I have been searching on the internet by a couple hours, and all the tutorials about install node on ubuntu stop right here, but I didn´t find how to configure an app right from the start, and how to install the bitbucket project on my server, and how I made this site accessible by my browser.
On a Php/Apache server I must create the project directory con /var/www/, made a git clone on that directory and configure the site's virtualhost, and access by http://ip_address/, How I do that in this case?
I'm sorry, I know maybe these are very basic questions, but really, as I said, I feel lost.
Upvotes: 3
Views: 1113
Reputation: 817
In case you want to manually deploy the app to EC2 and run it yourself, here's what's left to do:
Change your current directory to where you'd like to store the app (I usually use /home/ec2-user
, but it doesn't really matter).
Clone the Git repo and cd
into it.
Install the app's dependencies by running npm install
. Note that the app might have additional dependencies you'll have to install manually.
This step depends on the application itself, but usually you can run a Node.js app by either running npm start
(if the start
script has been configured in package.json
), or by running node index.js
(you can replace index.js
with any other file, in case the main file isn't named index.js
).
Now you need to expose the ports the application listens to by modifying the instance's VPC settings. More info on how to do this can be found in the official AWS documentation.
Now you should be able to access your app by going to http://public_ip:port
, where public_ip
is the public IP address of your EC2 instance (which can be found in the management console (see more on this here), and port
is the port the app is running on.
Upvotes: 0
Reputation: 361
If you use express.js for the Webapplication, you first could use pm2
(https://www.npmjs.com/package/pm2) to create a "container" for your application. If you want to Host your application, I recommend using Nginx with a reverse proxy.
Here are some Links:
I hope that helps you. And if you want to install your application, just run npm install
in the directory where the package.json
is. Maybe you should update node.js because version 4.x is absolutely outdated.
Upvotes: 1