PHP源码编译安装配置
下载地址
http://php.net/downloads.php
CentOS下预装依赖,具体自己对应添加 一般情况下面足够
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
PHP常用配置添加
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl \
--enable-ftp --enable-sockets --disable-ipv6 --with-gd \
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local \
--with-freetype-dir=/usr/local --enable-gd-native-ttf \
--with-iconv-dir=/usr/local --enable-mbstring --enable-calendar \
--with-gettext --with-libxml-dir=/usr/local --with-zlib \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd \
--enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
最后
make&&make install
拷贝PHP配置文件以及FPM配置文件 FPM默认端口是9000 Nginx通过此端口代理PHP的FastCGI模块
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php-5.5.0/etc/php-fpm.conf
最后在Nginx.conf下的server段添加如下节连接PHP fast cgi
location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
测试语法是否正确
nginx -t
启动php-fpm 在php安装路径的sbin目录下 启动后
ps -ef| grep fpm 就可以查看到php-fpm的信息
启动Nginx,此时Nginx 已经连接 php-fpm提供的fastcgi服务。