admin管理员组文章数量:1794759
Apache部署静态网站
Apache配置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即可网站访问www.example、www.example
版权声明:本文标题:Apache部署静态网站 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686541390a79717.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论