centos yum安装高版本php 2018-10-13
准备工作:配置防火墙,开启80、3306端口。CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
#停止firewall服务
systemctl stop firewalld.service
#禁止firewall开机启动
systemctl disable firewalld.service
#安装yuminstalliptables-services
#编辑防火墙配置文件 vi/etc/sysconfig/iptables加入红色的两行代码,请注意位置一定要对应。# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport22-j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
#最后重启防火墙使配置生效
systemctl restart iptables.service
#设置防火墙开机启动
systemctl enable iptables.service
3. 关闭seinux
#修改配置文件vi/etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
#使配置立即生效
setenforce 0
1.检查当前安装的php包
#yum list installed | grep php
扩展:@1检查当前已安装所有安装包 #yum list installed
@2检查当前已安装的指定安装包 #yum list installed httpd
删除(卸载)已安装的包
#yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
2.rpm包安装(rpm命令是RPM软件包的管理工具。)
CentOs 5.x
#rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
CentOs 6.x
#rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOs 7.X
#rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
如果想删除上面安装的包,重新安装
#rpm -qa | grep webtatic
#rpm -e 上面搜索到的包即可
3.查看可安装的php版本
#yum list php*(显示可用安装包)
4.安装php(以php7.0为例)
#yum -y install php70w.x86_64
安装php-mysql扩展
#yum install php56w-mysql
安装mbstring扩展
#yum install php56w-mbstring
查看php版本
#php -v
查看php安装的模块
#php -m
3.安装apeach
执行
#cd /etc/yum.repos.d
#wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
#wget http://www.hop5.in/yum/el6/hop5.repo
建议先把已安装的卸载掉(上面已有apache2.2)
查看已安装
#yum list installed httpd*
卸载
#yum remove httpd
查看可安装httpd
#yum list httpd*
安装
#yum install httpd24-httpd httpd24-httpd-devel httpd24-mod_ssl hhvm