lamp环境搭建之编译安装php

1,PRC (People's republic of China)

timezone中设置的时间为中国时间。


2,php的官方镜像源,使用linux时可以直接下载的

http://cn2.php.net/distributions/php-5.6.30.tar.gz

3,编译安装php报错如下
configure: error: no acceptable C compiler found in $PATH

解决:yum安装gcc套件。

4,编译安装 ./configure 时报错,如下:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/

解决:yum 安装 curl-devel 组件。

5,解决php编译报错configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release
yum install -y libmcrypt-devel
两个不能一起安装,因为CentOs6默认的yum源没有 libmcrypt-devel这个包,
只能借助epel的yum源,所以先安装epel,再安装libmcrypt。

6,编译安装php后,可以使用下面的方法查看php版本
vim ~/.bashrc
export PATH=/usr/local/php/bin:$PATH
export PATH=/usr/local/php/sbin:$PATH

php -version 查看版本成功,就说明安装成功了。

7,php的编译成功命令
./configure
--prefix=/usr/local/php
--with-config-file-path=/etc/php
--enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets
--enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-zip
--enable-ftp --enable-soap --enable-xml --enable-mbstring
--disable-rpath --disable-debug --disable-fileinfo
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
--with-pcre-regex --with-iconv --with-zlib --with-mcrypt
--with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl

8,###php配置
php.ini是php运行核心配置文件(注意需要去刚解压完的目录里)
php-fpm.conf是php-fpm进程服务的配置文件

cp /opt/php-download/php-5.6.30/php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp /opt/php-download/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
之后就可以使用下面的这些命令了
service php-fpm start
service php-fpm stop
service php-fpm restart
service php-fpm reload
然后加入到chkconfig中:chkconfig --add php-fpm

###fpm测试php配置
/usr/local/php/sbin/php-fpm -t
显示如下则成功:
configuration file /usr/local/php/etc/php-fpm.conf test is successful

猜你喜欢

转载自www.cnblogs.com/fengfengyang/p/9858540.html