>[success] ### 第八难 yum安装Apache PHP MySQL * 要在CentOS 7 上安装新软件, 我们可以使用yum; yum 是 CentOS 套件管理软件, 可以帮我们安装及更新不同的套件, 如Apache, PHP, MariaDB (MySQL) 等(MariaDB 其实就是MySQL 的开源版本!) * 安装新套件 ~~~txt yum install package-name ~~~ * 更新套件 ~~~txt yum update package-name ~~~ * 移除套件 ~~~txt yum remove package-name ~~~ >[info] ### 安装Apache ~~~txt yum install -y httpd ~~~ >[info] ### 安装PHP和想要组件 ~~~txt yum install -y php php-common php-gd php-xml php-mbstring php-mysqlnd php-mcrypt ~~~ >[info] ### 安装MariaDB ~~~txt yum install -y mariadb-server mariadb ~~~ >[warning] ### 其它配置项 * 可以在 /etc/httpd/conf 和 /etc/httpd/conf.d 页面找到apache配置 * 初始的项目路径 : /var/www/html * 启动服务 systemctl start [service-name] ~~~txt systemctl start mariadb.service systemctl start httpd.service ~~~ * 停止服务 systemctl stop [service-name] * 设置自启 systemctl enable [service-name] * 查看服务状态 systemctl status [service-name] ~~~txt firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-port=80/tcp firewall-cmd –reload ~~~ >[danger] ### 测试 ![](https://box.kancloud.cn/0b35cbec1c26c7ed60916b92fa825724_1043x822.png) ~~~txt [root@localhost /]# vim /var/www/html/index.php <?php echo phpinfo(); ?> ~~~ ![](https://box.kancloud.cn/6e36e93f2fa5eca2139ec1601c15f1b4_659x550.png) ~~~txt [root@localhost /]# mysql_secure_installation ~~~ ![](https://box.kancloud.cn/31d3e5b39131c1d1348377aa52afc9cf_815x236.png)