加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux上配置apache实现二级域名访问目录

发布时间:2020-12-13 23:37:17 所属栏目:Linux 来源:网络整理
导读:在下面我们将实现利用www.test.mytest.com访问 根目录下面的test目录 ? 这里以腾讯云为例子: 首先你得具备一个云主机 有一个公网ip 有一个主域名 www.mytest.com为例子 www.mytest.com已经解析到你的公网ip 添加记录 这里记录纸应该填写你的公网ip ? ?这里

在下面我们将实现利用www.test.mytest.com访问 根目录下面的test目录

?

这里以腾讯云为例子:

首先你得具备一个云主机 有一个公网ip

有一个主域名 www.mytest.com为例子

www.mytest.com已经解析到你的公网ip

添加记录

这里记录纸应该填写你的公网ip

?

?这里添加记录大概10分钟即可使用该记录

找到你的apache配置文件

find / -name httpd.conf

打开该文件或者

vi $(find / -name httpd.conf)

?

?

添加

<VirtualHost *:80>
DocumentRoot /var/www/test
ServerName test.mytest.com
<Directory "/var/www/test">
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

?

或者

?#开启url重写模式

RewriteEngine on
?
?
在网站根目录中. htaccess填写
?

?

<VirtualHost *:80>
DocumentRoot /var/www/test
ServerName test.mytest.com
<Directory "/var/www/test">
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

?

填写完后

apachectl restart 重启apachectl

到 /var/www目录下创建一个目录test

在test中添加index.html

地址栏输入

www.test.mytest,com/index.html即可访问

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读