2

Currently I am using Apache in a server with WHM/Cpanel and I'm currently using Prefork MPM with Mod Ruid2 to process PHP pages. While the setup allows it to run very fast, I'm limited to processing about 80 HTTP requests simultaneously since the machine has 8 GB ram.

I think google isn't happy enough with that. I feel to make my websites and the server keep up with the times, I need to increase the maximum number of requests that can be served at once.

So I thought of using FastCGI with PHP-FPM. I then began playing with my httpd.conf (on my own private test server of course) to see how to configure it for multiple users. Each user has its own domain on the server.

For now I am showing my configuration for one user. His website is 127.0.0.1:81. /daemon is a folder accessible by user daemon.

This is my php fpm config file that I apply when I execute php-fpm daemon.

[global]
pid = /daemon/x.pid
daemonize = yes
[www]
user = daemon
group = daemon
listen = /daemon/x.sock
listen.owner=daemon
listen.group=daemon
listen.backlog = 65534
pm = static
pm.max_children = 10
pm.max_requests = 10000
pm.status_path = /STAT
request_terminate_timeout = 100s
clear_env = no
security.limit_extensions=.php

This is the snippet in my httpd.conf file

<virtualhost 127.0.0.1:81>
AddHandler php51 .php 
Action php51 /php51
Alias /php51 /daemon/1
FastCgiExternalServer /daemon/1 -socket /daemon/x.sock -pass-header Authorization -idle-timeout 120 -flush
<Directory "/daemon">
Order allow,deny
Allow from all
</Directory>
ServerName 127.0.0.1
</virtualhost>

What I want to do is try to compress these lines so that when I go do a multi-user setup, the amount of typing I have to do will be less.

Because I felt theres some redundancy, I replaced:

Alias /php51 /daemon/1
FastCgiExternalServer /daemon/1 -socket /daemon/x.sock -pass-header Authorization -idle-timeout 120 -flush

with:

# Alias /php51 /daemon/1
FastCgiExternalServer /php51 -socket /daemon/x.sock -pass-header Authorization -idle-timeout 120 -flush

and restarted apache and attempted to access a php file and I'm told the file was not found, yet I never modified the file itself and I used the same URL in both tests.

Also, in the apache log, I received:

File does not exist: /usr/local/apache2/htdocs/php51

When I removed:

<Directory "/daemon">
Order allow,deny
Allow from all
</Directory>

I received "permission denied".

I never had to add all this configuration when using prefork with ruid2.

Is there a more minimal configuration I can use other than having to define an action, alias on top of defining an external server? I want to increase the number of connections apache can handle without eating all the memory or even eating the CPU and I want to be able to use PHP as well.

1

There's rather a lot of questions in that post.

when I go do a multi-user setup, the amount of typing I have to do will be less.

That's not the way to solve the problem. You already have lots of other things you should be doing onboarding a new user. WHM/Cpanel is a very basic tool designed for people running basic websites who don't have the expertise or time to configure a webserver. If you are concerned about the amount of time it will take you to copy, edit and paste a small block of config like this, then you should be thinking about how you solve all the steps in setting up a new account/service; you should be scripting them.

It's quite possible to setup a script on Linux or Unix (also on MSWindows, but its a lot more work), configure a skeleton website, tell Apache and PHP-FPM about it, add DNS and mail records, configure a MySQL database and users and more all from a simple shell script. And the amount of content which needs to be modified is then irrelevant.

I think google isn't happy enough with that

As long as you have the capacity to handle the requests, Google doesn't bother much about performance (yes it has an impact on ranking, but its very small). OTOH users care a lot more.

PHP-FPM is a reasonable way to address your capacity and performance woes without having to a radical redsign of your server architecture.

I want to increase the number of connections apache can handle without eating all the memory or even eating the CPU and I want to be able to use PHP as well.

That's not something which can sensibly be answered here - its way too broad. Although its mostly about performance rather than capacity, this book will give you a better understanding of how to make better use of the infrastructure you have. There's also some more guidance on capacity in the accompanying website.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.