Centos6.4 编译安装 nginx php的方法

2019-10-12 14:35:39王旭

如果报如下错误

configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

修改 /etc/ld.so.conf 文件

vi /etc/ld.so.conf.d/local.conf
#添加2行
/usr/local/lib64 //64系统
/usr/local/src/libmcrypt-2.5.7/lib/.libs

#执行以下命令
chmod gu+x /etc/ld.so.conf.d/local.conf
#执行以下命令使生效
ldconfig -v

再次执行命令

成功后编译安装

七. 配置启动

1. 配置php-fpm

cd /usr/local/php
cp /etc/php-fpm.conf.default /etc/php-fpm.conf
vi /etc/php-fpm.conf

修改
user = llong
group = llong

2. 修改nginx 支持 php-fpm

打开 nginx.conf

其中server段增加如下配置,注意标红内容配置,否则会出现No input file specified.错误

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

3. 测试是否配置成功

在/usr/local/nginx/html下创建index.php文件,输入如下内容

<? 
echo phpinfo(); 
?>

启动php-fpm和nginx

/usr/local/php/sbin/php-fpm (手动打补丁的启动方式/usr/local/php/sbin/php-fpm start)
 /usr/local/nginx/nginx