您的位置:首页 > 编程语言 > PHP开发

四、编译安装php-5.5.34

2016-04-12 21:47 651 查看

四、编译安装php-5.5.34

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

1、解决依赖关系

先配置阿里云yum源:

# 1、备份
# mv/etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

# 2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 6:
# wget-O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo CentOS 7:
# wget-O /etc/yum.repos.d/CentOS-Base.repo

# 3、之后运行yummakecache生成缓存
添加Epel源:
# 1、备份(如有配置其他epel源)
# mv/etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
# mv/etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

# 2、下载新repo 到/etc/yum.repos.d/
epel(RHEL 7):
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 
epel(RHEL 6):
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo[/code] 

安装依赖包:

# yum -y groupinstall "DesktopPlatform Development"
# yum -y install bzip2-devel libmcrypt-devel libxml2-devel
如果想让编译的php支持mcrypt扩展,此处还需要单独安装此依赖包,epel6源自带可以直接安装:
# yum-y install libmcrypt libmcrypt-devel mhash mhash-devel
注:如果你使用的epel7的源,可能会没有 mcrypt mhash mhash-devel 几个包,可以在 http://mirrors.aliyun.com/epel/6/x86_64/中下载,使用 yum localinstall xxx.rpm 或 rpm -Uvh xxx.rpm 手动安装即可。

2、创建www 用户

# groupadd -r www
# useradd-g www -s /sbin/nologin -M www

3、编译安装php-5.5.34

首先下载源码包至本地目录,
[root@web tool]# wget http://cn2.php.net/distributions/php-5.5.34.tar.gz [root@web tool]# tar xf php-5.5.34.tar.gz
[root@webtool]# cd php-5.5.34
然后执行以下编译参数:
./configure--prefix=/usr/local/php \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d\
--with-bz2 \
--with-curl \
--enable-ftp \
--enable-sockets \
--disable-ipv6 \
--with-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--enable-gd-native-ttf \
--with-iconv-dir=/usr/local \
--enable-mbstring \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-calendar \
--with-gettext \
--with-libxml-dir=/usr/local \
--with-zlib \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-mysql=mysqlnd \
--enable-dom \
--enable-xml \
--enable-fpm \
--with-fpm-user=www\
--with-fpm-group=www\
--with-libdir=lib64 \
--enable-bcmath \
--enable-maintainer-zts \
没有报错的话,再执行以下命令进行编译安装:
# make
# make test
# make intall
请耐心等待。。。。。。
# 参数说明:
#""" 安装路径 """
--prefix=/usr/local/php \
#""" php.ini 配置文件路径 """
--with-config-file-path= /etc \
#""" 优化选项 """
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
#""" 启用 opcache,默认为 ZendOptimizer+(ZendOpcache)"""
--enable-opcache \
#""" FPM """
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
#""" MySQL """
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
#""" 国际化与字符编码支持 """
--with-gettext \
--enable-mbstring \
--with-iconv \
#""" 图片格式的支持 """
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
#""" 加密扩展 """
--with-mcrypt \
--with-mhash \
--with-openssl \
#""" 数学扩展 """
--enable-bcmath \
#""" Web 服务,soap 依赖 libxml """
--enable-soap \
--with-libxml-dir \
#""" 进程,信号及内存 """
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
#""" socket & curl"""
--enable-sockets \
--with-curl \
#""" 压缩与归档 """
--with-zlib \
--enable-zip \
--with-bz2 \
#支持apache的worker或event这两个MPM
--enable-maintainer-zts

#Zabbix安装需要的PHP扩展参数
--enable-bcmath
--enable-mbstring
--enable-sockets
--with-gd
--with-libxml-dir=/usr/local
xmlwriter 同上
xmlreader 同上
ctype 默认支持
session 默认支持
gettext 默认支持

4、为php提供配置文件:

[root@web php-5.5.34]# cp php.ini-production/etc/php.ini
# 说明:
# php.ini-development     //开发环境用
# php.ini-production      //生产环境用

5、 编辑apache配置文件httpd.conf,以apache支持php

[root@web php-5.5.34]# vim/etc/httpd24/httpd.conf

# 输入409gg直接跳到409行,添加下面两条(注意格式,后面.前面需要空格):
409    AddTypeapplication/x-httpd-php .php .phtml
410    AddTypeapplication/x-httpd-php-source .phps

# 再跳到165行,修改damon为其它用户如www
165 # running httpd, as with most system services.
166 #
168 User www
169 Group www

# 更改首页,跳转到256行,添加index.php首页:
256 <IfModule dir_module>
257     DirectoryIndexindex.php index.html
258</IfModule>

6、而后重新启动httpd:

[root@web php-5.5.34]# service httpd restart

7、测试:

php程序与mysql安装情况:
[root@web php-5.5.34]# cd/usr/local/apache/htdocs
[root@web htdocs]# vim index.php

<?php
$link = mysql_connect('127.0.0.1','root','123456');
if($link)
echo "Success";
else
echo "failure";
mysql_close();
phpinfo();
?>
然后浏览器输入ip地址:



表明apache mysql php安装成功!

下一篇:五、安装xcache3.1.2,为php加速:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php 编译安装 zabbix