-
安装apache
# yum -y install httpd # systemctl start httpd.service 启动apache # systemctl stop httpd.service 停止apache # systemctl restart httpd.service 重启apache # systemctl enable httpd.service 设置apache开机启动
安装MariaDB(centos7下默认安装)
- 查询现有的包
# rpm -qa | grep mariadb - 如果存在mariadb包则删除这些包(代表全名,尽量删除全名)
# rpm -e --nodeps mariadb- - 配置MariaDB源
# vim /etc/yum.repos.d/MariaDB.repo - 输入如下内容
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1 - 安装MariaDB
# yum -y install MariaDB-server MariaDB-client - 启动MariaDB
# service mysql start - 配置MariaDB
# mysql_secure_installation
注意 初始秘密未空直接回车然后根据需要选择y/n,如果报错清参照mariadb安装遇到的问题 - 登陆MariaDB(以root用户登陆)回车输入密码即可
# mysql -u root -p
- 安装PHP
# yum -y install php
- 安装PHP组件使其支持MariaDB
# yum -y install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
- 重启MariaDB
# service mysql start
- 重启Apache
# systemctl restart httpd.service
测试PHP
# cd /var/www/html
# vi index.php #输入下面内容
<?php
phpinfo();
?>```
> 访问本机IP如下图所示恭喜你成功了
![](http://upload-images.jianshu.io/upload_images/2137957-1b2d078f4fa48b17.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)