1. Apache安装(Linux安装Apache)
  2. 网站模板(https://sc.chinaz/moban)
  3. Apache配置
    https://httpd.apache/docs/2.4/vhosts/examples.html

    1.编辑:/opt/apache/httpd-2.4.54/conf/httpd.conf
    # Ensure that Apache listens on port 80
    Listen 80
    <VirtualHost *:80>
        DocumentRoot "/opt/apache/website/myweb001"
        ServerName www.example
    
        # Other directives here
        <Directory "/opt/apache/website/myweb001">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot "/opt/apache/website/myweb002"
        ServerName www.example
    
        # Other directives here
        <Directory "/opt/apache/website/myweb002">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
    </VirtualHost>
    注意:/opt/apache/website/myweb001和/opt/apache/website/myweb002为静态网站在虚拟机中的路径
     
    2.重启Apache:httpd -k restart
     
    3.防火墙打开端口权限:firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload
    
    4.编辑:C:\Windows\System32\drivers\etc\hosts
    192.168.1.97 www.example
    192.168.1.97 www.example
    
    解释说明:
    C:\Windows\System32\drivers\etc\hosts为主机hosts文件,可以将域名www.example和www.example
    映射为虚拟机ip,主机浏览器输入www.example和www.example等价于输入192.168.1.97,http的默认端口
    为80,主机浏览器输入192.168.1.97等价于输入192.168.1.97:80,这样就可以定位到虚拟机Apache服务,然后根据主
    机浏览器输入的域名找到对应的ServerName为所输入域名的VirtualHost,这样就可以访问到对应的静态网站了,实际
    应用中静态网站部署在云服务器,只需要将购买的域名解析为云服务器的公网ip即可


  4. 网站访问
    www.example、www.example

更多推荐

Apache部署静态网站