1、安装apache
[root@localhost ~]# yum -y install httpd
直到返回
...... Installed: httpd.x86_64 0:2.4.6-40.el7.centos.4 Dependency Installed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 mailcap.noarch 0:2.1.41-2.el7 Complete!
表示安装成功!
2、安装Php
[root@localhost ~]# yum -y install php
直到返回:
...... Installed: php.x86_64 0:5.4.16-36.3.el7_2 Dependency Installed: libzip.x86_64 0:0.10.1-8.el7 php-cli.x86_64 0:5.4.16-36.3.el7_2 php-common.x86_64 0:5.4.16-36.3.el7_2 Complete!
3、安装php-fpm
[root@localhost ~]# yum -y install php-fpm
直到返回:
Installed: php-fpm.x86_64 0:5.4.16-36.3.el7_2 Complete!
4、安装Mysql
[root@localhost ~]# yum -y install mysql
直到返回:
Installed: mariadb.x86_64 1:5.5.50-1.el7_2 Dependency Updated: mariadb-libs.x86_64 1:5.5.50-1.el7_2 Complete!
7.2版本的Centos已经把mysql更名为mariadb,表示安装成功!
5、安装 mysql-server
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm yum install mysql-community-server
然后需要确定,输入y回车即可
Install 3 Packages (+8 Dependent packages) Total download size: 82 M Is this ok [y/d/N]:
一直选择输入 y ,有两次选择,直到返回:
Replaced: mariadb.x86_64 1:5.5.50-1.el7_2 mariadb-libs.x86_64 1:5.5.50-1.el7_2 Complete!
安装成功!!!
6、安装 php-mysql
[root@localhost ~]# yum -y install php-mysql
直到返回:
Installed: php-mysql.x86_64 0:5.4.16-36.3.el7_2 Dependency Installed: php-pdo.x86_64 0:5.4.16-36.3.el7_2 Complete!
安装成功!!!
1、安装Apache扩展包
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
返回
...... Installed: httpd-manual.noarch 0:2.4.6-40.el7.centos.4 mod_ssl.x86_64 1:2.4.6-40.el7.centos.4 Complete!
安装成功!!!
2、安装PHP扩展包
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel
返回:
...... Dependency Updated: pcre.x86_64 0:8.32-15.el7_2.1 Complete!
安装成功!!!
3、安装Mysql扩展包
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
返回:
...... Dependency Installed: libdbi.x86_64 0:0.8.4-6.el7 libdbi-drivers.x86_64 0:0.8.3-16.el7 unixODBC.x86_64 0:2.3.1-11.el7 Complete!
安装成功!!!
重启Apache、mysql服务(注意这里和centos6有区别,Cenots7+不能使用6的方式)
systemctl enable httpd.service #设置apache开机启动
如果是采用方法一安装的mariadb
,安装完成以后使用下面的命令开启数据库服务:
#启动MariaDB
[root@localhost ~]# systemctl start mariadb.service
#停止MariaDB
[root@localhost ~]# systemctl stop mariadb.service
#重启MariaDB
[root@localhost ~]# systemctl restart mariadb.service
#设置开机启动
[root@localhost ~]# systemctl enable mariadb.service
重启对应服务
service mysqld restart service php-fpm start service httpd restart
初次安装mysql是没有密码的,我们要设置密码,mysql的默认账户为root
设置 MySQL 数据 root 账户的密码:
mysql>mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
六 安装phpmyadmi
yum install phpmyadmin
修改配置
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8 <IfModule mod_authz_core.c>
# Apache 2.4 <RequireAny>
# Require ip 127.0.0.1 #注释掉
# Require ip ::1 #注释掉
Require all granted #新添加
RequireAny> IfModule>
complete!!!