Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Apache2.4 PHP-FPM configuring pools ? |
|
Author |
|
Duddy67
Joined: 14 Sep 2016 Posts: 1
|
Posted: Wed 14 Sep '16 10:03 Post subject: Apache2.4 PHP-FPM configuring pools ? |
|
|
Hi all,
I'm trying to set pools in order to run PHP scripts as different users, but it doesn't work. Here's step by step what I did (on Ubuntu 16.04):
Code: | sudo apt-get install apache2 libapache2-mod-fastcgi php7.0-fpm php7.0
a2enmod actions fastcgi alias
sudo service apache2 restart
vi /etc/apache2/sites-available/000-default.conf
|
Code: | ServerAdmin webmaster@localhost
DocumentRoot /var/www
<IfModule mod_fastcgi.c>
AddHandler php7-fcgi .php
Action php7-fcgi /php7-fcgi virtual
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule> |
Then I created a user called "web"
and set up his home directory in /var/www/web
Create and configure the pool file for the new user:
Code: | sudo cp /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.0/fpm/pool.d/web.conf |
Code: | [web]
...
user = web
group = web
...
listen = /run/php/php7.0-fpm.web.sock
...
listen.owner = web
listen.group = web |
Code: | sudo service php7.0-fpm reload
vi /etc/apache2/sites-available/web.conf |
Code: | ServerAdmin webmaster@localhost
DocumentRoot /var/www/web
<IfModule mod_fastcgi.c>
AddHandler php7-fcgi-web .php
Action php7-fcgi-web /php7-fcgi-web virtual
Alias /php7-fcgi-web /usr/lib/cgi-bin/php7-fcgi-web
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi-web -socket /var/run/php/php7.0-fpm.web.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule> |
Code: | sudo a2ensite web.conf
sudo service apache2 reload |
Now to ensure php scripts run as the proper user I put the following script in /var/www and var/www/web
Code: | <?php
$processUser = posix_getpwuid( posix_geteuid() );
var_dump($processUser);
?> |
when I run /var/www/user.php it displays "www-data" which is correct. But when I run /var/www/web/user.php it still displays "www-data" whereas it should display "web"
So what's wrong with my Apache config ?
Thanks for advance. |
|
Back to top |
|
|
|
|
|
|