[CentOS] Best way to set up for PHP websites

Rainer Duffner rainer at ultra-secure.de
Sat Dec 18 14:45:18 UTC 2010


Am 18.12.2010 um 02:12 schrieb Ruslan Sivak:

> Is there a how-to somewhere on getting php running with nginx?  I  
> would love to get that working.
>


You need to compile php with fpm support.
Then, in nginx, you basically say:


     server {
             listen *:80;
             server_name www.domain.com;

             location / {
                     root   /home/domain/FTPROOT/htdocs;
                     index index.php index.htm index.html;

                     # if file exists return it right away
                     if (-f $request_filename) {
                             break;
                     }

                     if ($request_uri ~ '^/(typo3(/|conf|temp)| 
fileadmin|uploads|t3lib|clear.gif|index.php|favicon.ico)') {
                         break;
                     }
                     # otherwise rewrite it;
                     if (!-e $request_filename) {
                              rewrite ^(.+)$ /index.php last;
                     #        rewrite .* /index.php last;
                             break;
                     }

             }

             # if the request starts with our frontcontroller, pass it  
on to fastcgi
             location ~ \.php$ {
                     fastcgi_pass unix:/var/run/php-fpm-domain.sock;
                     fastcgi_index index.php;
                     fastcgi_param SCRIPT_FILENAME /htdocs 
$fastcgi_script_name;
                     fastcgi_param PATH_INFO $fastcgi_script_name;
                     include /usr/local/etc/nginx/fastcgi_params;
                     fastcgi_param DOCUMENT_ROOT /htdocs/ ;
             }
         }


The php-fpm mailinglist is a good start for question regarding this  
topic.
I don't know about memcache, but it's surely a good idea.

With varnish, you have to be very careful because it doesn't cache  
sites with cookies.
Different drupal-modules and extensions will create their own cookies  
and so almost nothing will cache.


Probably, the people at
http://groups.drupal.org/nginx

know more about this than me anyway.


Rainer







More information about the CentOS mailing list