fcgid, fastcgi with or without php-fpm? - apache

I'm installing Apache 2.4.7 with PHP5 and I use fcgid and suexec.
I read that some people use PHP-FPM with fastcgi, but I don't know if they are speaking about the old fastcgi or the new fcgid.
Anyway, I want to know if my configuration of fcgid without PHP-FPM is correct or I need to install and configure PHP-FPM to have all the functionality?
Which is the advantage and disadvantage of putting fcgid and PHP-FPM together, in the case that it is correct?

Related

How to enable http2 on CentOS7 with Apache 2.4.46

I have CentOS 7, with Apache 2.4.46. I have done pretty much every thing available on internet. I am getting the below error
The mpm module (prefork.c) is not supported by mod_http2. The mpm
determines how things are processed in your server. HTTP/2 has more
demands in this regard and the currently selected mpm will just not
do. This is an advisory warning. Your server will continue to work,
but the HTTP/2 protocol will be inactive.
My apache is running from /usr/local/apache2/.
I have seen, I may need to use php-fpm module to run this.
I have made changes on my live server and It is kinda stuck now. Though work impact is very less but I really want to learn what wrong am I doing
You would need to:
Disable mod_mpm_prefork
Disable mod_php (disable the php module, what ever it's named, example: libphp7)
Enable mod_mpm_event
Enable mod_http2
Enable mod_proxy
Enable mod_proxy_fcgi
Enable mod_setenvif
Install PHP-FPM using yum install php-fpm, or you might need to specify the version yum install php7-fpm or php8-fpm, and then start the PHP-FPM service after installation of that, using systemctl start php-fpm or php7-fpm/php8-fpm.
Add the following to Apache configuration:
<FilesMatch "*\.php">
SetHandler "proxy:fcgi://localhost:9000"
</FilesMatch>
If it is running as an UNIX socket, you would need to change it to:
<FilesMatch "*\.php">
SetHandler "proxy:unix:/path/to/php-fpm.sock|fcgi://localhost:9000"
</FilesMatch>
Restart Apache

how to remove "Server:Apache" from response header

We have Apache 2.4.34 on a Red Hat Linux Server and I need to remove Server: Apache from the response header.
Is there any easy way to do that without mod_security?
If we need to do it with mod_security only, I have checked the Apache 2.4 documentation and it appears Apache 2.4 wont come with mod_security by default.
Can any one tell me the detailed steps how to install mod_security on Red Hat Linux?
Does mod_security have to be separate from Apache?
How we can configure or make Apache 2.4 to use mod_security?
Do we just need to configure in httpd.conf the same as we load other modules?

How do I configure Dancer2 with mod_proxy_fastcgi

The Dancer2 Manual gives examples for mod_proxy and mod_fastcgi but in Ubuntu 18.04 the mod_fastcgi is removed.
So are there any examples out there using Dancer2 with mod_proxy_fcgi?
Edit: If I have to use mod_proxy instead, how do I startup my dancer2 application using, say starman or plackup

Why laravel homestead is not running Apache

Obviously, I've Laravel project that really needs the .htaccess rules and Nginx doesn't seem to be the best solution for me,
1- my question is why Laravel didn't provide homestead with Apache!
After a small research that I made I found online tool for converting the rules but the output didn't work (was too short), whereas, Apache is more likely known and usable, plus it's easier to define rules for security and pretty URLs ..etc. ( at least for me )
2- Please give me answers explaining why they choose Nginx!, more importantly I need to know what Seniors and Experts will use ( Nginx, Apache )
3- Do you advise me to install Apache on Homestead?
Laravel homestead is currently able to install apache using your Homestead.yaml file.
Add a key to your sites called type. Set it to apache. like so:
sites:
- map: laravel.local
to: "/home/vagrant/laravel"
type: apache
Make sure you don't mix up apache and nginx, that won't work.
Then run vagrant up and to install apache and provision the right config files.
If it doesn't work, then first make sure to update to the latest version of homestead.
Here is an interesting article on the matter: https://www.nginx.com/blog/nginx-vs-apache-our-view/. TLDR: Nginx is faster.
Only when you have an existing project and you really need to use apache. Or in case your application is going to run on an apache server. Starting fresh? Use nginx.
Steps are as follows here.
SSH into vagrant -> vagrant ssh
Stop Nginx -> sudo service nginx stop
Remove it -> sudo apt-get purge nginx
Update you repos -> sudo apt-get update
Install apache -> sudo apt-get install apache2
Restart it -> sudo service apache2 restart
You are now on Apache server, update the apache conf file as your needs.
What exactly are you trying to do and perhaps we can supply a solution to your problem. You shouldn't really need to be rewriting URLs with .htaccess as Laravel's routing handles this.
1) Regardless of software, if you're needing to configure the webserver for each specific project, its probably better to go and configure your own vagrant box that is relevant for that project.
2) Nginx outperforms apache and reduces a lot of the bloat that simply isn't needed. Its also what forge uses and so homestead uses in turn so its mocking the forge environment.
3) See point 1, configure your own vagrant box for this project.

HHVM through Apache mod_fastcgi on debian

I've been able to rather easily get facebooks hhvm working from prebuilt debian packages as well as compile it, and afterwards to run it behind apache as a proxy. The problem with the proxy setup is though, that I can't get response headers other than http status code 200 - like 304 for example - through. It's not the proxy config of apache, but something wrt hhvm and apache interact, or even in hhvm.
Anyway, HHVM officially stopped supporting the standalone server, and they're moving over to fastcgi, and as all of our servers are running Debian, I don't have access to mod_proxy_fastcgi without compiling it (the only backports I found of apache 2.4 don't have mod_proxy_fastcgi backported unfortunately).
So I'm currently trying to get HHVM to run behind the old mod_fastcgi with apache 2.2. But currently I'm only getting "connect() failed" in the error log of apache, while hhvm is listening on :::1080
The important part of my apache config is
RemoveHandler application/x-httpd-php
FastCgiExternalServer /home/www/hhvm/hostname/htdocs/php5.fcgi -flush -host ip6-localhost:1080
AddType application/x-hhtpd-fastphp5 .php
Action application/x-httpd-fastphp5 /php5.fcgi
Alias /php5.fcgi /home/www/hhvm/hostname/htdocs/php5.fcgi
netstat also lists hhvm as listening on :::1080 and I can connect to it via telnet
Any Ideas on what I need to change so it works?
Looks like a IP6 port problem. Try \[ip6-localhost\]:1080 . Not sure if this has side effects in Apache.
How do ports work with IPv6?