一、配置防火牆
CentOS 7.0默認使用的是firewall作爲防火牆。
1、關閉firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啓動
2、關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #註釋掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #立即禁用
3.安裝apache
yum install httpd #根據提示,輸入Y安裝即可成功安裝
systemctl start httpd.service #啓動apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重啓apache
systemctl enable httpd.service #設置apache開機啓動
4.安裝mariadb(mysql)
yum install mariadb mariadb-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成
systemctl start mariadb.service #啓動MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重啓MariaDB
systemctl enable mariadb.service #設置開機啓動
修改mysql密碼:set password for 'root'@'localhost'=password('root');
mysql授權遠程連接(navicat等): grant all on *.* to root identified by 'root';
5、安裝PHP以及組件,使PHP支持 MariaDB
yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#這裏選擇以上安裝包進行安裝,根據提示輸入Y回車
systemctl restart mariadb.service #重啓MariaDB
systemctl restart httpd.service #重啓apache
測試篇
cd /var/www/html
vi index.php #輸入下面內容
<?php
phpinfo();
?>
:wq! #保存退出
在客戶端瀏覽器輸入服務器IP地址,可以看到相關配置信息