標籤:apache virtualhost apache2.4.6
參考連結:How To Set Up Apache Virtual Hosts on CentOS 7
近日因為需要,需要在一個公網IP的伺服器上配置多個網站,不同的網域名稱訪問不同的網站,用到了Apache的Virtualhost
系統內容:centos 7 + apache 2.4.6 + php + mysql
# 建立網站目錄mkdir -p /var/www/shuaiqijun.com/public_html # 帥旗軍個人部落格 mkdir -p /var/www/hmgzh.net/public_html # 黃梅公眾號網站# www目錄755許可權chmod -R 755 /var/www# 建立首頁vi /var/www/shuaiqijun.com/public_html/index.html #添加任意內容# 建立Virtual配置目錄mkdir /etc/httpd/sites-availablemkdir /etc/httpd/sites-enabled# 配置httpd.confvi /etc/httpd/conf/httpd.conf# 添加以下內容IncludeOptional sites-enabled/*.conf注釋掉# DocumentRoot "/var/www/html"# 建立網站Virtual設定檔vi /etc/httpd/sites-available/shuaiqijun.com.conf# 添加以下內容<VirtualHost *:80> ServerName www.shuaiqijun.com ServerAlias shuaiqijun.com DocumentRoot /var/www/shuaiqijun.com/public_html</VirtualHost><Directory "/var/www/shuaiqijun.com"> Options +Includes -Indexes AllowOverride All Require all granted </Directory>#建立連結ln -s /etc/httpd/sites-available/shuaiqijun.com.conf /etc/httpd/sites-enabled/shuaiqijun.com.conf#配置HOSTSvi /etc/hosts# 更改如下127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain610.100.18.100 shuaiqijun.com10.100.18.100 hmgzh.net#重啟Apachesystemctl restart httpd
Apache 2.4.6 多網域名稱多網站配置