Maison  >  Article  >  développement back-end  >  CentOS7安装Apache+PHP+MariaDB

CentOS7安装Apache+PHP+MariaDB

WBOY
WBOYoriginal
2016-07-29 09:15:081524parcourir

首先,安装Apache服务器

<code>yum <span>install</span> httpd</code>

第二,安装PHP及常用软件包

<code>yum install php httpd<span>-manual</span> mod_ssl mod_perl mod_auth_mysql
yum install php<span>-gd</span> php<span>-xml</span> php<span>-mbstring</span> php<span>-ldap</span> php<span>-pear</span> php<span>-xmlrpc</span>
yum install mysql<span>-connector</span><span>-odbc</span> mysql<span>-devel</span> libdbi<span>-dbd</span><span>-mysql</span></code>

第三,安装MariaDB

<code>yum <span>install</span> mariadb* </code>

第四,启动服务

<code>systemctl <span><span>start</span> httpd.service
systemctl <span>start</span> mariadb.service</span></code>

第五,如果第四部成功,则设置两个服务自动启动

<code>systemctl enable httpd<span>.service</span>
systemctl enable mariadb<span>.service</span></code>

第六,设置数据库服务器

<code>[root@rachel ~]<span>#  mysql -u root #无密码登录数据库</span>
Welcome <span>to</span><span>the</span> MariaDB monitor.  Commands <span>end</span><span>with</span> ; <span>or</span> \g.
Your MariaDB connection <span>id</span><span>is</span><span>3</span>
Server <span>version</span>: <span>5.5</span><span>.44</span>-MariaDB MariaDB Server

Copyright (c) <span>2000</span>, <span>2015</span>, Oracle, MariaDB Corporation Ab <span>and</span> others.

Type 'help;' <span>or</span> '\h' <span>for</span> help. Type '\c' <span>to</span> clear <span>the</span> current input statement.

MariaDB [(none)]> select user, host, password <span>from</span> mysql.user; <span>#检索数据库用户</span>
+<span>------+--------------+----------+</span>
| user | host         | password |
+<span>------+--------------+----------+</span>
| root | localhost    |          |
| root | rachel       |          |
| root | <span>127.0</span><span>.0</span><span>.1</span>    |          |
| root | ::<span>1</span>          |          |
|      | localhost    |          |
|      | rachel       |          |
+<span>------+--------------+----------+</span><span>6</span> rows <span>in</span><span>set</span> (<span>0.00</span> sec)

MariaDB [(none)]> delete <span>from</span> mysql.user <span>where</span> user='';
Query OK, <span>2</span> rows affected (<span>0.00</span> sec) <span>#删除匿名用户</span>MariaDB [(none)]> delete <span>from</span> mysql.user <span>where</span> user='root' <span>and</span> host='::<span>1</span>'; <span>#删除IPv6方式登录用户</span>
Query OK, <span>1</span> row affected (<span>0.00</span> sec)

MariaDB [(none)]> select user, host, password <span>from</span> mysql.user;  <span>#再次查看用户</span>
+<span>------+--------------+----------+</span>
| user | host         | password |
+<span>------+--------------+----------+</span>
| root | localhost    |          |
| root | rachel       |          |
| root | <span>127.0</span><span>.0</span><span>.1</span>    |          |
+<span>------+--------------+----------+</span><span>3</span> rows <span>in</span><span>set</span> (<span>0.00</span> sec)

MariaDB [(none)]> <span>set</span> password <span>for</span> root@localhost=password('XXXXXX');  <span>#修改本地登录密码</span>
Query OK, <span>0</span> rows affected (<span>0.00</span> sec)

MariaDB [(none)]> <span>set</span> password <span>for</span> root@rachel=password('XXXXXX');  <span>#修改本地登录密码</span>
Query OK, <span>0</span> rows affected (<span>0.00</span> sec)

MariaDB [(none)]> <span>set</span> password <span>for</span> root@'<span>127.0</span><span>.0</span><span>.1</span>'=password('XXXXXX');  <span>#修改本地登录密码</span>
Query OK, <span>0</span> rows affected (<span>0.00</span> sec)

MariaDB [(none)]> select user, host, password <span>from</span> mysql.user; <span>#查看密码</span>
+<span>------+--------------+-------------------------------------------+</span>
| user | host         | password                                  |
+<span>------+--------------+-------------------------------------------+</span>
| root | localhost    | *<span>1728</span>FCC102D8D1EB12BFXXXXXXXXXXXXXXXXXXX |
| root | rachel       | *<span>1728</span>FCC102D8D1EB12BFXXXXXXXXXXXXXXXXXXX |
| root | <span>127.0</span><span>.0</span><span>.1</span>    | *<span>1728</span>FCC102D8D1EB12BFXXXXXXXXXXXXXXXXXXX |
+<span>------+--------------+-------------------------------------------+</span><span>3</span> rows <span>in</span><span>set</span> (<span>0.00</span> sec)

MariaDB [(none)]> <span>exit</span><span>#退出</span>
Bye
[root@rachel ~]<span># mysql -u root -p #再次用密码登录测试</span>
Enter password: 
Welcome <span>to</span><span>the</span> MariaDB monitor.  Commands <span>end</span><span>with</span> ; <span>or</span> \g.
Your MariaDB connection <span>id</span><span>is</span><span>4</span>
Server <span>version</span>: <span>5.5</span><span>.44</span>-MariaDB MariaDB Server

Copyright (c) <span>2000</span>, <span>2015</span>, Oracle, MariaDB Corporation Ab <span>and</span> others.

Type 'help;' <span>or</span> '\h' <span>for</span> help. Type '\c' <span>to</span> clear <span>the</span> current input statement.

MariaDB [(none)]> <span>exit</span>
Bye
[root@rachel ~]<span># #测试成功</span></code>

以上就介绍了CentOS7安装Apache+PHP+MariaDB,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn