Strapi deployment - javascript

I am new to Strapi and I found it really good, I got my website in development mode locally working perfectly fine but I can not get my head around or find any good guide how to host Strapi on Debian Linux server, that I have, to be part of website and to access Strapi control panel for example mywebiste.com/admin so I can add content as blog posts directly by logging in to website admin part. Is that possible or I must use some services like Heroku. if someone can provide in short step by step what to do I will really appreciate that. I tried already create new Strapi project inside public_html folder but its not working

I use strapi on my project . I hosted strapi on pm2 package. Its very easy.
this documention https://docs.strapi.io/developer-docs/latest/guides/process-manager.html#install-pm2
don't forget add startup Ubuntu to pm2. Otherwise when Ubuntu started then not starting pm2
I suggest use Ubuntu.
Nginx Configuration

In order to deploy it to a Linux server, you need to install nginx, and set it up. You can find instructions in official documentation: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/optional-software/nginx-proxy.html#nginx-virtual-host

Related

Running strapi project on hosting service provider

I don't understand how to run my Strapi project once it's online on the server. I have a website vpftravel.com and I want to fetch data from the Strapi collections (api) I created but the only way that Strapi runs is when I use the "start" command. I've read many times their deployment documentation but no luck. I also don't understand how I can access the Strapi dashboard once I've uploaded it to the hosting service's server.
Background on my project, it's just a regular JS, PHP and HTML site hosted on Aruba (hosting service). I've been using DatoCMS but I've surpassed the 10GB bandiwdth on their free tier hence why I'm looking into a locally hosted database.
Maybe Strapi is not the right tool for what I wanna do.
I'd appreciate any help.
This photo shows my personal project directory and I highlighted where the Strapi project is located inside the directory.
Strapi is not a "flat file" type of web app, it's adminUI is but the backend needs to run as a service. This is something you would use PM2 for (and I would not recommend using IIS)

How to solve "Access-Control-Allow-Origin"-Issue in vue.js?

Im new to vue.js and webpack. I currently have a very big trouble to archive the next step: communicate with real-world-apis in a dev env.
what i currently do is:
npm run dev
my application calls an remote api to which i have no access.
then i run into the Access-Control-Allow-Origin-Issue.
If i build my application and run it with xampp everything works fine.
What can i do, to simply develope my application instead to hassle with that security thing?
I have tried to create a proxy, so i have already looked at:
npm cors (node-cors-client and node-cors-server) - but how does that apply to my vue app?
socket.io - but it seems to be overkill
http-server - but i got the same issues here
nuxt - could work, but then i need to refactor my vue.js app to nuxt and i dont know if this works then
any suggestions? Thanks!
Solved:
I ended up with a PHP-API
The PHP-API runs with xampp under port 80
The Vue.js-App runs with npm dev server under port 8080
The CORS-Hassle must solved then in the PHP-Script with:
https://stackoverflow.com/a/9866124/3918455

Angular 4 SEO Friendly solution in prod

I'm trying to create a website in Angular 4. It is a base of my personal study.
My website is up and running but I'm trying to improve it. I checked and apparently my website is not SEO Friendly. I make some changes and I discovered this sample https://oliverveits.wordpress.com/2017/07/05/server-side-rendering-in-angular-4-with-universal/ That show an Angular 4 app with Page Source code.
I make the changes, I started to use Webpack and other features sugared by in the link. When I run the command "npm run start" and I access http://localhost:8000 I can see the Page Source. But when I copy the dist to my server on Godaddy domain I can't.
I'm not sure about what I have to do. If I need put my website in a node.js server or if I'm not compiling it correctly to have what I'm expecting.
I'm open to different approachs.
Well, I found the what causes this issue.
I think many of new Angular devs possible have the same problem.
When you run "npm start" or "ng s" what are you doing is put the node to listen a specific port. In other words, you are running a node server.
In another approach, copy the files to an IIS server or Apache Server. This doesn't make the Node Server run. In this scenario, the pages are download to the client browser and run as HTML/javascript page. And because of this when I try to see the Page source I saw the Angular files.
Took me a while to understand it. My background is .Net development.
Now a day my website is running in one of the many node.js servers. evennode.com, on this server instead of to have an IIS or Apache, they set up a Node Server to listing a specific port and then you are able to run all your development on the server side.
I found easier use a node js server like evennode them set tup node js run on my Goddady account.

How to serve a REST API on Heroku

I've built a REST API that works well if I host it locally. I followed this tutorial:
http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/
How can I serve this on heroku or any other online platform so my app can execute CURL commands?
Here is the code I used:
https://github.com/taboada92/wham
Thanks
You need to add a Procfile to your project so heroku will know what to execute. If are new to Heroku + Node, I suggest going through the tutorial

Installing/setting up Socket.IO on my server

Ok so I have read through the Socket.IO docs and I am still a little unsure of a couple of points:
The documentation says...
To run the demo, execute the following:
git clone git://github.com/LearnBoost/Socket.IO-node.git socket.io
cd socket.io/example/
sudo node server.js
Now I don't know what this means at all! I think it may be command line interface. I of course have access to this on my localhost, but my online hosting package is a shared LAMP setup. Meaning I don't have access to the root command line (i think).
How do I actually setup socket.IO, is it impossible on my shared server package?
Appreciate any help...
W.
If you aren't familiar with node.js or with basic command line usage then I would suggest that you use a hosted WebSockets solution like pusherapp. Trying to learn WebSockets, and Node.js, and the Linux command line all at once is going to lead to a lot of frustration. Take a look a pusherapp's quick start guide, it's very easy to get started. You can have 5 simultaneous connections with a single application for free (I'm not affiliated with pusherapp).
Updated (with inline answers to questions):
If you are going to go the direction of running a Socket.IO application:
You don't technically need git since you can download node.js and Socket.IO from their respective download links on github.
You don't actually need a LAMP server to use Socket.IO. By default Socket.IO functions as a simple webserver in addition to a WebSockets server. If you want server side scripting then you might want Apache with mod_php, mod_python, etc.
You don't technically need a dedicated server or even root access. You do need a system where you can have long running process. And if you want the service to start automatically when the system is rebooted, you probably want to add a startup file to /etc/init.d, /etc/rc.d which will require root access. Both node.js and Socket.IO can be installed and run from a normal home directory. If you want to run Socket.IO on a standard port like 80 or 443 then you will need to run it with root privilege.
Node.JS scales quite well so Socket.IO will probably scale pretty well too.
It's not a simple matter to get everything setup and working, but if your goal is a free solution for web serving+WebSockets then Socket.IO is probably is good route to at least explore if you are brave.
First you'll have to determine if your host supports SSH. Sometimes they don't by default on shared hosting, but if you ask they can turn it on. If it does you'll use some sort of SSH client to connect to it. Putty for windows is the most common. Then you'll use git, which is a source control program. Which you'll probably have to install on your host, which may or may not be allowed. If you can, this can be accomplished a number of ways, you'll want to read the git documentation, it will depend largely on what linux distribution you're running. CD is change directory, basic command line stuff. sudo on the last line is telling the system to run the command as root, which it will ask you the password for, which you may not have access to on your host. Sounds like you're gonna have an uphill battle on shared hosting. You may want to opt for a VPS instead.
If your shared host is a LAMP system with no command line access you're not going to get very far with Socket.IO. The instructions you posted assume you have command line access and that you've installed the node.js runtime on your system.
If you really want to try this I recommend you get a VPS of your own (I use prgmr.com) to test it out. For what it's worth I found the Socket.IO platform pretty nice to use once I got it up and running.

Categories