centos7 配置 php 环境(php-fpm)

安装php服务

  • 1、下载php
    网址:http://php.net/downloads.php
  • 2、解压
tar zxvf php-x.x.xx.tar.gz   (x.x.xx 为php版本)
cd php-x.x.xx
  • 3、配置php
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-MySQL --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
  • 3.1、错误
错误1:xml2-config not found. Please check your libxml2 installation.

解决办法:
安装libxml2相关组件

yum install libxml2
yum install libxml2-devel -y

错误2:Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/

安装curl相关组件:

yum install curl curl-devel

错误3:configure: error: png.h not found.

安装libpng相关组件:

yum install libpng
yum install libpng-devel

错误4:freetype-config not found.

安装freetype相关组件:

yum install freetype-devel

错误5:xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

安装libxslt相关组件:

yum install libxslt-devel
  • 4、安装php
make
make install
  • 5、配置php.ini
cp -a php.ini-production /usr/local/php/etc/php.ini //拷贝安装包里的php配置文件到安装目录下
rm -rf /etc/php.ini      //删除默认的php配置文件
ln -s /usr/local/php/etc/php.ini /etc/php.ini       //建立软链接

cp -a ./sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf     //拷贝安装包里的php-fpm配置文件到安装目录下
cp -a ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm      //拷贝启动文件
  • 6、启动
service php-fpm start 
ps aux | grep php
  • 7、重启
service php-fpm restart
  • 8、关闭
service php-fpm stop
  • 9、卸载
yum remove php-common

你可能感兴趣的:(centos7,安装文档)