首先先安裝所需套件:
#yum -y install httpd
接下來是啟動web server服務:
#systemctl enable httpd.service
#systemctl start httpd.service
#systemctl status httpd.service
開通防火牆:
#firewall-cmd --permanent --add-service=http
#firewall-cmd --reload
再安裝PHP模組:
#yum -y install php-* --skip-broken php-mysql
重新啟動Web server服務:
#systemctl restart httpd.service
在 /etc/httpd/conf.d目錄中自由新增檔案:
#cd /etc/httpd/conf.d
新增vhosts.conf檔案:
#vim vhosts.conf
<VirtualHost _default_:80>
ServerName www.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
ServerName test1.example.com
DocumentRoot /var/www/vhosts/test1
</VirtualHost>
建立虛擬網路目錄:
#mkdir -p /var/www/vhosts/test1
建立虛擬網頁:
#vim /var/www/vhosts/test1/index.html
Hello!! Test1 Web Site !!
新增DNS紀錄:
#vim /var/named/example.zone
$TTL 10
@ IN SOA dns1.example.com. root (
2016032901;
1H;
2D;
3W;
10 )
@ IN NS dns1.example.com.
@ IN A 192.168.5.220
@ IN MX 10 mail
dns1.example.com. IN A 192.168.5.220
mail IN A 192.168.5.220
ftp IN A 192.168.5.220
www IN A 192.168.5.220
test1 IN A 192.168.5.220 //新增在最後一行
重新啟動DNS服務:
#systemctl restart named
重新啟動Web server服務:
#systemctl restart httpd