Configure nginx in centos to support php
Install php
yum install php
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Add nginx default homepage index. php
Vim/etc/nginx/conf. d/default. conf
Location /{
Root/usr/share/nginx/html;
Index index.html index.htm index. php;
}
Configure nginx to support php
Vim/etc/nginx/conf. d/default. conf
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ . Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/usr/share/nginx/html $ fastcgi_script_name;
Include fastcgi_params;
}
Configure php-fpm
Vim/etc/php-fpm.d/www. conf
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; Will be used.
; RPM: apache Choosed to be able to access some dir as httpd
User = nginx
; RPM: Keep a group allowed to write in log dir.
Group = nginx
Chkconfig php-fpm on # Set php-fpm to self-start
Chkconfig mysqld on # Set mysqld to start automatically
Service nginx restart # restart nginx
Service php-fpm start # start php-fpm
Service mysqld start # start mysqld