-
安裝apache
# yum -y install httpd # systemctl start httpd.service 啟動(dòng)apache # systemctl stop httpd.service 停止apache # systemctl restart httpd.service 重啟apache # systemctl enable httpd.service 設(shè)置apache開(kāi)機(jī)啟動(dòng)
安裝MariaDB(centos7下默認(rèn)安裝)
- 查詢現(xiàn)有的包
# rpm -qa | grep mariadb - 如果存在mariadb包則刪除這些包(代表全名,盡量刪除全名)
# rpm -e --nodeps mariadb- - 配置MariaDB源
# vim /etc/yum.repos.d/MariaDB.repo - 輸入如下內(nèi)容
[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 - 啟動(dòng)MariaDB
# service mysql start - 配置MariaDB
# mysql_secure_installation
注意 初始秘密未空直接回車然后根據(jù)需要選擇y/n,如果報(bào)錯(cuò)清參照mariadb安裝遇到的問(wèn)題 - 登陸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
測(cè)試PHP
# cd /var/www/html
# vi index.php #輸入下面內(nèi)容
<?php
phpinfo();
?>```
> 訪問(wèn)本機(jī)IP如下圖所示恭喜你成功了
![](http://upload-images.jianshu.io/upload_images/2137957-1b2d078f4fa48b17.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)