Is there anyway to use php-cgi with tomcat server? - php

I have a situation where a C/C++ application has a thread dedicated for nginx webserver and the thread and nginx server communicates via a specific port. This nginx server is configured to display the data (the data from the C/C++ application) on the webserver with the help of php-cgi. The port for php-cgi is different.
Is it possible to replace nginx server with tomcat server with minimal changes?
I came to know about php/java bridge while researching about it. I am not sure if that is the one I am looking for.
Please help.
Thanks
Edit: Any other cgi is okay as long as the data from the native C/C++ application is sent to webpages, but using tomcat server.

Related

docker-compose nginx and php-fpm need to share code folder?

Why every tutorial that I find on the web always share the code folder between the two machines?
If i'm setting two different machines, its the same that have two physical machines, let's say nginx server on california and php server in florida.
On my understanding, the fastcgi protocol is sending the data through the networks right?
Thats why we are using IP:PORT right?
So nginx ask the machine that understand php to process the data sending to that IP:PORT through fastcgi and getting the processed response to show to the browser right?
Or am I crazy?
Having made the same journey through these tutorials, here my view:
php-fpm is only the processor for php files, cannot serve static files. For php calls only, php-fpm would technically be enough but the php-fpm container cannot handle multiple requests even if the php-fpm itself is capable to do so
nginx plays the role of a webserver and load balancer, generally a socket (via volume) to communicate to php, and is also delivering static files
So, the shared code is necessary for the entrypoint to php files and having the static files to serve while php-fpm is using code for execution.
Suggestions to improve this answer welcome.
References here:
php-fpm and nginx on linode.com
nextcloud using the fpm image

Can i use Node js, Websocket and php in the same apache server?

I was wondering if its possible create a website combined with NodeJs, Websocket and php in the same Apache server. Is there any documentation that can i read?
"In the same Apache server", No. node.js does not run in Apache. It runs by itself.
But, you can use multiple technologies on the same server. For starters, you could have two completely separate web servers running on separate ports, one that was Apache + PHP + webSocket and another that was node.js + webSocket.
But, node.js does not use Apache. Instead, node.js would typically be configured to be it's own web server all by itself. So, you don't typically run an Apache server and have some requests through it go to PHP and some go to node.js.
Using PHP and node.js together depends entirely upon what you're trying to do with them. You could have your web server as a node.js server and then have some requests that node.js receives actually execute some PHP and get the results from running a PHP script. And, you could do the reverse too with a PHP script fielding the request and then manually running a node.js script for some requests.
To answer any more fully, we need to know what you're really trying to do with PHP, node.js and webSockets.
FYI, you could set up an NGINX proxy on port 80 and configure it to direct some requests to your Apache/PHP server (running on a different port) and other requests to your node.js server (running on a different port). Incoming webSocket requests would then be directed to one of the two servers.

Running a custom webserver in cloud9 environment and reaching it from the outside world

Is it possible to run serve my web application from another server than the one provided in cloud9?
For example : I would like to run different applications (PHP, Node.js - not sure what's possible yet) with nginx as the backend server (i) and/or a reverse proxy (ii) (to try different scenarios and configuration options).
Is it possible to run nginx and serve content to the outside world in cloud9?
Is it possible to have nginx as a reverse proxy in cloud9?
EDIT:
Here they write:
$PORT is exposed to the outside: When you run an application which listens on the port specified in the environment variable $PORT, you can access this application using the http://projectname.username.c9.io URL scheme. The proxy expects the server on that port to be a HTTP server. Other protocols are not supported.
This leads me to believe that if I would start nginx on port=$PORT it would be accesible via the specified URL sheme - can anyone confirm? Maybe anyone has tried this and can share some time-saving tips. Thanks.
I know this might be a late reply but might be helpful for those who are wondering how to do the same.
Short answer
I've created a repository to hold all the configuration needed on the process. Just run a command and NGINX and PHP-FPM will be serving and accessible from internet.
GitHub repo: https://github.com/GabrielGil/c9-lemp
Explanation
Basically to run NGINX on a c9 environment as you noted, you just have to make it listen on port 8080. YOu can either edit the default site on /etc/nginx/sites-available or create and enable your own (That's what the script above does)
Then, in order to run PHP-FPM script using NGINX, configure some permissions and the socket on the webserver is needed. By default, c9 uses ubuntu:ubuntu and the webserver www-data:www-data.
The script above also does this changes for you.
Hope this help you, or other users on similar situations.
You can run nginx on a normal Cloud9 workspace, as long as it listens to port 8080 (the value of $PORT). The URL scheme to reach your server would be http://projectname-username.c9.io, however. Please refer to the docs.c9.io for more up-to-date help on running applications.
One other thing you can do if you have another server where you would like to host your software, is to create an ssh workspace (https://docs.c9.io/ssh_workspaces.html). That way, you can connect Cloud9 to an external server directly.

Running Apache Dev/Test server locally

Is there any way that I can set up Apache to run locally, specifically NOT connecting to the internet, so that it may serve dynamic content (PHP) over a LAN?
I'm trying to set up a development environment on my Windows XP SP3 box and gain some experience with building web PHP driven web applications. I have residential Rogers service, and it's a violation of the TOS to have a server running over that connection.
Umm yes. Just download apache and fire it up. The only way it's going to get to the outside is if you specifically open up ports in your firewall/router to let http traffic in and route it to your machine. And if you're serious about getting some experience, ditch XP and get a quality linux distro on your "development" box. You can always remote desktop or ssh to it from a windows machine if you feel more comfortable that way.
My experience has been that many hosting companies use CentOs for their client servers, so I'd recommend trying that first if the purpose is gaining useful experience.
Oh by the way, Linux happens to be free.
You can use WAMP. It installs everything you'll need to get a testing server up and running in minutes
Using a packaged solution like WAMP or XAMPP will provide you with the basics for setting up an Apache web server + PHP + MySQL + the phpMyAdmin interface for working with MySQL outside of the command line.

running php with Nginx server

I am using apache server for php. So my doubt is can I use both Nginx and apache server for running on my system . Can be both server load on the systm? Thanks in advance
Although I don't see much benefit, but as long as they are listening to different ports, I don't see why not.
Here's a tutorial on how to setup php in nginx (just in case)
http://wiki.nginx.org/Configuration#PHP_via_FastCGI
If it were me, for evaluation purposes, I would just fire up one of my Virtual Machines and run nginx in the test environment of your choice.
http://www.virtualbox.org/

Categories