首先,安装apache服务器
yum install httpd
第二,安装php及常用软件包
yum install php httpd-manual mod_ssl mod_perl mod_auth_mysqlyum install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpcyum install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
第三,安装mariadb
yum install mariadb*
第四,启动服务
systemctl start httpd.servicesystemctl start mariadb.service
第五,如果第四部成功,则设置两个服务自动启动
systemctl enable httpd.servicesystemctl enable mariadb.service
第六,设置数据库服务器
[root@rachel ~]# mysql -u root #无密码登录数据库welcome tothe mariadb monitor. commands endwith ; or \g.your mariadb connection idis3server version: 5.5.44-mariadb mariadb servercopyright (c) 2000, 2015, oracle, mariadb corporation ab and others.type 'help;' or '\h' for help. type '\c' to clear the current input statement.mariadb [(none)]> select user, host, password from mysql.user; #检索数据库用户+------+--------------+----------+| user | host | password |+------+--------------+----------+| root | localhost | || root | rachel | || root | 127.0.0.1 | || root | ::1 | || | localhost | || | rachel | |+------+--------------+----------+6 rows inset (0.00 sec)mariadb [(none)]> delete from mysql.user where user='';query ok, 2 rows affected (0.00 sec) #删除匿名用户mariadb [(none)]> delete from mysql.user where user='root' and host='::1'; #删除ipv6方式登录用户query ok, 1 row affected (0.00 sec)mariadb [(none)]> select user, host, password from mysql.user; #再次查看用户+------+--------------+----------+| user | host | password |+------+--------------+----------+| root | localhost | || root | rachel | || root | 127.0.0.1 | |+------+--------------+----------+3 rows inset (0.00 sec)mariadb [(none)]> set password for root@localhost=password('xxxxxx'); #修改本地登录密码query ok, 0 rows affected (0.00 sec)mariadb [(none)]> set password for root@rachel=password('xxxxxx'); #修改本地登录密码query ok, 0 rows affected (0.00 sec)mariadb [(none)]> set password for root@'127.0.0.1'=password('xxxxxx'); #修改本地登录密码query ok, 0 rows affected (0.00 sec)mariadb [(none)]> select user, host, password from mysql.user; #查看密码+------+--------------+-------------------------------------------+| user | host | password |+------+--------------+-------------------------------------------+| root | localhost | *1728fcc102d8d1eb12bfxxxxxxxxxxxxxxxxxxx || root | rachel | *1728fcc102d8d1eb12bfxxxxxxxxxxxxxxxxxxx || root | 127.0.0.1 | *1728fcc102d8d1eb12bfxxxxxxxxxxxxxxxxxxx |+------+--------------+-------------------------------------------+3 rows inset (0.00 sec)mariadb [(none)]> exit#退出bye[root@rachel ~]# mysql -u root -p #再次用密码登录测试enter password: welcome tothe mariadb monitor. commands endwith ; or \g.your mariadb connection idis4server version: 5.5.44-mariadb mariadb servercopyright (c) 2000, 2015, oracle, mariadb corporation ab and others.type 'help;' or '\h' for help. type '\c' to clear the current input statement.mariadb [(none)]> exitbye[root@rachel ~]# #测试成功
以上就介绍了centos7安装apache+php+mariadb,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。