nginx配置多域名泛解析的看這個連接:http://www.javashuo.com/article/p-acnnrtxm-dk.htmlhtml
下面直接來操做:nginx
[root@localhost ~]# find / -name httpd.conf ###查找配置文件目錄地址 /etc/httpd/conf/httpd.conf [root@localhost ~]# vi /etc/httpd/conf/httpd.conf
編輯這個配置文件直接按組合建shift+G至配置文件最下面這行編輯添加你所需的域名配置。多個域名如此類推web
# VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # #<VirtualHost *:80> # ServerAdmin webmaster@dummy-host.example.com # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> ###以上是apache給的示例參考,下面是個人多站點編輯自定義多個域名 <VirtualHost *:80> ServerAdmin 838670594@qq.com DocumentRoot /home/www/www.baidu.com ServerName www.baidu.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost> <VirtualHost *:80> ServerAdmin 838670594@qq.com DocumentRoot /home/www/wiki.baidu.com ServerName wiki.baidu.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>
重啓apache生效apache
systemctl restart httpd.service
總結:服務器
1.先把你要的二級域名解析到服務器ip。跟www同樣解析。ide
2.找到配置文件添加虛擬主機頭配置好目錄文件和域名網站
3.添加的虛擬主機頭指定目錄新建對應目錄文件並上傳網站源碼spa
4.重啓apache生效3d