How to install node.js and run js files using it? - php

I have made a website that has some notification action done by socket.io which is written in server.js file. The server.js file is run on cmd using node.js. It working perfectly fine on my localhost(xampp server). Now I want to implement it on the live server which is linux. How do I proceed it. The server has been installed with node.js. How should i run the server.js file on it which should be ran all the time in the server?

Related

How to use Supervisor to run Websocket server on AWS Lightsail instance

I'm using this library to add websockets to my codeigniter app. I got everything to work, but I need the websocket server to always run in the background, regardless of the CLI being open or not.
To run the server in the CLI, I run this command:
php index.php welcome index
Which gives me:
Running server on host 0.0.0.0:8282
Authentication activated
Websockets works on my app, but if I close the CLI, the server closes as well. How do I keep this running? I have Supervisor (as suggested for Ratchet), but I have no idea where to go from here. I'm just running a simple PHP server (Ubuntu on AWS Lightsail), not a node one, bytheway.

Rsync from server to server without downloading locally

I am writing a script in shell for a Wordpress website, which takes the plugins, themes and uploads and puts them on a backup-website where I usually test and break stuff.
To make it easier for me to always have the latest version on the development website, I am running this script so that I don't have to manually import export everything, everytime.
At the moment I am running:
rsync -avzhe ssh -t ${HOST_REMOTE}:${PATH_REMOTE}/plugins/ ./plugins/
rsync -avzhe ssh ./plugins/ ${HOST_TARGET}:${PATH_TARGET}/plugins/
I am wondering if there is any way I could re-write this so that it could download the files from the remote directly to the target, without having to download them locally anymore.
Thank you very much for any input relevant to the subject.

Apache2 and CakePHP project server deployment

Hi my CakePHP project works fine. I have pushed it to my server #www.zeyeland.com/register. So the cake app works great but I am not sure how to get my Apache2 server to run the app automatically. I have to log into my server and type bin/cake server to start it.
Some time ago, When I uploaded my NodeJS app to server I had to edit the .bashrc file and use the bash script command "cd/var/www/html/zeyeland-website/bin && pm2 start npm1 -- start and cd". This command starts my nodejs app automatically
Do I need a similar bash command with bin/cake server to run my Cakephp project automatically too?
You need to look for upstarting apache and mysql so that whenever your server reboots the services will start automatically.
Look for upstart at
https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples

PHP files downloading

I have an AWS EC2 instance running the Bitnami Tomcat stack. When I try to run php from the server, they download. When I try to run it from my computer to test it, the code shows in the browser. In both scenarios, what could the problem be?

How to run an php application without installing xampp on client system?

In my application i have to deploy my application on client system.
So is there any way to run my php application without installing xampp...
Because the client should access it as a readymade app without installing anything...
This is the description of my project...
We have to develop an application where the client will have our application he will connect to remote server
Then he will download the data from remote server...
Then he uses that downloaded data using that app
Here my requirement is the user may not have the knowledge of installing the xampp...
So is there any way to run the application in user system just by copying some files
U may suggest me a one click solution (like using installer which will include installation of xampp and copying my data into user system)
I really dont want to use any external software to render no database PHP pages so I did some digging and found that if you run php -S localhost:port in your working directory you basically start a server there.
S is a capital S and not s
I'm a big fan of server2go. I've used it to deploy PHP applications on CD/DVD. It comes with MySQL and is relatively easy to configure. I've even replaced their splash screen with my own so no one knows I'm using it. It's donationware, but I was impressed enough to donate:
server2go-web
With this application, you don't have to install all that other stuff. It's self-contained in this executable and directory.
EDIT: To clarify, server2go does not install anything on the client machine. It runs as an exe only when you specifically want it to. When you click on the .exe file, it launches your PHP application in a browser window, then you can right-click on the server2go icon in the system tray and close it when you're done.
EDIT2: One gotcha: if you want to save data to the MySQL db on the client machine, you'll need to copy serve2go to a directory on the client machine or run it on a writable USB stick. If you run this application off CD/DVD, it will be able to read data from the database, but not write.
The better way is to use PHP Desktop Application. It will allow you to run your PHP Script like a Desktop application and you don't need to install Xampp or any other web server to run.
PHP Desktop Application
After downloading the .Zip file unzips it to any folder that you like. After unzipping, Go to the folder, and there you can see a folder "www". Delete all the files contained in it and move all your php script to it.
Once you moved all your files into it. Run the .Exe file named "PHP desktop-chrome"
It will open your PHP Script really like a Desktop Application.
This script doesn't require any kind of server software like Xampp, Wamp, Etc installed in your PC.
You can either host the php application or install the application into one system as server and call in client system using the ip of the server system like the following
http://**ip address/php file name
If you don't want your client to install anything then you should create Client Server architecture, there is no another way.
PHP Application are not meant to be deployed on multiple clients. It's meant to be deployed on a webserver (your own server with sth. like IIS or XAMPP) so the clients can access it via their browser and doesn't have to install anything more.
If you want to deploy applications on the client pc's i recommened an other programming language like Java or C/C++.
I simply used xampp zip version so i copied my application into htdocs and the whole xampp is given to the customer so he simply running the application eazily without installation.
Make sure you have installed php from https://www.php.net/downloads.php. Once installed add it to path. Lastly type php -S localhost:8000
PHP needs to be installed on the machine it is running at in order to make sure it works. Since the app may grow and may require extension installing, PHP upgrading over time, hosting this on a client machine is not a very easy task in terms of management. You may want to host your project on a server and write a small bash script sending requests to the API.
If, for some reason you cannot host this on a server where your clients would send requests via the bash scripts, then you may want to install only PHP. If it does not need to listen to HTTP requests, then you do not need a server, you can just implement the PHP application and create a bash script so the user will be able to run it from the UI of their operating system.
No, you need some kind of server - Wamp, Xampp, etc.
You can host it online, and then he can just browse it from his PC.

Categories