Lamp: Configure multiple virtual sites and lamp multiple sites
Add multiple domain name sites under the same ip address!
1. View ip addresses
Command: ifconfig
2. Add a domain name
Command: vi/etc/hosts
Enter a domain name, for example
192.168.160.127 www.test.com
192.168.160.127 www.test2.com
3. Create a folder and file for the site to be configured
. Var/www/test/index. php
/Var/www/test2/index. php
4. Modify httpd-vhosts.conf File Content
Enter the command: vi/etc/httpd/extra/httpd-vhosts.conf
Add the following code:
<VirtualHost *: 80>
ServerName www.test.com
DocumentRoot/var/www/html/test/
<Directory "/var/www/html/test">
Options Indexes FollowSymLinks
AllowOverride None
Order allow, deny
Allow From All
</Directory>
</VirtualHost>
Ps: if you do not have this file, you can manually create it. This file is not required for the next time. It is only used to facilitate domain name management!
5, modify the httpd. onf file, and introduce the modified httpd-vhosts.conf file in the httpd. conf file
Run vi/etc/httpd/conf/httpd. conf.
- Delete NameVirtualHost *: comment before 80
- Add the following: Include extra/httpd-vhosts.conf, note that the path here is relative path, because httpd. conf and httpd-vhosts.conf files are both under the httpd directory, so use relative path.
Now you can access the domain name site you just created!