转自https://www.cnblogs.com/pengyunjing/p/8687097.html
先删除之前的安装目录
rm -rf /usr/local/php;
安装php依赖组件(包含Nginx依赖):
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
创建用户和组,并下载php安装包解压:
groupadd www useradd -g www www wget http://am1.php.net/distributions/php-7.2.1.tar.gz tar xvf php-7.2.1.tar.gz cd php-7.2.1
设置变量并开始源码编译:
cp -frp /usr/lib64/libldap* /usr/lib/;
./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --enable-mysqlnd-compression-support \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-mbstring \ --enable-intl \ --with-mcrypt \ --with-libmbfl \ --enable-ftp \ --with-gd \ --enable-gd-jis-conv \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --with-gettext \ --disable-fileinfo \ --enable-opcache \ --with-pear \ --enable-maintainer-zts \ --with-ldap=shared \ --without-gdbm
完成后,这一部时间比较长,半个小时左右
make clean && make && make install;
cp php.ini-development /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
完成安装后配置php.ini文件: vim /usr/local/php/etc/php.ini
配置www.conf:
user = www
group = www
pm = static
pm.max_children = 64
配置php-fpm.conf
取消注释
pid=/usr/local/php/var/run/php-fpm.pid
运行php-fpm
/usr/local/php/sbin/php-fpm
第一次编译的时候,没有把之前的php-fpm删掉,在这里卡住 总是报
php-fpm: line 2: syntax error near unexpected token `;'
百度之后 删掉前几行 没有行 吧“;”注释符改成“#”注释符,当行不报错,可是后面的“;”还是报错,所以删掉/usr/local/php,重新生成configure文件 重新make && make install。php启动成功。(运行了错误的命令 /usr/local/php/etc/php-fpm.conf)
转自:https://blog.csdn.net/zhezhebie/article/details/73331067
netstat -lntup | grep 9000
killall php-fpm
重新启动
/usr/local/php/sbin/php-fpm
成功