Using PHP5-FPM With Apache2 On OpenSUSE 12.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/apache2/conf.d/mod_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/apache2/conf.d/mod_fastcgi.conf... vi /etc/apache2/conf.d/mod_fastcgi.conf ... and put the following section at the end (comment out everything else in that file):
The /usr/lib/cgi-bin/ directory must exist, so we create it as follows: mkdir /usr/lib/cgi-bin/ Restart Apache afterwards: systemctl restart apache2.service Now create the following PHP file in the document root /srv/www/htdocs of the default Apache vhost: vi /srv/www/htdocs/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 php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications: zypper install php5-mysql php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm Now reload PHP-FPM: systemctl reload php-fpm.service 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. phpMyAdmin can be installed as follows: zypper install phpMyAdmin To make sure that we can access phpMyAdmin from all websites created through ISPConfig later on by using /phpmyadmin (e.g. http://www.example.com/phpmyadmin) and /phpMyAdmin (e.g. http://www.example.com/phpMyAdmin), open /etc/apache2/conf.d/phpMyAdmin.conf... vi /etc/apache2/conf.d/phpMyAdmin.conf ... and add the following two aliases right at the beginning:
Restart Apache and reload PHP-FPM: systemctl restart apache2.service 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/php5/fpm/php-fpm.conf... vi /etc/php5/fpm/php-fpm.conf ... and make the listen line look as follows:
Also set the owner, group, and permissions of the socket as follows:
Then reload PHP-FPM: systemctl reload php-fpm.service 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/apache2/conf.d/mod_fastcgi.conf
Finally reload Apache: systemctl reload apache2.service
10 Links
|






Recent comments
11 hours 7 min ago
20 hours 35 min ago
21 hours 25 min ago
1 day 58 min ago
1 day 5 hours ago
1 day 5 hours ago
1 day 7 hours ago
1 day 17 hours ago
1 day 22 hours ago
2 days 20 min ago