VMware Images:
|
Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Fedora 14 - Page 2
4 Installing PHP5We can make PHP5 work in nginx through PHP-FPM (PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites). There's no php-fpm package in the official Fedora 14 repositories, but fortunately the Remi repository provides such a package. To enable the Remi repository, run: rpm -ivh http://rpms.famillecollet.com/remi-release-14.rpm Next open /etc/yum.repos.d/remi.repo... vi /etc/yum.repos.d/remi.repo ... and change enabled to 1 and gpgcheck to 0 in the [remi] section (don't enable the [remi-test] section!):
Now we can install php-fpm together with php-cli and some PHP5 modules like php-mysql which you need if you want to use MySQL from your PHP scripts: yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy Then open /etc/php.ini and uncomment the line cgi.fix_pathinfo=1: vi /etc/php.ini
Next create the system startup links for php-fpm and start it: chkconfig --levels 235 php-fpm on PHP-FPM is a daemon process (with the init script /etc/init.d/php-fpm) that runs a FastCGI server on port 9000.
5 Configuring nginxThe nginx configuration is in /etc/nginx/nginx.conf which we open now: vi /etc/nginx/nginx.conf The configuration is easy to understand (you can learn more about it here: http://wiki.codemongers.com/NginxFullExample and here: http://wiki.codemongers.com/NginxFullExample2) First (this is optional) you can increase the number of worker processes and set the keepalive_timeout to a reasonable value:
The virtual hosts are defined in server {} containers. Let's modify the default vhost as follows:
server_name _; makes this a default catchall vhost (of course, you can as well specify a hostname here like www.example.com). In the location / part, I've added index.php to the index line. root /usr/share/nginx/html; means that the document root is the directory /usr/share/nginx/html. The important part for PHP is the location ~ \.php$ {} stanza. Uncomment it to enable it. Change the root line to the web site's dosument root (e.g. root /usr/share/nginx/html;). Please make sure that you change the fastcgi_param line to fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; because otherwise the PHP interpreter won't find the PHP script that you call in your browser. Now save the file and restart nginx: /etc/init.d/nginx restart Now create the following PHP file in the document root /usr/share/nginx/html... vi /usr/share/nginx/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, including the MySQL module:
6 Links
About The Author![]() Falko Timme is the owner of
|






Recent comments
22 hours 9 min ago
1 day 1 hour ago
1 day 2 hours ago
1 day 3 hours ago
1 day 5 hours ago
1 day 6 hours ago
1 day 8 hours ago
1 day 23 hours ago
2 days 49 min ago
2 days 4 hours ago