Home > Article > Backend Development > Apache2.4 issues regarding configuring multi-port virtual websites
I have already configured one website, and now I want to change it to multiple websites. Follow the online methodDo I need to change the relevant information of the site I originally configured? Or will httpd-vhosts.conf directly overwrite the website I set in httpd.conf?
I have already configured one website, and now I want to change it to multiple websites. Follow the online methodDo I need to change the relevant information of the site I originally configured? Or will httpd-vhosts.conf directly overwrite the website I set in httpd.conf?
To add a virtual website, just configure it with VirtualHost in httpd.conf.
<code># *:80表示监听本机所有IP(需要配置有Listen 80),星号匹配所有地址, # 因此主服务器(httpd.conf里的DocumentRoot和ServerName)将不会处理任何请求. # 注意,第一个监听80端口VirtualHost将作为default server用于处理找不到匹配的80请求 <VirtualHost *:80> DocumentRoot "/path/to/default" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "/path/to/a.com" ServerName a.com </VirtualHost> <VirtualHost *:80> DocumentRoot "/path/to/b.com" ServerName b.com </VirtualHost></code>
Try modifying the hosts file
Add: 127.0.0.1 your domain name
httpd-vhosts.conf Add a VirtualHost and restart the service. The official configuration manual is very detailed. You will understand after reading it. It is really not suitable to download a wampserver3. There is a tool that automatically adds VirtualHost, so you can learn it.