Centos7下安装PHP7
准备工作:
# 安装编译工具:
yum -y install gcc automake autoconf libtool gcc-c++
# 安装基础库
yum -y install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt
libmcrypt-devel curl curl-devel
yum安装的时候出现下面提示
No package libmcrypt available.
No package libmcrypt-devel available.
是因为版权原因没有这个源
解决方法安装第三方yum源(参考http://www.nginx.cn/2196.html)
wget http://www.atomicorp.com/installers/atomic
sh ./atomic
yum install php-mcrypt libmcrypt libmcrypt-devel
# 下载pcre 正则库
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2
tar jxf pcre-8.37.tar.bz2
cd pcre-8.37/
./configure --prefix=/usr/local/pcre
make && make install
1、下载PHP
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.0.3.tar.gz
2、解压PHP并切换到PHP解压的目录
tar zxvf php-7.0.3.tar.gz
cd php-7.0.3/
./configure --prefix=/usr/local/php7 \
--with-gd \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-mcrypt \
--enable-mbstring \
--enable-zip \
--enable-fpm \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-curl \
--enable-xml \
--with-iconv-dir \
--with-freetype-dir \
--with-openssl \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv
make && make install
耐心等待吧,骚年
# 复制配置文件
cp /usr/local/src/php-7.0.3/php.ini-development /usr/local/fastphp/lib/php.ini
cp /usr/local/fastphp/etc/php-fpm.conf.default /usr/local/fastphp/etc/php-fpm.conf
cp /usr/local/fastphp/etc/php-fpm.d/www.conf.default /usr/local/fastphp/etc/php-fpm.d/www.conf
# 整合nginx+php
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;
}
最后在/usr/local/nginx/html/下新建test.php
phpinfo();
OK,Centos7下PHP7成功安装!
喜欢 (0)or分享 (0)