VMware Images:
|
Using PHP5-FPM With Apache 2.4 (+ mod_proxy_fcgi Module) On Fedora 18 - Page 2
5 Configuring ApacheTo make Apache 2.4 work with PHP-FPM, we can use the ProxyPassMatch directive in each vhost that should use PHP-FPM (see http://wiki.apache.org/httpd/PHP-FPM). Possible configurations are, for example: ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/your/documentroot/$1 This matches (from the document root onward) all paths that contain .php, optionally followed by a / and any continued path. ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/path/to/your/documentroot/$1 This matches (from the document root onward) all paths that end in .php. In this example I want to configure the default vhost which has the document root /var/www/html. It is defined in /etc/httpd/conf/httpd.conf: vi /etc/httpd/conf/httpd.conf Add this somewhere near the end (before the IncludeOptional conf.d/*.conf line):
Make sure you use the correct document root (/var/www/html in this case) in the ProxyPassMatch directive. If mod_php is installed and enabled, we need to disable it. Open /etc/httpd/conf.d/php.conf... vi /etc/httpd/conf.d/php.conf ... and comment out the AddHandler and AddType lines:
Restart Apache afterwards: systemctl restart httpd.service 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.
6 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-odbc php-pear php-xml php-xmlrpc php-magickwand php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and Xcache. It is strongly recommended to have one of these installed to speed up your PHP page. APC can be installed as follows: yum install php-pecl-apc 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:
7 Links
|





Recent comments
1 day 1 hour ago
1 day 6 hours ago
1 day 8 hours ago
1 day 8 hours ago
1 day 10 hours ago
1 day 15 hours ago
1 day 15 hours ago
1 day 18 hours ago
2 days 7 hours ago
2 days 8 hours ago