15053971836 注册 / 登录

apache绑定一个域名

时间: 阅读:228
apache绑定一个域名

最佳回答

临沂网站建设

临沂网站建设

2023-01-13 04:14:50

你是用apache做虚拟主机吗? 如果是单独一个网站,不需要绑定就可以访问,如果只限制一个域名访问的话,在httpd.conf搜索Listen 80 将其改为 Listen 域名:80 即可。如果是做虚拟主机,需要在httpd.conf最后加上像下面这样的设置:<VirtualHost ithx.net:80>
DocumentRoot "H:/website/wwwroot/idc.qkweb.net/htdocs"
ServerName ithx.net:80
<Directory "H:/website/wwwroot/idc.qkweb.net/htdocs">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml
AllowOverride Options FileInfo
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>

最新回答共有2条回答

  • 清风若雨
    回复
    2023-01-13 06:06:52

    我把我们公司Apache的配置文件粘贴给你看下。我们知道Apache的配置文件位置在/etc/httpd/conf/httpd.conf中,所有的基本配置以及虚拟网站都可以写在这里。

    NameVirtualHost *:80
    <VirtualHost *:80>
    DocumentRoot /home/xwqc/wwwroot
    ServerName xwqc.linux.zhaomuhost.cn
    ServerAlias zhaomu.com yourdomain.com
    DirectoryIndex index.php index.htm index.html
    ErrorLog /home/xwqc/logfiles/error_log
    CustomLog /home/xwqc/logfiles/access_log common
    </VirtualHost>

    其中ServerName是绑定的主域名,ServerAlias中的www.zhaomu.com是绑定的其他附属域名。另外注意配置文件中要设置好端口号,并且关闭服务器防火墙,或者在防火墙上开放80端口后才能正常访问。