Bước 1: Cài đặt nginx & php-fpm
rpm-Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install-ynginx php-fpm php-common |
Bước 2: Cấu hình nginx & php-fpm
vim/etc/nginx/nginx.conf |
Chỉnh worker_processes bằng với số processor VPS của bạn
vim/etc/nginx/conf.d/default.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # # The default server # server{ listen 80; server_name example1.com; location /{ root /var/www/html/example1.com; index index.php; try_files $uri$uri//index.php?q=$uri&$args; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location~\.php${ root /var/www/html/example1.com; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } server{ listen 80; server_name example2.com; location/ { root /var/www/html/example2.com; index index.php; try_files $uri$uri//index.php?q=$uri&$args; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location~\.php${ root /var/www/html/example2.com; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } |
Chú ý cần phải để fastcgi_pass 127.0.0.1:9000;
vim/etc/php-fpm.d/www.conf |
Thay user và group = apache sang nginx
[...] ;Unix user/group of processes ;Note:The user ismandatory.Ifthe group isnotset,the defaultuser'sgroup ;will be used. ;RPM:apache Choosed tobe able toaccess some dir ashttpd user=nginx ;RPM:Keepagroup allowed towriteinlog dir. group=nginx [...] |
Bước 3: Khởi động lại
service nginx start service php-fpm start |