时间:2023-02-07 16:36:01 | 来源:建站知识
时间:2023-02-07 16:36:01 来源:建站知识
[root@ etc]# cat /etc/redhat-releaseCentOS release 6.9 (Final)
[root@ etc]# httpd -vServer version: Apache/2.2.15 (Unix)Server built: Oct 19 2017 16:43:38
LoadModule rewrite_module modules/mod_rewrite.so
#vhost conf fileInclude "vhost/*.conf"
[root@ httpd]# pwd/etc/httpd[root@ httpd]# lltotal 12drwxr-xr-x 2 root root 4096 Jun 28 19:46 confdrwxr-xr-x 2 root root 4096 Oct 24 2017 conf.dlrwxrwxrwx 1 root root 19 Oct 24 2017 logs -> ../../var/log/httpdlrwxrwxrwx 1 root root 29 Oct 24 2017 modules -> ../../usr/lib64/httpd/moduleslrwxrwxrwx 1 root root 19 Oct 24 2017 run -> ../../var/run/httpddrwxr-xr-x 2 root root 4096 Jun 28 19:47 vhost
<VirtualHost *:80> ServerAdmin 1184795629@qq.com DocumentRoot /var/code/mallServerName www.xxx.cn ServerAlias xxx.cn<Directory "/var/code/mall"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all</Directory></VirtualHost>
<VirtualHost *:80> ServerAdmin 1184795629@qq.com DocumentRoot /var/code/mallServerName mall.phpersay.cn <Directory "/var/code/mall"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all</Directory></VirtualHost>
<VirtualHost *:80> ServerAdmin 1184795629@qq.com DocumentRoot /var/code/blogServerName www.phpersay.cn <Directory "/var/code/blog"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all</Directory></VirtualHost>
[root@ etc]#service httpd restart
127.0.0.1 phpersay.com127.0.0.1 mall.phpersay.com127.0.0.1 xxxx.cn
重启网络[root@ etc]# /etc/init.d/network
重启web服务器Apache的进程httpd[root@ etc]#service httpd restartStopping httpd: [ OK ]Starting httpd: [ OK ]
然并非有用答案。#NameVirtualHost *:80
[root@iZ23hnwptztZ etc]# service httpd restartStopping httpd: [ OK ]Starting httpd: [Mon Jun 28 18:40:25 2021] [warn] NameVirtualHost xxx.xx.xx.110:80 has no VirtualHosts [ OK ]
引起这个警告的原因是NameVirtualHost语法错误 ,对于同一主机支持多个虚拟主机的情况,只需要命名一次NameVirtualHost,如果在每个虚拟主机配置文件中都加上NameVirtualHost *:80 ,则会报这个警告。NameVirtualHost *:80NameVirtualHost xxx.xx.xx.xxx:80
vhost/web.conf<VirtualHost *:80> ServerAdmin 1184795629@qq.com DocumentRoot /var/code/blogServerName www.phpersay.cn <Directory "/var/code/blog"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all</Directory></VirtualHost>
错误原因就是在httpd.conf文件中,重复定义了NameVirtualHost,删除该行,重启Apache即可。关键词:配置