# 設定 Apache 虛擬主機配置
# CentOS 6
$ vim /etc/httpd/conf/httpd.conf
$ service httpd restart
# CentOS 7
$ cd /etc/httpd/conf.d/
$ vim centos7.ntub.edu.tw.conf
$ vim wordpress7.ntub.edu.tw.conf
$ service httpd graceful
# 建立 www 資料夾並設定其 SELinux 配置
$ cd /home/centos
$ mkdir www
$ chcon -t user_home_dir_t /home/centos
$ chcon -R -t httpd_user_content_t /home/centos/www
# 建立各路由的 index 檔
$ cd www
# CentOS 6
$ mkdir centos6
$ mkdir wordpress6
$ echo ' centos6' >> /home/centos/www/centos6/index.html
$ echo ' wordpress6' >> /home/centos/www/centos6/index.html
# http://centos6.ntub.edu.tw/
# http://wordpress6.ntub.edu.tw/
# CentOS 7
$ mkdir centos7
$ mkdir wordpress7
$ echo ' centos7' >> /home/centos/www/centos7/index.html
$ echo ' wordpress7' >> /home/centos/www/centos7/index.html
# http://centos7.ntub.edu.tw/
# http://wordpress7.ntub.edu.tw/
/etc/httpd/conf/httpd.conf (CentOS6)
NameVirtualHost * :80
<VirtualHost *:80>
ServerAdmin webmaster@c entos6.ntub.edu.tw
DocumentRoot /home/ centos/www/ centos6
ServerName centos6.ntub.edu.tw
ErrorLog logs/centos6.ntub.edu.tw - error_log
CustomLog logs/centos6.ntub.edu.tw - access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@w ordpress6.ntub.edu.tw
DocumentRoot /home/ centos/www/ wordpress6
ServerName wordpress6.ntub.edu.tw
ErrorLog logs/wordpress6.ntub.edu.tw - error_log
CustomLog logs/wordpress6.ntub.edu.tw - access_log common
</VirtualHost>
centos7.ntub.edu.tw.conf (CentOS7)
<VirtualHost *:80>
ServerName centos7.ntub.edu.tw
ServerAlias * .centos7.ntub.edu.tw
ServerAdmin webmaster@c entos7.ntub.edu.tw
ErrorLog /var/ log /httpd/ centos7.ntub.edu.tw .err
CustomLog /var/ log /httpd/ centos7.ntub.edu.tw .log combined
DocumentRoot /home/ centos/www/ centos7
<Directory "/home/centos/www/centos7">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
wordpress7.ntub.edu.tw.conf (CentOS7)
<VirtualHost *:80>
ServerName wordpress7.ntub.edu.tw
ServerAlias * .wordpress7.ntub.edu.tw
ServerAdmin webmaster@w ordpress7.ntub.edu.tw
ErrorLog /var/ log /httpd/ wordpress7.ntub.edu.tw .err
CustomLog /var/ log /httpd/ wordpress7.ntub.edu.tw .log combined
DocumentRoot /home/ centos/www/ wordpress7
<Directory "/home/centos/www/wordpress7">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>