I recently moved my servers from Ubuntu 10.04 to Debian 6, and changed my entire application stack along with it. No more Apache or mod_php; for the moment, my whole stack is based off of Nginx, PHP-FPM, and Percona (a high-performance drop-in MySQL replacement.)
To do this easily, first we must add the Dotdeb repos. First, open up /etc/apt/sources.list:
root@debian:~# nano /etc/apt/sources.list
And add the following lines:
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
Done? Now you need to add the repository's GPG key: (you might need to install wget)
root@debian:~# wget http://www.dotdeb.org/dotdeb.gpg
root@debian:~# cat dotdeb.gpg | sudo apt-key add -
Now run:
root@debian:~# apt-get update
root@debian:~# apt-get install nginx-full php5-cli php5-common php5-suhosin
root@debian:~# apt-get install php5-fpm php5-cgi
These next packages aren't absolutely necessary, but will definitely ensure compatibility:
root@debian:~# apt-get install php5-mysql php5-curl
You should now have PHP-FPM and Nginx installed. Let's get Percona installed as well, then we'll configure it all.
Add the GPG key for the repository:
root@debian:~# gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
root@debian:~# gpg -a --export CD2EFD2A | apt-key add -
Then add the repo to /etc/apt/sources.list:
deb http://repo.percona.com/apt squeeze main
deb-src http://repo.percona.com/apt squeeze main
And update:
root@debian:~# apt-get update
Before you install the required packages, add the following to /etc/apt/preferences, (create it if it doesn't exist):
Package: libmysqlclient16
Pin: origin repo.percona.com
Pin-Priority: 1001
This will help you avoid problems with the Percona and the Dotdeb repositories. Finally, install Percona:
root@debian:~# apt-get install percona-server-client-5.1 percona-server-common percona-server-server-5.1
It will install and you can configure it exactly the same as MySQL.
To get Nginx to send PHP files upstream to PHP-FPM, add the following to your Nginx server configuration (this is assuming you are already familiar with Nginx configuration):
location ~ (.*)?.php($|/) {
# No funny business
if (!-f $request_filename) {
return 404;
}
fastcgi_index index.php;
fastcgi_split_path_info ^(.+.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
Then restart both PHP-FPM and Nginx for good measure:
root@debian:~# service nginx restart
root@debian:~# service php-fpm restart
The last thing we need to do is tell Percona to only allow the newer authentication scheme, or PHP will not be able to connect. So, open up /etc/mysql/my.cnf:
root@debian:~# nano /etc/mysql/my.cnf
And change old_passwords = 1 to #old_passwords = 1. Then, restart Percona:
root@debian:~# service mysql restart
And that's it! You should have a basic PHP-FPM, Nginx, and Percona setup.
Text is formatted with Markdown.
There are no comments made so far.