一、配置防火牆
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 -u用戶名 -p密碼 進入mysql
修改mysql密碼:set password for 'root'@'localhost'=password('root');
5、安裝PHP以及組件,使PHP支持 MariaDB
如果我們已經安裝過了PHP,首先將原來的php卸載:
yum remove php php-common
由於linux的yum源不存在php7.0,所以我們要更改yum源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
然後安裝各種擴展:
yum install php70w php70w-cli php70w-common php70w-devel php70w-embedded php70w-fpm php70w-gd php70w-mbstring php70w-mysql php70w-opcache php70w-pdo php70w-xml
最後重啓apache!