Centos Apache+PHP5.6/PHP7.0+mysql5.5

安装Apache

#一键安装apache
yum install httpd

#启动apche
/etc/init.d/httpd start                     #方法1 
service httpd start                         #方法2

#设置apache开机自动启动
chkconfig --levels 235 httpd on 

安装PHP7.0(如果想安装PHP5.6则跳过此步骤,看下一步骤)

#更新yum源(默认yum源中无php7)
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm  

#安装php及常用的拓展模块
yum -y install php70w php70w-mysql php70w-mbstring php70w-mcrypt php70w-gd php70w-imap php70w-ldap php70w-odbc php70w-pear php70w-xml php70w-xmlrpc php70w-pdo

#查看php安装了那些拓展模块
php -m

#安装其他你需要的拓展模块
yum -y install php70w-xxx

安装PHP5.6

#更新yum源(默认yum源中无php7)

#追加CentOS 6.5的epel及remi源。
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#以下是CentOS 7.0的源。
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

#安装PHP5.6
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

#这边给你提供安装php5.6的yum方法扩展自选。
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof (空格跟上自己想要的扩展)
yum --enablerepo=remi-php56 install php-gd php-mysql php-mbstring php-xml php-mcrypt (忘记的扩展在运行一次就ok了(常用的GD库安装))

 安装mysql5.5

#查询是否安装了mysql,默认是安装了mysql-libs的5.1版本的。需卸载
rpm -qa|grep mysql
rpm -e mysql-libs --nodeps       #不检测依赖性

#增加两个新的repo源
rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#检测源是否安装成功
yum --enablerepo=remi,remi-test list mysql mysql-server

#安装mysql5.5
yum -y --enablerepo=remi,remi-test install mysql mysql-server

#启动mysql
/etc/init.d/mysqld start

#将mysql设置为开机自动启动
chkconfig --levels 345 mysqld on

#设置mysql的root密码
/usr/bin/mysql_secure_installation
原文地址:https://www.cnblogs.com/daniel2021/p/10702115.html