1.安装apache
[root@localhost ~]# yum install httpd
根据提示,输入Y安装即可成功安装
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
2.安装mariadb(MySQL)
[root@localhost ~]# yum install mariadb mariadb-server
询问是否要安装,输入Y即可自动安装,直到安装完成
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
3.修改mysql密码,安装后默认为空
修改mysql密码为root:
[root@localhost ~]# mysql -u root
MariaDB [(none)]> set password for 'root'@'localhost'=password('root');
再次登录mysql,验证密码 root
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.50-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
mysql授权远程连接(navicat等):
MariaDB [(none)]> grant all on *.* to root identified by 'root';
Query OK, 0 rows affected (0.00 sec)
4.安装PHP以及组件,使PHP支持 MariaDB
yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
选择以上安装包进行安装,根据提示输入Y回车
#重启MariaDB
systemctl restart mariadb.service
#重启apache
systemctl restart httpd.service
5.访问测试
[root@localhost ~]# cd /var/www/html
[root@localhost html]# vi index.php
#输入下面内容
phpinfo();
?>
按Esc键 输入
:wq!
#保存退出
在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!