标签:star tail 图片 virt start service html doc 文件夹
apache实现动态子域名,abc.zblog.com,则访问/data/www/default/zblog/abc
1.查找httpd.conf所在的位置
root@instance-baidu:/usr/local/apache/conf# sudo find / -name httpd.conf
/usr/local/apache/conf/httpd.conf
2.修改httpd.conf
vi /usr/local/apache/conf/httpd.conf
#取消注释这行
LoadModule rewrite_module modules/mod_rewrite.so
3.修改虚拟主机的配置(如何配置虚拟主机)
sudo vi /usr/local/apache/conf/vhost/default.conf
<VirtualHost *:80> DocumentRoot /data/www/default/zblog ServerName zblog.com Rewriteengine On RewriteCond %{HTTP_HOST} ^[^.]+\.zblog\.com$ RewriteRule ^(.+) %{HTTP_HOST}$1 [C] RewriteRule ^([^.]+)\.zblog\.com(.*) /$1$2 SetOutputFilter DEFLATE Options FollowSymLinks DirectoryIndex index.php index.html index.htm </VirtualHost>
重启一下服务 service httpd restart
4.修改hosts文件做测试:
IP改为你自己的服务器IP
sudo vi /etc/hosts 127.111.39.58 abc.zblog.com 127.111.39.58 zblog.com 127.111.39.58 uuu.com
abc文件夹的内容是:
root@instance-baidu:/data/www/default/zblog/abc# pwd /data/www/default/zblog/abc root@instance-baidu:/data/www/default/zblog/abc# cat index.html i am abc page.
参考:
https://blog.csdn.net/mzllyl/article/details/84434976
标签:star tail 图片 virt start service html doc 文件夹
原文地址:https://www.cnblogs.com/v5captain/p/12496500.html