Centos6.6编译安装PHP7.0详解-创新互联
Centos6.6编译安装PHP7.0.13详解
成都创新互联公司主要从事成都网站设计、成都网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务蜀山,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-869222201: Yum源更改为阿里的镜像源
#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos- 6.repo
#yum clean all
#yum makecache
2: 安装php所必要的依赖包
#yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
#yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel -y
libiconv-devel 默认的yum源中没有需要编译安装
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#cd libiconv-1.14
#./configure --prefix=/usr/local/libiconv
#make && make install
3:安装mhash和mcrypt算法
一:下载相应的软件包
1:下载libmcrypt(安装mcrypt需要此软件包)
#wgethttps://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
2:下载mhash(安装mcrypt需要此软件包)
#wgethttps://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
3:下载mcrypt
#wgethttps://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
二、安装软件包
1、安装libmcrypt
cd /usr/local/src #进入软件包存放目录
tar zxvf libmcrypt-2.5.8.tar.gz #解压
cd libmcrypt-2.5.8 #进入安装目录
./configure #配置
make #编译
make install #安装
2、安装mhash
cd /usr/local/src
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
3、安装mcrypt
cd /usr/local/src
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
ln -s /usr/local/bin/libmcrypt_config /usr/bin/libmcrypt_config #添加软连接
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH #添加环境变量
./configure
make
make install
4:安装编译php7.0.13
#wget http://cn2.php.net/distributions/php-7.0.13.tar.gz
#cd php-7.0.13
#./configure --prefix=/application/php-7.0.13/ --with-mysqli=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --disable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-signals --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
#make
#make install
到源码包目录把PHP的配置文件copy到php的安装目录
#cd /home/ntw1990/tools/php-7.0.13
# cp php.ini-production /application/php-7.0.13/etc/
将 php 的 bin 和 sbin 加入环境变量:
#echo "export PATH=$PATH:/application/php-7.0.13/bin:/application/php-7.0.13/sbin" >> /etc/profile
#source /etc/profile
# cd /application/php-7.0.13/etc/
#cp php-fpm.conf.default php-fpm.conf
# /application/php-7.0.13/sbin/php-fpm ( 启动php进程)
#ps -ef | grep php-fpm (检测下php-fpm进程)
5:测试php与nginx和mysql的通信正常与否
1:测试和nginx的通信是否正常 (随意编辑一个虚拟主机,本人的如下配置)
# vim /application/nginx/conf/extra/blog.conf
server { listen 80; server_name blog.niutianwen.org; root /application/nginx/html/blog; index index.php index.html index.htm; location / { } location ~ \.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } }# 在测试虚拟主机的网站首页写一个php的测试脚本
# mkdir /application//nginx/html/blog -p 创建网站根目录
# cd /application//nginx/html/blog
# echo "" >test_info.php
打开firefox测试效果:
1:首先做好主机名和ip的对应
#vim /etc/hosts
本机ip地址 blog.niutianwen.org
2:在浏览器中打开http://blog.niutianwen.org/test_info.php
如出现以下界面表示php和nginx的通信是正常的!
2:测试和Mysql的通信是否正常
# cd /application//nginx/html/blog
# vim mysql_connect.php
2:在浏览器中打开http://blog.niutianwen.org/mysql_connect.php
如出现下面红线标的那一行表示php连接Mysql是正常的!
6:使用centos6.6系统默认的进程管理方式启动php-fpm
#vim /etc/init.d/php-fpm
#! /bin/sh # Comments to support chkconfig on CentOS # chkconfig: 2345 65 37 # set -e #PATH=/application/php-7.0.13/sbin:/application/php-7.0.13/bin DESC="php-fpm daemon" NAME=php-fpm #php-fpm命令的路径 DAEMON=/application/php-7.0.13/sbin/$NAME #php-fpm的配置文件 CONFIGFILE=/application/php-7.0.13/etc/php-fpm.conf #php-fpm的pid文件 PIDFILE=/application/php-7.0.13/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 function_start() { [ -f $PIDFILE ] && rm -rf $PIDFILE $DAEMON -y $CONFIGFILE -g $PIDFILE && echo "Php-fpm is started" } function_stop() { netstat -tunlp | grep $NAME | grep -v -e grep -e vim | awk -F'/' '{print $1}' |awk '{print $NF}' | xargs -I {} kill -QUIT {} 2> /dev/null [ $? -eq 0 ] && echo " Php-fpm is stopped" } function_reload() { [ `netstat -tunlp | grep 9000|wc -l` -eq 0 ] && echo "$DESC is not startup!" && exit 0 PID=`ps -ef | grep $NAME | grep -v -e grep -e vim | grep master | awk '{print $2}'` echo $PID kill -USR2 $PID && echo "php-fpm is reloaded!" } case "$1" in start) echo -n "Starting $DESC....----->>>>" function_start ;; stop) echo -n "Stopping $DESC....---->>>>" function_stop ;; reload) echo -n "Reloading $DESC configuration....---->>>>" function_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC....---->>>>" function_stop sleep 3 function_start ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac至此。centos6.6编译安装PHP7.0.12就OK了!
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享标题:Centos6.6编译安装PHP7.0详解-创新互联
文章URL:http://ybzwz.com/article/pohcj.html