首先,安裝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>
rereee
設定兩個服務自動啟動<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教學有興趣的朋友有幫助。
🎜