準備篇:
CentOS 7.0系統安裝配置圖解教程
//www.49028c.com/os/188487.html
一、配置防火墻,開啟80端口、3306端口
CentOS 7.0默認使用的是firewall作為防火墻,這里改為iptables防火墻。
1、關閉firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
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 #設置防火墻開機啟動
二、關閉SELINUX
vi /etc/selinux/config#SELINUX=enforcing #注釋掉#SELINUXTYPE=targeted #注釋掉SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
安裝篇:
一、安裝Apache
yum install httpd #根據提示,輸入Y安裝即可成功安裝systemctl start httpd.service #啟動apachesystemctl stop httpd.service #停止apachesystemctl restart httpd.service #重啟apachesystemctl enable httpd.service #設置apache開機啟動
在客戶端瀏覽器中打開服務器IP地址,會出現下面的界面,說明apache安裝成功
二、安裝MariaDB
CentOS 7.0中,已經使用MariaDB替代了MySQL數據庫
1、安裝MariaDB
yum install mariadb mariadb-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成systemctl start mariadb.service #啟動MariaDBsystemctl stop mariadb.service #停止MariaDBsystemctl restart mariadb.service #重啟MariaDBsystemctl enable mariadb.service #設置開機啟動cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷貝配置文件(注意:如果/etc目錄下面默認有一個my.cnf,直接覆蓋即可)
2、為root賬戶設置密碼
新聞熱點
疑難解答