和LAMP安装PHP方法有差别,需要开启php-fpm服务
如果安装过以前php需要make clean
root@aminglinux-02 php-5.6.30]# make clean
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp5.la sapi/cli/php sapi/cgi/php-cgi libphp5.la modules/* libs/*
cd /usr/local/src/
tar zxf php-5.6.30.tar.gz
useradd -s /sbin/nologin php-fpm 该账号用来运行php-fpm服务
cd php-5.6.30
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
错误
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
[root@aminglinux-02 php-5.6.30]# yum list |grep libcurl
libcurl.x86_64 7.29.0-35.el7.centos @anaconda
libcurl.i686 7.29.0-35.el7.centos base
libcurl-devel.i686 7.29.0-35.el7.centos base
libcurl-devel.x86_64 7.29.0-35.el7.centos base
[root@aminglinux-02 php-5.6.30]# yum install -y libcurl-devel
make & make install
php-fpm加载模块查看命令
[root@aminglinux-02 php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -m
[root@aminglinux-02 php-5.6.30]# /usr/local/php-fpm/bin/php -m
php-fpm配置文件语法检测命令
[root@aminglinux-02 php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t
cp php.ini-production /usr/local/php-fpm/etc/php.ini拷贝php配置文件
vi /usr/local/php/etc/php-fpm.conf 编辑php-fpm配置文件写入
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
#listen = 127.0.0.1:9000
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
[global]定义全局参数,listen定义监听地址,也可以写成ip加端口,listen.mode只有监听为socket时才生效,用来指定sock文件的权限
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 启动文件
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
ps aux |grep php-fpm