Using PHP5-FPM With Apache2 On CentOS 6.2 - Page 2
6 Configuring ApacheTo make Apache work with PHP-FPM, we need the following configuration:
(To learn more about the FastCgiExternalServer directive, take a look at http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer.) You can put it in the global Apache configuration (so it's enabled for all vhosts), for example in /etc/httpd/conf.d/fastcgi.conf, or you can place it in each vhost that should use PHP-FPM. I want to use PHP-FPM with all vhosts so I open /etc/httpd/conf.d/fastcgi.conf... vi /etc/httpd/conf.d/fastcgi.conf ... and put the following section at the end:
The /usr/lib/cgi-bin/ directory must exist, so we create it as follows: mkdir /usr/lib/cgi-bin/ Restart Apache afterwards: /etc/init.d/httpd restart Now create the following PHP file in the document root /var/www/html of the default Apache vhost: vi /var/www/html/info.php
Now we call that file in a browser (e.g. http://192.168.0.100/info.php): As you see, PHP5 is working, and it's working through FPM/FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.
7 Getting MySQL Support In PHP5To get MySQL support in PHP, we can install the php-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this: yum search php Pick the ones you need and install them like this: yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc Now reload PHP-FPM: /etc/init.d/php-fpm reload Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:
8 phpMyAdminphpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it: yum install phpmyadmin Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory "/usr/share/phpmyadmin"> stanza): vi /etc/httpd/conf.d/phpmyadmin.conf
Next we change the authentication in phpMyAdmin from cookie to http: vi /usr/share/phpmyadmin/config.inc.php
Restart Apache: /etc/init.d/httpd restart Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:
9 Making PHP-FPM Use A Unix SocketBy default PHP-FPM is listening on port 9000 on 127.0.0.1. It is also possible to make PHP-FPM use a Unix socket which avoids the TCP overhead. To do this, open /etc/php-fpm.d/www.conf... vi /etc/php-fpm.d/www.conf ... and make the listen line look as follows:
Then reload PHP-FPM: /etc/init.d/php-fpm reload Next go through your Apache configuration and all your vhosts and change the lineFastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization to FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization, e.g. like this: vi /etc/httpd/conf.d/fastcgi.conf
Finally reload Apache: /etc/init.d/httpd reload
10 Links
|






Recent comments
15 hours 18 min ago
18 hours 14 min ago
19 hours 28 min ago
20 hours 51 min ago
22 hours 29 min ago
23 hours 58 min ago
1 day 1 hour ago
1 day 17 hours ago
1 day 17 hours ago
1 day 21 hours ago