準(zhǔn)備篇:
CentOS 7.0系統(tǒng)安裝配置圖解教程
http://www.jb51.net/os/188487.html
一、配置防火墻,開(kāi)啟80端口、3306端口
CentOS 7.0默認(rèn)使用的是firewall作為防火墻,這里改為iptables防火墻。
1、關(guān)閉firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開(kāi)機(jī)啟動(dòng)2、安裝iptables防火墻
yum install iptables-services #安裝vi /etc/sysconfig/iptables #編輯防火墻配置文件# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT
:wq! #保存退出
systemctl restart iptables.service #最后重啟防火墻使配置生效
systemctl enable iptables.service #設(shè)置防火墻開(kāi)機(jī)啟動(dòng)二、關(guān)閉SELINUX
vi /etc/selinux/config#SELINUX=enforcing #注釋掉#SELINUXTYPE=targeted #注釋掉SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
安裝篇:
一、安裝Apache

yum install httpd #根據(jù)提示,輸入Y安裝即可成功安裝systemctl start httpd.service #啟動(dòng)apachesystemctl stop httpd.service #停止apachesystemctl restart httpd.service #重啟apachesystemctl enable httpd.service #設(shè)置apache開(kāi)機(jī)啟動(dòng)
在客戶端瀏覽器中打開(kāi)服務(wù)器IP地址,會(huì)出現(xiàn)下面的界面,說(shuō)明apache安裝成功

二、安裝MariaDB
CentOS 7.0中,已經(jīng)使用MariaDB替代了MySQL數(shù)據(jù)庫(kù)
1、安裝MariaDB

yum install mariadb mariadb-server #詢問(wèn)是否要安裝,輸入Y即可自動(dòng)安裝,直到安裝完成systemctl start mariadb.service #啟動(dòng)MariaDBsystemctl stop mariadb.service #停止MariaDBsystemctl restart mariadb.service #重啟MariaDBsystemctl enable mariadb.service #設(shè)置開(kāi)機(jī)啟動(dòng)cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷貝配置文件(注意:如果/etc目錄下面默認(rèn)有一個(gè)my.cnf,直接覆蓋即可)
2、為root賬戶設(shè)置密碼

mysql_secure_installation
回車,根據(jù)提示輸入Y輸入2次密碼,回車根據(jù)提示一路輸入Y最后出現(xiàn):Thanks for using MySQL!MariaDB密碼設(shè)置完成,重新啟動(dòng) MariaDB:新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注