VMware Images:
|
Using PHP5-FPM With Apache2 On Ubuntu 11.10
|
Submitted by falko (Contact Author) (Forums) on Thu, 2012-02-09 19:32. :: Ubuntu | Web Server | Apache | PHP
Using PHP5-FPM With Apache2 On Ubuntu 11.10Version 1.0 This tutorial shows how you can install an Apache2 webserver on an Ubuntu 11.10 server with PHP5 (through PHP-FPM) and MySQL support. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. I do not issue any guarantee that this will work for you!
1 Preliminary NoteIn this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate. I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root: sudo su
2 Installing MySQL 5First we install MySQL 5 like this: apt-get install mysql-server mysql-client You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on: New password for the MySQL "root" user: <-- yourrootsqlpassword
3 Installing Apache2Apache2 is available as an Ubuntu package. We need the apache2-mpm-worker package which we can install it like this: apt-get install apache2-mpm-worker Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder page (It works!): Apache's default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.
4 Installing PHP5We can make PHP5 work in Apache2 through PHP-FPM and Apache's mod_fastcgi module which we install as follows: apt-get install libapache2-mod-fastcgi php5-fpm php5 PHP-FPM is a daemon process (with the init script /etc/init.d/php5-fpm) that runs a FastCGI server on port 9000. Next we fix the PHP-FPM init script /etc/init.d/php5-fpm which sends a wrong signal to the daemon process when you try to reload it (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=645934). vi /etc/init.d/php5-fpm Go to the do_reload() function and replace --signal 1 with --signal 12 in the start-stop-daemon line:
Next enable the following Apache modules... a2enmod actions fastcgi alias ... and restart Apache: /etc/init.d/apache2 restart
5 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/php5-fpm.conf (this file does not exist, so you must create it), or you can place it in each vhost that should use PHP-FPM. I want to use PHP-FPM with the default vhost so I open its vhost configuration file /etc/apache2/sites-available/default... vi /etc/apache2/sites-available/default ... and put the following section somewhere between <VirtualHost></VirtualHost>:
Restart Apache afterwards: /etc/init.d/apache2 restart Now create the following PHP file in the document root /var/www: vi /var/www/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.
|





Recent comments
1 day 5 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 11 hours ago
1 day 12 hours ago
1 day 14 hours ago
1 day 15 hours ago
2 days 7 hours ago
2 days 8 hours ago
2 days 12 hours ago