http://cn2.php.net/distributions/php-5.5.34.tar.gz
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
# 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 手动安装即可。
# groupadd www # useradd-g www -s /sbin/nologin -M www
首先下载源码包至本地目录,
[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 默认支持
[root@web php-5.5.34]# cp php.ini-production/etc/php.ini 说明: php.ini-development //开发环境用 php.ini-production //生产环境用
[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>
[root@web php-5.5.34]# service httpd restart
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加速:
本文出自 “汛熙时空” 博客,请务必保留此出处http://858004880.blog.51cto.com/7265424/1763190
原文地址:http://858004880.blog.51cto.com/7265424/1763190