php7.4, php7.4-fpm, http2, Apache, nginx, I'm confused [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Can I use php7.4-fpm with Apache? Or is php-fpm really only for use with nginx? And why?
Does php7.4 support http2? Or do you still need php-fpm? The official http2 site (http2.pro) hasn't been updated in a couple of years.
Is it Still worth activating HTTP2? (The latest update dates back to a couple of years ago.)
To activate http2 I followed all the procedure described here: https://http2.pro/doc/Apache, now if I have to reactivate php (normal) how do I go back?
(The question was initially much more explanatory, but the administrators didn't like it ... they ask for it to be more focused, so let's try with only the questions.)

PHP-fpm is a version PHP that talks to the outside world with a protocol (a style of communication) called FastCGI. Apache can also talk via fastcgi to the servers it uses to answer requests - in both Nginx & Apache via the php-fpm: master process, that organises the pool of workers that actually run the PHP code. Since Nginx doesn't have mod_php, the only significant way to have it run PHP code is with php-fpm (there are some other methods, but they are not so often used)
HTTP2 is something for the webserver to deal with - Apache, or NginX. PHP doesn't need to worry about it, unless you want to send additional headers that the webserver would then deal with on its behalf (like also sending CSS or .JS files along with the initial connection - this is called HTTP-push, but it's not yet well widely established).
HTTP2 it totally worth it - you will, however, use this alongside the older http v1.0, or v1.1, but it is more efficient for browsers that support it.

Related

Apache + php-fpm vs Nginx + php-fpm [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have a wallpaper website (almost all traffic goes to images). I use the following apps to serve.
apache2 + php5.3 + CGI/FastCGI
I have recently read that Nginx is faster than Apache. Also, many people advise using php-fpm. Do you recommend me to move my website to
Nginx+php-fpm
or just make
apache2 + php-fpm?
There definitely is a difference in performance of Apache and NGINX.
Both have their strongsuits and their weaknesses but in general:
If PHP has to do a lot of work Apache will actually be faster because mod_php is a part of the Apache itself and is really good integrated.
The additional (f)cgi takes some time too when using Nginx and thus making it slower on PHP-heavy applications.
Conclusion
Do you only want to serve a lot of static data (like images) you are better of with NGINX, because if excells on static content.
--> In your case I'd go with NGINX...don't forget to make good use of NGINX' caching-mechanisms!

What should I do to execute php scripts on my own web server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to create own web server to accept HTTP requests and send response to client.
I have idea to call PHP scripts by CLI interface but then PHP scripts executed in CLI mode. What I need do for call scripts by my own server (not in CLI mode)? Because in CLI mode some PHP abilities is disabled. Maybe I need to write own PHP SAPI?
Please help me to start.
Thanks
No, you don't need to write your own PHP SAPI, as there has already been one written specifically for interfacing with a web server. It's called FastCGI.
It's important to note that PHP is both extensible and embedded by design. So, while some SAPIs like the Apache 2.0 Handler (a.k.a mod_php) might be embedded in the httpd server directly, it is not typically necessary to do so in order to have the web server talk to PHP.
The difference is you still need some process to manage the underlying PHP interpreter and deal with things like recycling workers or managing the number worker processes available for the webserver to talk to. For example, php-fpm does this quite nicely and many people use php-fpm to manage the PHP workers and just tie that to their webservers like nginx or httpd via the fastcgi protocol. The PHP workers forked by php-fpm listen on a fastcgi socket and the webserver can freely send and receive information from and to PHP.

Ruby web application working modes [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
When I write web app on PHP it can works in different modes: like FCGI (php-fpm), like apache module (mod_php) and so on. In all this cases when I am editing my PHP scripts application updates immediatelly without need to restart a server. I know that Ruby web app also can works in different modes (i.e. FCGI withing Unicorn + Nginx). But I want to get an idea about all the most common ways to launch Ruby web app and techincal details about all this means (i.e. when I should restart my server to update scripts), their proc and cons.
There are many ways to write Ruby applications, classic 1990s-style CGI, FastCGI, independent HTTP-capable processes with Mongrel or Thin and the more modern, recommended approach which uses a launcher like Passenger to manage the processes more directly.
Ruby on Rails can have several operating modes. The default two are development and production. These have some important differences:
In development:
Anything in app/ or config/routes.rb is reloaded for each request.
The log/development.log is as verbose as possible, recording each query executed.
Assets are served up in their raw form, can be changed any time.
In production:
Application is loaded once and cached, any changes require a restart.
The log/production.log file contains only errors and important notifications.
Assets are minified, compressed, and served up in bundles. Even minor changes require repackaging everything.
It's generally a bad idea to be editing scripts on a production server, so the Rails approach is usually a good thing. If you need to rapidly iterate on something, do it on your local copy and push the changes to the server only when you're confident they'll work.
If you really need to emergency fix something on the server, you can edit the code, then touch tmp/restart.txt to force a reload. When you change assets you'll have to run rake assets:precompile to repackage them.
Like a lot of things, Rails makes the recommended approach easy and the risky one hard.

PHP CLI with NodeJs [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a php application [mostly REST] which runs on top of Apache in a Linux Virtual Machine. This application does a lot of Data queries and i have started having performance issues.
To me one way to address this is using NodeJs Async Patterns. I also plan to implement websockets. But the problem is code size in php is very large. It will take months to rewrite in Node.
Is there a middle ground to complete rewrite. Where i can handle interaction with browser in Node and interaction with database in php cli. and Node can call php cli with approximating Apache environment?
I am using Slim PHP Framework for the REST API, Both HTTP Basic Auth and PHP Sessions, $_GET and variables for extra filters on GET requests. I dont know much about internal workings of Slim. But i think it depends on Apache-PHP implementation of HTTP requests and responses.
How to send the message body [post, put] to the php cli which is in 99% cases JSON (I have file uploads too but which can be ignored as of now). i can have php cli put the json output in STDOUT and parse from there.
The real problem is how to remove dependency on php apache SAPI without changing much of the codebase and how to integrate it with Node. is there any tools, lib which can help in this case.
One more side question, can NGinx help me here somehow?
**Note - My knowledge of node is limited to few fun scripts and custom linting, template compiling, testing scripts for browser side code.
First you could put nginx in front of Apache. This will allow you to slowly transition your actions to node by routing selectively to one or the other.
Alternatively you could put node in front and use node-http-proxy with express (for exemple) to proxy selectively to Apache. I haven't tried it myself but I guess it should work.
You could also/or use dnode to call php functions from node. zeromq is an option, too.

Can you run Ruby and Rails and PHP together on the same site? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Why? Because for our site I want to develop a Rails application, but I also want a separate part of it (perhaps the public directory) to be easy to modify by a PHP programmer/web designer.
Is it possible to run both on the same site? Are there any reasons why it is not a good idea or not a best practice?
I am pretty sure Nginx and Lighttpd can do it. For example, you can run php worker processes with php-fpm and configure the webserver to send any php jobs to them. Every other job could be configured for rails. I have never tried it myself.
You can use the vhost, port, or file extension (*.php) to determine where the webserver will send the request.
I think it would be an ok idea if lets say you have a PHP site but want to have a non-blocking application in nodeJS or use Tornado and have Nginx configured to proxy requests to them.
Example where Nginx is used for PHP-FPM and Node.js
http://blog.mixu.net/2011/01/04/nginx-php-fpm-and-node-js-install-on-centos-5-5/
In this example Node is ran on port 8000

Categories